Hi, several things here:
-
please do not put all the configurations of navigation into a single config file. This only makes EVERYTHING A LOT MORE COMPLEX TO DEBUG. Separate the configs for the different parts of navigation (localization, path planning, etc…). Then, only share what is relevant to the problem.
-
I can see a first error and is that your class
VirtualWall
is not inheriting frompublic nav2_costmap_2d::Layer
As it is explained in the course, Unit 3:
- Your custom class name is
GradientLayer
and inherits from the base class namednav2_costmap_2d::Layer
. It is from here that you inherit methods and override them.
Maybe you defined like that in the .hpp file? Please show.
- The Plugin declaration has to be at the end of the cpp file as explained here:
// This is the macro allowing a custom_nav2_costmap_plugin::GradientLayer class
// to be registered in order to be dynamically loadable of base type nav2_costmap_2d::Layer.
// Usually places in the end of cpp-file where the loadable class written.
#include "pluginlib/class_list_macros.hpp"
PLUGINLIB_EXPORT_CLASS(custom_nav2_costmap_plugin::GradientLayer, nav2_costmap_2d::Layer)
- Do not use
cout
to print messages. UseRCLCPP_DEBUG
instead so the messages are centralized by the ROS system, and we can be sure that we receive them (somecout
messaged maybe cached and not shown on screen when they where generated). Example:
RCLCPP_DEBUG(rclcpp::get_logger(
"nav2_costmap_2d"), "GradientLayer::onFootprintChanged(): num footprint points: %lu",
layered_costmap_->getFootprint().size());
- What is the output you are getting when you launch everything? If your code is correct, you should at least see the message of the constructor of the class. If not, then it means that it is not being loaded and the error lies in the way the class is constructed or the way the plugin is specified. Can you please change all the
cout
byRCLCPP_DEBUG
calls, add some of those on each function of your class, and then see the result?