Local Costmap's Obstacle layer not detecting obstacles
I am using RTABMAP along with Nav2 and ROS2 Galactic. The robot uses a RGBD camera and I am using the depthimagetolaserscan package to transform the images into a laserscan.
First of all it is worth to mention that the local costmap only appears if it is defined with an static_layer, like the global costmap. Otherwise it doesn't appear.
Moreover, you can see here an image of the problem. Once the map is mapped using RTABMAP, I introduce a rock in the middle of the cave, that, as you can see, it is detected by the laserscan and so by the camera. However, the local costmap doesn`t reflect this obstacle in the map.
I attach here the definition of the local costmap plugins.
plugins: ["static_layer", "obstacle_layer", "inflation_layer"]
inflation_layer:
plugin: "nav2_costmap_2d::InflationLayer"
cost_scaling_factor: 3.0
inflation_radius: 0.6
obstacle_layer:
plugin: "nav2_costmap_2d::ObstacleLayer"
enabled: True
observation_sources: scan
scan:
topic: /scan
max_obstacle_height: 5.0
min_obstacle_height: 0.0
obstacle_max_range: 6.0
obstacle_min_range: 0.0
raytrace_max_range: 10.0
raytrace_min_range: 0.0
clearing: True
marking: True
data_type: "LaserScan"
static_layer:
map_subscribe_transient_local: True
always_send_full_costmap: True
Asked by marpeja on 2022-08-31 06:17:24 UTC
Answers
I came up with one hypothesis. The cost map has been created with obstacle_layer, but it has been overwritten with static_layer. This is the reason.
Could you check to see if the obstacle_layer does not show up when the static_layer is removed?
If this is correct, then
Changing use_maximum
to True
should improve this.
Setting always_send_full_costmap
to False
may also help.
I have considered other candidates.
I think there is a possibility that sensor_frame
needs to be specified.
If not specified, the frame_id of the /scan
topic seems to be used; the frame_id may be different than usual due to the use of depthimage_to_laserscan
.
It appears that observation_sources is written differently.
I expect that something will change if it is written as follows.
observation_sources: {"scan"}
ref: https://navigation.ros.org/configuration/packages/costmap-plugins/obstacle.html
Asked by miura on 2022-09-04 05:23:58 UTC
Comments
Thanks a lot @miura but sadly that isn't the solution. Although I tried it, you can see here an example of configuration at the bottom of the page: [https://navigation.ros.org/configuration/packages/configuring-costmaps.html]
Asked by marpeja on 2022-09-04 13:24:03 UTC
Yeah @miura I thought it could be something related to the frame_id too, but even after specifying it, it doesn't work...
If you want to, you can take a look to this thread to see if you know how to implement the suggested solution, as I haven't been able to do so...
https://github.com/ros-planning/navigation2/issues/3014
Asked by marpeja on 2022-09-05 10:19:24 UTC
I have read this thread. building yourself nav2 might be one solution.
Also, I came up with dirty hack after reading the following text.
When a static map is set or the global costmap/footprint/frame are used, things work fine!
You create a blank map with no obstacles and load it as a static_layer. I don't know if it would work, but if you don't have time to wait for a new version of nav2 to be released, you might try it.
Asked by miura on 2022-09-06 07:58:11 UTC
Building myself Nav2 how?? I cloned it in my workspace and override de default Nav2 I installed in the root workspace of Nav2, but I don't know if I have to do something else...
I read the same about the static layer, that is why although I preferred not to use one in my local costmap I set it.
Thank you again @miura
Asked by marpeja on 2022-09-07 04:48:00 UTC
Have you seen the following Build instructions are posted here.
https://navigation.ros.org/build_instructions/index.html#for-main-branch-development
Also, you may need to be careful which nav2 you are referring to, the original nav2 or the built nav2. Output of ros2 pkg prefix --share nav2_costmap_2d
should be the path to the built nav2.
Asked by miura on 2022-09-07 09:08:27 UTC
Yeah, I checked it and it is using the nav2_costmap_2d I am using in my workspace. However, I downloaded turtlesim_simulations package in my workspace too and tried the project that uses RTABMAP with Nav2 (as I do), and there, the obstacle layer of the costmap works with the lectures of the laser sensor the turtlebot has, but not with its camera.... Could it be that I have some dependencies or something wrong?? I am also thinking about having the laser misconfigured for Nav2, although this would be strange as it works perfectly fine with the robot…
Asked by marpeja on 2022-09-07 16:04:13 UTC
@miura I am also thinking about the quality of services. My camera, which is the libgazebo_ros_camera.so gazebo plugin is publishing as Best Effort (I don't know why, because in Ros2 Foxy published as Reliable) so I have to changed the qos of depthimage_to_laserscan to Best Effort too (I wanted to do it in the camera controller but I didn't know how). I have checked that the ObstacleLayer subscribes to the LaserScan as Best Effort too, so there shouldn't be a problem, but I don't know.
Asked by marpeja on 2022-09-08 02:57:30 UTC
Comments