custom global planner with multiple cpp and h files
Hi
I have created a custom planner following this tutorial:
http://wiki.ros.org/navigation/Tutori...
I created the files:
GA_global_planner.cpp and GA_global_planner.h
Also, I needed other utility classes:
Path.cpp, Path.h, Map.cpp, Map.h, GenericPathPlanner.cpp, GenericPathPlanner.h , OccupancyGridMap.cpp, OccupancyGridMap.h , all are necessary for the planning.
This is part of GA_global_planner.h,
#include "GenericPathPlanner.h"
#include "OccupancyGridMap.h"
#include "Map.h"
#include "Path.h"
class GAGlobalPlannerROS : public nav_core::BaseGlobalPlanner, public GenericPathPlanner
NOTE: that the class GAGlobalPlannerROS inherits both BaseGlobalPlanner and GenericPathPlanner
NOTE: that the class OccupancyGridMap inherits public from class Map
I can successfully compile and build the package of this planner.
However, when I try to use the planner with move_base got error:
[FATAL] [1623866783.746869597, 0.412000000]: Failed to create the GA_planner/GAGlobalPlannerROS planner, are you sure it is properly registered and that the containing library is built? Exception: Failed to load library /home/evadro/Desktop/Eman/ros_workspace/devel/lib//libGA_planner_lib.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = /home/evadro/Desktop/Eman/ros_workspace/devel/lib//libGA_planner_lib.so: undefined symbol: _ZN18GenericPathPlanner8findPathEP16OccupancyGridMapP4Path)
[move_base-12] process has died [pid 17199, exit code 1, cmd /opt/ros/kinetic/lib/move_base/move_base __name:=move_base __log:=/home/evadro/.ros/log/8a34ae68-cecd-11eb-b87b-9e3f7c65cb79/move_base-12.log].
log file: /home/evadro/.ros/log/8a34ae68-cecd-11eb-b87b-9e3f7c65cb79/move_base-12*.log
When I rewrite the implementation without Path.cpp, Path.h, Map.cpp, Map.h, GenericPathPlanner.cpp, GenericPathPlanner.h , OccupancyGridMap.cpp, OccupancyGridMap.h, every thing works fine and I can use my planner in ROS.
However, I need to implement another custom planner, but I have to use Path.cpp, Path.h, Map.cpp, Map.h, GenericPathPlanner.cpp, GenericPathPlanner.h , OccupancyGridMap.cpp, OccupancyGridMap.h because the implementation will be very complicated without them.
How can I solve this problem ( using multiple cpp files with the custom planner)?
Many thanks
UPDATE:
at the beginning of the source GA_global_planner.cpp
PLUGINLIB_EXPORT_CLASS(GA_planner::GAGlobalPlannerROS, nav_core::BaseGlobalPlanner)
at the beginning of GenericPathPlanner.cpp
PLUGINLIB_EXPORT_CLASS(GenericPathPlanner, nav_core::BaseGlobalPlanner)
at the beginning of OccupancyGridMap.cpp
PLUGINLIB_EXPORT_CLASS(OccupancyGridMap, nav_core::BaseGlobalPlanner)
at the beginning of Map.cpp
PLUGINLIB_EXPORT_CLASS(Map, nav_core::BaseGlobalPlanner)
at the beginning of Path.cpp
PLUGINLIB_EXPORT_CLASS(Path, nav_core::BaseGlobalPlanner)
* The launch file *
<launch>
<arg name="use_rosbot" default="false"/>
<arg name="use_gazebo" default="true"/>
<param if="$(arg use_gazebo)" name="use_sim_time" value="true"/>
<!-- Bring the ROSbot model and show it in Gazebo and in Rviz -->
<include file="$(find rosbot_description)/launch/rosbot_rviz.launch"/>
<!-- Map server -->
<arg name="map_file" default="$(find rosbot_navigation)/maps/willowgarage-refined.yaml"/>
<node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />
<!--- tf -->
<node unless="$(arg use_rosbot)" pkg="tf" type="static_transform_publisher" name="map_odom_tf" args="0 0 0 0 0 0 map odom 100" />
<node if="$(arg use_rosbot)" pkg="tf" type="static_transform_publisher" name="base_link_to_laser" args="0 0 0 3.14 0 0 base_link laser 100" /> ...
Did you add
PLUGINLIB_EXPORT_CLASS
to your source code?Did you update your
CMakeLists.txt
withadd_library(global_planner_lib src/path_planner/global_planner/global_planner.cpp)
?Did you create the
global_planner_plugin.xml
file in your package?Did you update your
package.xml
file?Please upate the post with the
launch
file you are using.Thank you. I have edited my question above and added more details
What happens when you try to query the package system (
rospack plugins --attrib=plugin nav_core
)?I added PLUGINLIB_EXPORT_CLASS at the beginning of each class composes the library, as I edit above.
Also I edit the plugin.xml and add all cpp files composes the library (edit above).
After .lanuch, i got different error:
this the output of rospack: