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

Problem with using subscriber from initialize method.

asked 2022-10-20 09:17:42 -0600

Edvard gravatar image

updated 2022-10-20 09:43:26 -0600

ravijoshi gravatar image

Hi. Sorry for all mistakes, English is not my native language. I am porting my project from Noetic to Foxy and I have flowing code:

bool STMRobotHW::initialize(ros::NodeHandle nh)
{
   ...
   hw_feedback_sub = nh.subscribe("hw_feedback", 1000, &STMRobotHW::feedbackCallback, this);
}

void STMRobotHW::feedbackCallback(const minicar_control::Feedback &fb_msg)
{
     ....
}

I have hard time understanding how this subscribe should look in Foxy if there are no obj parameter parameter for create_subscribe in ROS 2, or at least I couldn't find any. Appreciate any help.

edit retag flag offensive close merge delete

Comments

Please look at Writing a simple publisher and subscriber (C++) tutorial suggested by @thejeeb. Furthermore, you can look at ros2/examples and ros2/demos

ravijoshi gravatar image ravijoshi  ( 2022-10-20 09:45:48 -0600 )edit

Thank you for help

Edvard gravatar image Edvard  ( 2022-10-21 00:13:41 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-20 09:41:42 -0600

thejeeb gravatar image

You need a Node to create a subscriber. See this tutorial for an example.

edit flag offensive delete link more

Comments

Thank you, for your help. I'll try it

Edvard gravatar image Edvard  ( 2022-10-21 00:13:20 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2022-10-20 09:17:42 -0600

Seen: 68 times

Last updated: Oct 20 '22