ROS 1 obstacle avoidance

I’d like to share my issue to get a better understanding of what’s happening. I’ll be as descriptive as possible.

Here’s the situation: I have a mobile robot that uses ROS 1 and is equipped with a lidar (rplidar A1). The robot’s goal is to avoid obstacles on a predefined map as well as dynamically detected obstacles (moving obstacles) using the lidar. The robot successfully avoids the predefined obstacles on the map, but I’m encountering issues with dynamic obstacle avoidance. My robot is creating a path to avoid the obstacle but ic very close to it, so it cannot avoid it, and is doing back and forward movements withou any succesful result. I tried to increase the inflation_radius, I changed aso some other parameters but is like they do not affect the creation of the path. You can see the picture below about the path that is created.

I’m sharing my global and local YAML files, along with the launch files related to the navigation system, for your reference.

local costmap

local_costmap:
   global_frame: odom # 09/25 it was odom 
   robot_base_frame: base_link
   update_frequency: 5.0 # 10 /5.0
   publish_frequency: 5.0 #10
   #transform_tolerance: 0.5
   width: 4.0 
   height: 4.0 
   resolution: 0.05
   static_map: false
   rolling_window: true
   
   
   
   
   
   footprint: [[0.3, 0.3], [0.3, -0.3], [-0.3, -0.3], [-0.3, 0.3]] # 11/07/2024
   obstacle_range: 5 #2.5 0.5 before was 1 (09/30)  it was 3 and changed to 5 on 10/11/2024
   raytrace_range: 5 #3.0 0.8 before was 2 (09/30)  it was 3 and changed to 5 on 10/11/2024
   
   plugins: 
      #- {name: static_layer,            type: "costmap_2d::StaticLayer"} εγινε σχολιο 09/24/24
      - {name: inflation_layer,         type: "costmap_2d::InflationLayer"}
      - {name: obstacle_layer,          type: "costmap_2d::ObstacleLayer"}

   static_layer: # I did comment 11/09/2024 (maybe net time do not have it as a comment) 09/11/2024 we were able as it is to see the obstacle in real time of the agv. not the obstacle that we already had
        enabled:              true
        map_topic:            map # was /map 10/11/2024
#09/13/1024 το βγαλα απο σχολιο το στατικ λειερ

   inflation_layer:
        enabled:              true
        cost_scaling_factor:  10 # it was 5 10/11/2024  
        inflation_radius:     1.5 #it was 0.5 10/11/2024

   obstacle_layer:
        enabled: true #11/09/2024 false
        observation_sources: laser_scan_sensor
        footprint_clearing_enabled: true
        laser_scan_sensor: {data_type: LaserScan, sensor_frame: laser, clearing: true, marking: true, topic: LaserScan}

common costmap

#map_type: costmap

obstacle_range: 5  #it was 3 and changed to 5 on 10/11/2024 
raytrace_range: 5  #it was 3 and changed to 5 on 10/11/2024 
#transform_tolerance: 0.2
footprint: [[0.3, 0.3], [0.3, -0.3], [-0.3, -0.3], [-0.3, 0.3]]
#robot_radius: 0.0
inflation_radius: 1.5 #it was 0.5 10/11/2024
observation_sources: laser_scan_sensor
laser_scan_sensor: {sensor_frame: laser_frame, data_type: LaserScan, topic: scan, marking: true, clearing: true}

global costmap

global_costmap:
   global_frame: map
   robot_base_frame: base_link
   update_frequency: 5.0
   publish_frequency: 5.0
   #transform_tolerance: 0.5 14/06 change 
   static_map: true

DWA planner

DWAPlannerROS:
  max_vel_x: 0.22
  min_vel_x: -0.22
  max_vel_y: 0.0
  min_vel_y: 0.0
  max_vel_trans: 0.22
  min_vel_trans: 0.11
  max_vel_theta: 2.75
  min_vel_theta: 1.37
  acc_lim_x: 2.5
  acc_lim_y: 0.0
  acc_lim_theta: 3.2
  xy_goal_tolerance: 0.05
  yaw_goal_tolerance: 0.17
  latch_xy_goal_tolerance: false
  sim_time: 1.5
  vx_samples: 20
  vy_samples: 0
  vth_samples: 40
  controller_frequency: 10.0
  path_distance_bias: 32.0
  goal_distance_bias: 20.0
  occdist_scale: 0.02
  forward_point_distance: 0.325
  stop_time_buffer: 0.2
  scaling_speed: 0.25
  max_scaling_factor: 0.2
  oscillation_reset_dist: 0.05
  publish_traj_pc: true
  publish_cost_grid_pc: true

