Ask Your Question

How to publish a specific message to ROS?

asked 2012-06-14 00:55:01 -0500

Engineer gravatar image

updated 2014-04-20 14:09:19 -0500

ngrennan gravatar image


I am using an arduino UNO to communicate with ROS and I am trying to write a program to create a publisher and a subscriber node. I am not that familiar with ROS but I was wondering if there is a way to tell ROS exactly what to do. I mean that ok I publish a message to ROS but how can ROS know what to do? Lets say for example that I have an input to my arduino coming from a PIC microcontroller and what ROS needs to do is to tell the robot to go to a specific location. Can anyone give me a hint on how to do that?

Thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-06-14 01:56:15 -0500

cagatay gravatar image

updated 2012-06-14 02:16:26 -0500

Lorenz gravatar image

you can build a specific msg system regarding to your needs in ROS. one node may receive a message from microcontroller via serial port(etc..) then publish a topic and an other node can subscribe to that do some other things. You can design your own messaging system. You can add a msg directory in your ros package then create your msg system i.e. EncoderValues.msg in msg directory. EncoderValues.msg file may contain two variables such as int64 encoderLeft and int64 encoderRight. then you can include this msg system to your ros source as a header file similar to this

#include "your_package_name/EncoderValues.h"

after that you can create a object your_package_name::EncoderValues enc;

whenever you receive the encoder values you can publish the enc msg as a topic.

I quickly and simply summarized what I know, you refer to ros wiki tutorials for more detailed tasks and msg systems. I recommend you to begin with this simplest one

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-06-14 00:55:01 -0500

Seen: 318 times

Last updated: Jun 14 '12