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

Rosserial problem with std_msgs on Arduino

asked 2022-03-09 06:44:44 -0500

PabloCordoba gravatar image

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 std_msgs/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 ros_lib 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 <ros.h>

include <stg_msgs int8.h="">

ros::NodeHandle nh;

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

ros::Subscriber<std_msgs::int8> 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: stg_msgs/Int8.h: No such file or directory #include <stg_msgs int8.h=""> ^~~~~~~~~~~~~~~~~ compilation terminated. exit status 1 stg_msgs/Int8.h: No such file or directory

edit retag flag offensive close merge delete

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... ?

crnewton gravatar image crnewton  ( 2022-03-10 08:27:50 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-03-10 11:59:55 -0500

PabloCordoba gravatar image

@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!

edit flag offensive delete link more

Question Tools

Stats

Asked: 2022-03-09 06:44:44 -0500

Seen: 320 times

Last updated: Mar 10 '22