Robotics StackExchange | Archived questions

Rosserial problem with std_msgs on Arduino

Hello,

I am trying to connect ROS with Arduino using a simple subscriber and publisher program to blink a LED on an Arduino but I am getting an error when including the stdmsgs/Int8.h library on arduino. It says that there is no such file or directory but I have already followed all the steps on the ROS tutorial and the library is already in my roslib inside arduino.

I have also tried including the Rosserial library from the arduino IDE but I still get the same error.

Does anyone know how to fix this or if I am doing something wrong?

Pablo.

Arduino code:

include

include

ros::NodeHandle nh;

void messageCb(const stdmsgs::Int8& togglemsg){ if(toggle_msg.data==4){ digitalWrite(13, HIGH-digitalRead(13)); } }

ros::Subscriber sub("chatter", messageCb);

void setup() { pinMode(13, OUTPUT); nh.intNode() nh.subscribe(sub);

}

void loop() { nh.spinOnce(); delay(500);

}

Arduino error:

est:2:10: fatal error: stgmsgs/Int8.h: No such file or directory #include <stgmsgs/Int8.h> ^~~~~~~~~~~~~~~~~ compilation terminated. exit status 1 stg_msgs/Int8.h: No such file or directory

Asked by PabloCordoba on 2022-03-09 07:44:44 UTC

Comments

Can you add the code as preformatted text? this is hard to read. It's also missing the # before include. And why do you have ' =""' ' at the end of your include? And did you look at the tutorial: http://wiki.ros.org/rosserial_arduino/Tutorials/Blink ?

Asked by crnewton on 2022-03-10 09:27:50 UTC

Answers

@cmnewton Yeah sorry, the format got a bit weird when I uploaded it, surprisingly I tried running the blink example from ros_lib instead of my own code and it worked so now it's fine. Thanks for the help anyway!

Asked by PabloCordoba on 2022-03-10 12:59:55 UTC

Comments