Bidirectional rosserial communication

asked 2018-05-04 13:20:34 -0500

blasrobot gravatar image

updated 2018-05-04 13:23:46 -0500

Hello everyone,

I am having some trouble regarding a program that connects a RPi3 with ROS and a UNO board. The idea is that the node in RPi advertises on a certain topic that UNO's node is suscribed to. Also, the other way around is meant with another topic, in which the UNO advertises. I have some trouble when defining the publisher on the UNO's code, I don't know if i should put something like:

a)

ros::Publisher pub_boton("topic", &message);

b)

ros::Publisher pub_boton = nh.advertise <std_msgs::Int8> ("topic", 1000);

I saw a) in many examples, but I don't find it in any official documentation.

Another problem I have is that, when I try to publish a std_msgs/Int8, by doing:

 #include "std_msgs/Int8.h"
 std_msgs::Int8 message;
 int b=1; message.data=b;
 ros::Publisher pub_boton("topic",&message);

I get the following error:

Nodo_rosserial_ultrasonicov2.ino:12:1: error: ‘message’ does not name a type

I don't get it, as I do specify the type of the message.

Thank you in advance.

edit retag flag offensive close merge delete

Comments

Have u checked rosserial_arduino. Make sure you have included

#include <ros.h>
BhanuKiran.Chaluvadi gravatar image BhanuKiran.Chaluvadi  ( 2018-05-05 03:32:24 -0500 )edit
1

It would be useful to know which line is line 12 of your source code.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-05-05 05:48:17 -0500 )edit