ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

compile error related to <nav_msgs::Path> publisher

asked 2021-06-10 14:46:56 -0500

updated 2021-06-11 04:29:07 -0500

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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2021-06-12 09:16:45 -0500

miura gravatar image

It seems that you are issuing the wrong target. Perhaps it is global_plan_pub.publish(my_path); instead of global_plan_pub.publish(plan);.

edit flag offensive delete link more

Comments

1

@miura Thanks. That solved the problem.

skpro19 gravatar image skpro19  ( 2021-06-12 12:06:00 -0500 )edit

I'm glad it was resolved.

miura gravatar image miura  ( 2021-06-12 20:15:08 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-06-10 14:46:56 -0500

Seen: 463 times

Last updated: Jun 12 '21