how can I add a main method in local_planner_node.cpp ?
Why would you want to do that? Local_planner_node.cpp already has a main, it is called Local_planner_node_main.cpp therefore you cannot add a second main function and there is absolutely no need for it.
I need to add a subscriber in the local_planner_node … however I’m not able to do that at all so I was thinking of adding new main method in the local_planner_node to help me
@baumanta would you help me in adding a subscriber in the local_planner_node ?
@lioneleeedadad I have already pointed you to the appropriate ROS tutorials on how to add subscribers / publishers. Adding a subscriber does not need / should not be done by adding a main function in to the local_planner node.
Have you tried creating your own custom node in c++ to add a subscriber? Doing this will enable you to better understand how to add this to local_planner
This question is also a duplicate with Local_planner_node subscribing
I created my own node and modified the CMakelist and the package.xml . However when I try to add this subscriber in the local_planner_node I’m unable . So would you guide me more ? @Jaeyoung-Lim
@lioneleeedadad just look at the code a bit more closely. There are already subscribers in there, you need to define yours exactly the same way. Take
pose_sub_ as an example:
it is defined in local_planner_node.h (line 248):
it is initialized in local_planner_node.cpp (line 39):
pose_sub_ = nh_.subscribe<const geometry_msgs::PoseStamped&>( "/mavros/local_position/pose", 1, &LocalPlannerNode::positionCallback, this);
And then it calls the corresponding callback function
So you need to do exactly those three steps for your subscriber: define it, initialize it and then write a callback.