Recommendation on how to set path_planner and controller parameters

Hi,

I am working in the Path Planning section of the rosject, however I am having difficulties in setting the path_planner and controller parameters. The robot does not move smothly when I send a goal, sometimes it moves, then stops and it does not reach the goal.

An example of an error that I got is the following:

controller_server-2] [ERROR] [1680286255.233165771] [tf_help]: Transform data too old when converting from odom to map
[controller_server-2] [ERROR] [1680286255.233208610] [tf_help]: Data time: 588s 366000000ns, Transform time: 588s 66000000ns
[controller_server-2] [ERROR] [1680286255.233353927] [controller_server]: Unable to transform robot pose into global plan's frame
[controller_server-2] [WARN] [1680286255.233455596] [controller_server_rclcpp_node]: [follow_path] [ActionServer] Aborting handle.


image

As you can see from the images, the robot stopped without reaching its goal.

The parameters that I have changed are:

  • Robot diameter for global and local cost map.
  • Controller frequency
  • max_vel_x
  • max_vel_theta

path_planner.yaml

planner_server:
  ros__parameters:
    expected_planner_frequency: 8.0
    use_sim_time: True
    planner_plugins: ["GridBased"]
    GridBased:
      plugin: "nav2_navfn_planner/NavfnPlanner"
      tolerance: 0.5
      use_astar: true
      allow_unknown: true
global_costmap:
  global_costmap:
    ros__parameters:
      update_frequency: 1.0
      publish_frequency: 1.0
      global_frame: map
      robot_base_frame: base_link
      use_sim_time: True
      robot_radius: 0.12
      resolution: 0.05
      track_unknown_space: true
      plugins: ["static_layer", "obstacle_layer", "inflation_layer"]
      static_layer:
        plugin: "nav2_costmap_2d::StaticLayer"
        map_subscribe_transient_local: True
      inflation_layer:
        plugin: "nav2_costmap_2d::InflationLayer"
        cost_scaling_factor: 2.0
        inflation_radius: 0.1
      always_send_full_costmap: True
      obstacle_layer:
        plugin: "nav2_costmap_2d::ObstacleLayer"
        enabled: True
        observation_sources: scan
        scan:
          topic: /scan
          max_obstacle_height: 2.0
          clearing: True
          marking: True
          data_type: "LaserScan"
          raytrace_max_range: 3.0
          raytrace_min_range: 0.0
          obstacle_max_range: 2.5
          obstacle_min_range: 0.0

controller.yaml

controller_server:
  ros__parameters:
    use_sim_time: True
    controller_frequency: 8.0
    min_x_velocity_threshold: 0.001
    min_y_velocity_threshold: 0.5
    min_theta_velocity_threshold: 0.001
    failure_tolerance: 0.3
    progress_checker_plugin: "progress_checker"
    goal_checker_plugins: ["general_goal_checker"] 
    controller_plugins: ["FollowPath"]

    # Progress checker parameters
    progress_checker:
      plugin: "nav2_controller::SimpleProgressChecker"
      required_movement_radius: 0.5
      movement_time_allowance: 10.0
    # Goal checker parameters
    general_goal_checker:
      stateful: True
      plugin: "nav2_controller::SimpleGoalChecker"
      xy_goal_tolerance: 0.25
      yaw_goal_tolerance: 0.25
    # 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.20
      max_vel_y: 0.0
      max_vel_theta: 0.52
      min_speed_xy: 0.0
      max_speed_xy: 0.2
      min_speed_theta: 0.0
      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
local_costmap:
  local_costmap:
    ros__parameters:
      update_frequency: 5.0
      publish_frequency: 2.0
      global_frame: odom
      robot_base_frame: base_link
      use_sim_time: True
      rolling_window: true
      width: 1
      height: 1
      resolution: 0.05
      robot_radius: 0.12
      plugins: ["voxel_layer", "inflation_layer"]
      inflation_layer:
        plugin: "nav2_costmap_2d::InflationLayer"
        cost_scaling_factor: 1.8
        inflation_radius: 0.1
      voxel_layer:
        plugin: "nav2_costmap_2d::VoxelLayer"
        enabled: True
        publish_voxel_map: True
        origin_z: 0.0
        z_resolution: 0.05
        z_voxels: 16
        max_obstacle_height: 2.0
        mark_threshold: 0
        observation_sources: scan
        scan:
          topic: /scan
          max_obstacle_height: 2.0
          clearing: True
          marking: True
          data_type: "LaserScan"
          raytrace_max_range: 3.0
          raytrace_min_range: 0.0
          obstacle_max_range: 2.5
          obstacle_min_range: 0.0
      static_layer:
        map_subscribe_transient_local: True
      always_send_full_costmap: True

I will appreciate any kind of help.

Thanks
Best Regards,
Ronaldo

Hi @w.ronaldo.cd ,

The robot uses footprint not robot_radius.
Make sure to change the critics in controller.yaml to account for change from robot_radius to footprint. BaseObstacle to ObstacleFootprint - if you use footprint.

Set it to a value less than or equal to 10.0.

Visit this repo to get more info: turtlebot3/turtlebot3_navigation/param at master · ROBOTIS-GIT/turtlebot3 · GitHub

Usually, the cause of robot not reaching the goal happens when planner_frequency >= controller_frequency. Make sure you set controller_frequency > planner_frequency.

This must be base_footprint. If you look into your tf tree, you may not find base_link.

Also in the controller.yaml file, voxel_layer properties should come before inflation_layer properties. static can stay at the bottom.

Try these fixes and let me know if your situation improved.

Regards,
Girish

Hi @girishkumar.kannan ,

I am following this discussion and wonder how to know the planner_frequency and controller_frequency?
Additionally, where to specify ObstacleFootprint critics in controller.yaml? I don’t see the word critics in it?

Thank you

Hi @AlfoChri ,

I hope you are working on ROS2 Nav2 Stack and not ROS1.

You can find planner_frequency and controller_frequency in the planner.yaml and controller.yaml files respectively.

You can find controller critics in the controller.yaml file under the controller_server configuration (have a look at the file shared above by @w.ronaldo.cd ).

You can find a line similar to this line which does have the word critics in it!

Regards,
Girish

Hi @girishkumar.kannan ,

Thanks for the reply.

Yes, I am able to change that critics and it works fine now.

For the frequency, I assume that the controller frequency is named the same, but for the planner, is it the update_frequency or the publish_frequency? How to know that the planner frequency >= controller?
Planner configuration:
Screenshot from 2023-07-13 10-53-32
Controller configuration:
Screenshot from 2023-07-13 10-54-07

So the controller frequency > planner_frequency then?

Regards

Hi @AlfoChri ,

Why don’t you go through the planner.yaml parameters completely?
When I say planner_frequency, why do you look into update_frequency and publish_frequency? Neither of those two parameters have the word planner in them!

When I say planner_frequency I mean expected_planner_frequency.

Yes, generally controller_frequency should be greater than planner_frequency - but the numbers depend on how fast your computer is!
If you have a 1 MHz computer then a safe value for planner is 1 Hz and for controller is 2 Hz.
If you have a 12 GHz computer, then you can have planner at 10 Hz and controller at 50 Hz.
The usual relation what I use is controller frequency = (1.5 to 2.0) x planner frequency.

Regards,
Girish

1 Like