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

How to exchange data between nodes?

asked 2013-12-16 22:29:16 -0600

Safeer gravatar image

updated 2013-12-17 21:12:43 -0600

tfoote gravatar image

I want to send data from one node to another. For example: One node is publishing data to the topic /mobile_base/commands/velocity and other one is subscribed to /mobile_base/events/bumper. Both the subscriber & publisher are working fine.

What I want to do is to make the robot move backward once the bumpers are pressed. I do not know how to send the event of bumper pressed to the other node.

The solution I thought was of using pipes or sockets or shared memory to exchange data between two nodes.

Is this the right approach? Or does ROS has a builtin method for that?

Thanks in Advance.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-12-16 22:49:25 -0600

David Galdeano gravatar image

Hello, you should create an intermediate node wich subscribe to /mobile_base/events/bumper and publish on /mobile_base/commands/velocity. In this node, create your reactive behaviour.

No need of pipes and sockets, the publisher/subscriber mechanism is develloped to allows the communications.

edit flag offensive delete link more
3

answered 2013-12-16 22:46:50 -0600

dornhege gravatar image

You can just subscribe /mobile_base/events/bumper in the node that publishes velocity directly.

edit flag offensive delete link more

Comments

I have tried this. The problem I faced was that when bumper was pressed, the robot stopped moving i.e. once the subscriber receive the *bumper pressed(signal)* it stopped publishing to *Velocity* topic.

Safeer gravatar image Safeer  ( 2013-12-16 22:55:59 -0600 )edit

If it stopped publishing than that is a bug in your code. However, are you sure that is the cause? The earlier Kobuki firmware did stop the robot on bumper press internally as a "feature".

dornhege gravatar image dornhege  ( 2013-12-17 00:54:45 -0600 )edit
1

I agree, that must be a problem with your code. Just make that the callback that answers to /mobile_base/events/bumper raises a "bumperPressed" flag and check that flag in your main thread to move forward or backward.

IvanV gravatar image IvanV  ( 2013-12-17 22:02:46 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-12-16 22:29:16 -0600

Seen: 2,125 times

Last updated: Dec 16 '13