compile error related to <nav_msgs::Path> publisher
I am trying to publish the path produced by my global_planner plugin
(named my_global_planner
) using a publisher named global_plan_pub
.
Unfortunately, I keep getting this error when I try to compile my package (named my_global_planner
).
It compiles successfully if I comment out the line global_plan_pub.publish(plan)
from the global_planner.cpp
file.
I have included my header file (named global_planner.h
) and source file (named global_planner.cpp
) below.
/opt/ros/melodic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum<M>::value(const M&) [with M = std::vector<geometry_msgs::PoseStamped_<std::allocator<void> > >]’:
/opt/ros/melodic/include/ros/message_traits.h:254:102: required from ‘const char* ros::message_traits::md5sum(const M&) [with M = std::vector<geometry_msgs::PoseStamped_<std::allocator<void> > >]’
/opt/ros/melodic/include/ros/publisher.h:113:7: required from ‘void ros::Publisher::publish(const M&) const [with M = std::vector<geometry_msgs::PoseStamped_<std::allocator<void> > >]’
/home/skpro19/catkin_ws/src/my_global_planner/src/global_planner.cpp:94:33: required from here
/opt/ros/melodic/include/ros/message_traits.h:125:14: error: ‘const class std::vector<geometry_msgs::PoseStamped_<std::allocator<void> > >’ has no member named ‘__getMD5Sum’
return m.__getMD5Sum().c_str();
~~^~~~~~~~~~~
/opt/ros/melodic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::DataType<M>::value(const M&) [with M = std::vector<geometry_msgs::PoseStamped_<std::allocator<void> > >]’:
/opt/ros/melodic/include/ros/message_traits.h:263:104: required from ‘const char* ros::message_traits::datatype(const M&) [with M = std::vector<geometry_msgs::PoseStamped_<std::allocator<void> > >]’
/opt/ros/melodic/include/ros/publisher.h:113:7: required from ‘void ros::Publisher::publish(const M&) const [with M = std::vector<geometry_msgs::PoseStamped_<std::allocator<void> > >]’
/home/skpro19/catkin_ws/src/my_global_planner/src/global_planner.cpp:94:33: required from here
/opt/ros/melodic/include/ros/message_traits.h:142:14: error: ‘const class std::vector<geometry_msgs::PoseStamped_<std::allocator<void> > >’ has no member named ‘__getDataType’
return m.__getDataType().c_str();
~~^~~~~~~~~~~~~
make[2]: *** [CMakeFiles/global_planner_lib.dir/src/global_planner.cpp.o] Error 1
make[1]: *** [CMakeFiles/global_planner_lib.dir/all] Error 2
make: *** [all] Error 2
cd /home/skpro19/catkin_ws/build/my_global_planner; catkin build --get-env my_global_planner | catkin env -si /usr/bin/make --jobserver-fds=6,7 -j; cd -
global_planner.h
#include <ros/ros.h>
#include <costmap_2d/costmap_2d_ros.h>
#include <costmap_2d/costmap_2d.h>
#include <nav_core/base_global_planner.h>
#include <geometry_msgs/PoseStamped.h>
#include <angles/angles.h>
#include <base_local_planner/world_model.h>
#include <base_local_planner/costmap_model.h>
#include <map>
#include<nav_msgs/Path.h>
#ifndef GLOBAL_PLANNER_CPP
#define GLOBAL_PLANNER_CPP
namespace global_planner {
class GlobalPlanner : public nav_core::BaseGlobalPlanner {
struct Point {
__uint32_t x, y;
bool operator==(const Point &p1 ) { return ((p1.x == this->x) && (p1.y == this->y)); }
bool operator<(const Point &p1 ) const{ return (p1.x < this->x) ; }
};
struct Cell {
Point point;
__uint32_t cost_till_now;
};
struct compare_cost{
bool operator() (Cell &p1, Cell &p2)
{
return p1.cost_till_now < p2.cost_till_now;
}
};
public:
GlobalPlanner();
GlobalPlanner(std::string name, costmap_2d::Costmap2DROS* costmap_ros);
void initialize(std::string name, costmap_2d::Costmap2DROS* costmap_ros);
bool makePlan(const geometry_msgs::PoseStamped& start,
const geometry_msgs::PoseStamped& goal,
std::vector<geometry_msgs::PoseStamped>& plan
);
bool makePlanOne(const geometry_msgs::PoseStamped& start, const geometry_msgs::PoseStamped& goal, std::vector<geometry_msgs::PoseStamped>& plan );
bool makePlanTwo(const geometry_msgs::PoseStamped& start, const ...