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

subscribe and publish in the same class

asked 2011-08-02 06:40:00 -0600

patrick_hammer gravatar image

updated 2014-01-28 17:10:08 -0600

ngrennan gravatar image

I am trying to publish and subscribe to topics from within the same class but cannot figure out how to set up the subscriber callback. Can you explain what to do on line 10 for me? Thanks! http://pastebin.com/E2qLkcfX

<iframe src="http://pastebin.com/embed_iframe.php?i=E2qLkcfX" style="border:none;width:100%"></iframe>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-08-02 06:53:48 -0600

arebgun gravatar image

This page describing different callback types (with example usage of each) might help.

edit flag offensive delete link more

Comments

I was able to call the class method from within main but I would still like to figure out how to subscribe from within the class: ros::Subscriber sub = nh.subscribe("my_topic", 1, &Foo::callback, &foo_object);
patrick_hammer gravatar image patrick_hammer  ( 2011-08-02 07:39:08 -0600 )edit
sub = n.subscribe("/robot_pose_ekf/odom_combined", 1000, &Spinner::spin_cb, this); ?
arebgun gravatar image arebgun  ( 2011-08-02 07:48:37 -0600 )edit

Question Tools

Stats

Asked: 2011-08-02 06:40:00 -0600

Seen: 2,491 times

Last updated: Aug 02 '11