zl程序教程

您现在的位置是:首页 >  其他

当前栏目

ROS2极简总结-Nav2-概述(中)控制器

2023-03-31 10:32:01 时间

上一节,主要介绍导航功能包Nav2的规划部分,本节为控制部分:

控制器概述 Controller

注意黄色部分,具体看下图。

插件 Plugins
  • 控制器
  • 过程检查
  • 目标检查

控制器服务器 Controller Server

[nav2_controller_server]

  • 输入:全局路径,代价地图
  • 输出:速度指令

默认为 DWB 控制器

发布速度:~/cmd_vel (geometry_msgs/Twist)

包含多个插件:

  • 轨迹生成器插件
  • 评分插件
  • 目标检查器插件

DWB控制器 DWB Controller

轨迹生成器插件

负责生成局部轨迹并输出指令速度。

目前有两个插件(一次只能加载一个):

  • 标准轨迹生成器
  • 有限加速器
    FollowPath:
      plugin: "dwb_core::DWBLocalPlanner"
      debug_trajectory_details: True
      min_vel_x: 0.0
      min_vel_y: 0.0
      max_vel_x: 0.22
      max_vel_y: 0.0
      max_vel_theta: 1.0
      min_speed_xy: 0.0
      max_speed_xy: 0.22
      min_speed_theta: 0.0

评分插件 Critic Plugins

对轨迹生成器生成的轨迹进行评分。 可以加载多个插件并将它们的分数添加到每个轨迹的最终分数中。

示例:

  • BaseObstacle:基于路径经过代价地图的位置
  • ObstacleFootprint:基于验证机器人足迹上的所有点都没有接触到代价地图中标记的障碍物。
  • GoalDist:基于轨迹使机器人与目标姿势的接近程度。
  • ...
 critics: ["RotateToGoal", "Oscillation", "BaseObstacle", "GoalAlign", "PathAlign", "PathDist", "GoalDist"]

目标检查器 Goal Checker

验证机器人是否达到了目标

目前有两个插件(一次只能加载一个):

  • SimpleGoalChecker - 检查位置以查看机器人是否已达到目标。
  • StoppedGoalChecker - 检查位置以及机器人是否已停止。

可以参数化目标“范围”(位置、旋转等...)。

goal_checker:
  plugin: "nav2_controller::SimpleGoalChecker"
  xy_goal_tolerance: 0.25
  yaw_goal_tolerance: 0.25
  stateful: True
controller_server:
  ros__parameters:
    use_sim_time: False
    controller_frequency: 20.0
    min_x_velocity_threshold: 0.001
    min_y_velocity_threshold: 0.5
    min_theta_velocity_threshold: 0.001
    controller_plugins: ["FollowPath"]

    # DWB parameters
    FollowPath:
      plugin: "dwb_core::DWBLocalPlanner"
      debug_trajectory_details: True
      min_vel_x: 0.0
      min_vel_y: 0.0
      max_vel_x: 0.22
      max_vel_y: 0.0
      max_vel_theta: 1.0
      min_speed_xy: 0.0
      max_speed_xy: 0.22
      min_speed_theta: 0.0
      # Add high threshold velocity for turtlebot 3 issue.
      # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/75
      acc_lim_x: 2.5
      acc_lim_y: 0.0
      acc_lim_theta: 3.2
      decel_lim_x: -2.5
      decel_lim_y: 0.0
      decel_lim_theta: -3.2
      vx_samples: 20
      vy_samples: 5
      vtheta_samples: 20
      sim_time: 1.7
      linear_granularity: 0.05
      angular_granularity: 0.025
      transform_tolerance: 0.2
      xy_goal_tolerance: 0.25
      trans_stopped_velocity: 0.25
      short_circuit_trajectory_evaluation: True
      stateful: True
      critics: ["RotateToGoal", "Oscillation", "BaseObstacle", "GoalAlign", "PathAlign", "PathDist", "GoalDist"]
      BaseObstacle.scale: 0.02
      PathAlign.scale: 32.0
      PathAlign.forward_point_distance: 0.1
      GoalAlign.scale: 24.0
      GoalAlign.forward_point_distance: 0.1
      PathDist.scale: 32.0
      GoalDist.scale: 24.0
      RotateToGoal.scale: 32.0
      RotateToGoal.slowing_factor: 5.0
      RotateToGoal.lookahead_time: -1.0

controller_server_rclcpp_node:
  ros__parameters:
    use_sim_time: False

下一节介绍恢复器。