AMCL launch

<launch>
<!-- Load the map -->
<!-- <arg name="map_file" default="/home/ubuntu/psybot_ws/testst1.yaml"/> -->
 
    <!-- Run AMCL -->
<node pkg="amcl" type="amcl" name="amcl" output="screen">
<param name="odom_frame_id" value="odom"/>
<param name="base_frame_id" value="base_link"/>
<param name="global_frame_id" value="map"/>
<param name="min_particles" value="100"/>
<param name="max_particles" value="2000"/>
<param name="initial_pose_x" value="0.0"/>
<param name="initial_pose_y" value="0.0"/>
<param name="initial_pose_a" value="0.0"/>
<param name="laser_min_range" value="-1.0"/>
<param name="laser_max_range" value="0.5"/> <!-- change from 2 to 0.5  07/02/2024 -->
<param name="laser_max_beams" value="30"/> 
<param name="gui_publish_rate" value="10.0"/>

<!-- 02/07/2024, these parameters are used to decrease the influence of the lidar. -->
<param name="laser_z_hit" value="0.05"/>
<param name="laser_z_rand" value="0.95"/>
<param name="laser_sigma_hit" value="1.0"/>



<!-- Remap the laser topic -->

</node>
<!-- Transform broadcaster for the static transform between map and odom if needed -->
<!-- You might need to adjust or remove this depending on your setup -->
<node pkg="tf" type="static_transform_publisher" name="odom_to_map_broadcaster"
          args="0 0 0 0 0 0 1 map odom 100"/>
</launch>

MoveBase Launch

<?xml version="1.0"?>
<launch>

  <!-- Run the map server -->
 <!-- <arg name="map_file" default="/home/ubuntu/psybot_ws/testst1.yaml"/> -->
 <!-- <arg name="move_forward_only" default="true"/> -->
 <!-- <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" /> -->

<!-- <arg name="no_static_map" default="false"/> -->
  

  <arg name="base_global_planner" default="navfn/NavfnROS"/>
  <arg name="base_local_planner" default="dwa_local_planner/DWAPlannerROS"/>

  <node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen">

    <param name="base_global_planner" value="$(arg base_global_planner)"/>
    <param name="base_local_planner" value="$(arg base_local_planner)"/> 
    <param name="recovery_behavior_enabled" value="true"/> 
    <param name="controller_frequency" value="1.0"/> 

    <rosparam file="/home/ubuntu/psybot_ws/costmap_common_params.yaml" command="load" ns="global_costmap" />
    <rosparam file="/home/ubuntu/psybot_ws/costmap_common_params.yaml" command="load" ns="local_costmap" />
    <rosparam file="/home/ubuntu/psybot_ws/local_costmap_params.yaml" command="load" />
    <rosparam file="/home/ubuntu/psybot_ws/global_costmap_params.yaml" command="load" />

    <!-- Load DWA Local Planner parameters -->
    <rosparam file="/home/ubuntu/psybot_ws/dwa_local_planner_params.yaml" command="load" />
  </node>

</launch>

Hi @slek, welcome to the community!

It seems you are at the point where everything in your move_base setup is working, and now it is time to tune its parameters.

The first tip I’d recommend is changing the color scheme of the local costmap Costmap. This will help you identify what the robot is reacting to at the local level.

Even if a dynamic obstacle is not in the global costmap, it should have an inflation radius, but I don’t think I see that in the screenshot you are sharing.

Besides that:

  • You increased the inflation_radius to 1.5, which is good for creating buffer zones. However, the cost_scaling_factor of 10 might be making this inflated cost map very steep, meaning the robot may not see a gradual enough penalty for paths close to obstacles. Try reducing it.
  • Try increasing goal_distance_bias to prioritize avoiding dynamic obstacles over heading directly toward the goal.
  • Make sure that the sim_time aligns with the gazebo time.
  • Try increasing the controller frequency.

Hi @roalgoal ,

Thank you very much for your response!

Regarding the inflation issue, the reason it affected the value increase but not the obstacles was due to the ordering of the layers; the inflation_layer needs to be positioned after the obstacle_layer. I’ll also test the parameter adjustments you suggested.

plugins:
#- {name: static_layer, type: “costmap_2d::StaticLayer”} εγινε σχολιο 09/24/24
- {name: inflation_layer, type: “costmap_2d::InflationLayer”}
- {name: obstacle_layer, type: “costmap_2d::ObstacleLayer”}

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.