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

How to create subscriber in a publisher

asked 2013-10-01 08:59:42 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I want to create a node that will publish a topic but before that subscribes to listen to another topic. I want to rostopic pub /my_topic_cg std_gs/String "GO" ,and when the listener gets the "GO" published another topic which would print "The race has started" for example. How can i manage this? ive looked into it in the tutorial but could not get a answer. Also can i publish a number instead of a string, how can I do it in cpp?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-10-02 03:46:26 -0600

tfoote gravatar image

Yes you can do that. I suggest you go through all the ROS Tutorials. (This one will help you, but you should go through all of them before as they are cumulative.)

edit flag offensive delete link more
0

answered 2013-10-01 09:06:36 -0600

davinci gravatar image

You should incorporate the subscriber code before the publisher code. If you roscd to std_msgs/msg you can find all the standard data types.

edit flag offensive delete link more

Comments

@davinci thanks , but how to I accomplish that? to incorporate the subscriber code before the publisher code?

ctguell gravatar image ctguell  ( 2013-10-01 09:13:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-10-01 08:59:42 -0600

Seen: 267 times

Last updated: Oct 02 '13