How to know if the plugin has been written properly and loaded into the system successfully?

Hi, several things here:

  1. 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.

  2. I can see a first error and is that your class VirtualWall is not inheriting from public 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 named nav2_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.

  1. 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)
  1. Do not use cout to print messages. Use RCLCPP_DEBUG instead so the messages are centralized by the ROS system, and we can be sure that we receive them (some cout 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());
  1. 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 by RCLCPP_DEBUG calls, add some of those on each function of your class, and then see the result?