0
$\begingroup$

Rosanswers logo

I've been following this tutorial to understand how I can come up with my own layer for Costmap2D http://wiki.ros.org/costmap_2d/Tutorials/Creating%20a%20New%20Layer

I finished doing the first part (i.e. the "Simple Layer" without the grid) and attempted to run it. So I wrote a launch file to start it.

<?xml version="1.0"?>
<launch>
    <rosparam file="$(find my_package)/config/costmap_params.yaml" command="load" ns="/costmap_2d_node/costmap" />
    <node pkg="costmap_2d" type="costmap_2d_node" name="costmap_2d_node" />
    <node pkg="tf2_ros" type="static_transform_publisher" name="static_transform" args="0 0 0 0 0 0 map base_link" />
</launch>

With the following yaml file for the Costmap parameters. As you can see, my layer is the only layer I'm loading (and I want it that way).

plugins: 
  - {name: MyLayer, type: "MyNamespace::MyLayer"}
publish_frequency: 1.0
footprint: [ [-0.325, -0.325], [-0.325, 0.325], [0.325, 0.325], [0.46, 0.0], [0.325, -0.325] ]

The layer correctly starts and I can see this using a ROS_ERROR() statement I added in the onInitialize() function. I also noticed the reconfigureCB() function getting called. However, that's all I'm getting. The updateCosts() function isn't getting called. I was expecting it to be called, and add a cost to the front of base_link. But whenever I read the costmap data from /costmap_2d_node/costmap/costmap topic, all I get are zeros, which means that it's not working.

Is there something else I need to do to get the Costmap to update? Or is there something fundamental about Costmap2D that I didn't understand yet?


Originally posted by 9a3eedi on ROS Answers with karma: 63 on 2017-07-23

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

do you have any sensors or anything actually adding stuff to the costmap? If there is nothing in it, the costs will always be 0...


Originally posted by mgruhler with karma: 12390 on 2017-07-24

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by 9a3eedi on 2017-07-24:
I do not, but the tutorial code is supposed to put a cost manually in the robot's cell when the updateCosts function is called. The only layer in the costmap is the tutorial code layer. I should at least see something even without any sensors

Comment by 9a3eedi on 2017-08-09:
Hi, it turns out that you are correct. The costmap will not run if there are no messages being published to any of its subsrcibed topics. If your plugin is the only one running in the costmap, then you need to subscribe to at least one topic in order for it to do something. Can you post an answer?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.