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

How to use custom message arduino [SOLVED]

asked 2016-03-18 12:45:58 -0500

thepirate16 gravatar image

updated 2016-03-19 10:58:01 -0500

Hi guys,

I've been doing some novice work in arduino and ros and i would like to use a custom message already created as the official tutorial says. The custom package is in:


and under its msg folder, we have the message file: Num.msg

This message works perfectly in a normal ROS node (not arduino) created by a C++ code. I can modify without issues all its fields and get the message published efficiently. Everything in the CMakeLists.txt and in the package.xml has been edited as the ROS tutorial suggests.

The problem is: how can my arduino use that custom message??

In order to make the arduino have it as a library, i've used:

rosrun rosserial_arduino ~/sketchbook/libraries/ros_lib

Seems to have worked well despite that some packages like rtabmap, etc haven't been made. Anyway this isn't important.

Then, I open the Arduino IDE, open the HelloWorld example (just for testing the new message), and reference the message as a normal library in the very first line of the code:

#include <pkg_prova1/Num.h>

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle  nh;
......(all the stuff that follows)

Unfortunately, it gives me the next compiling error:

HelloWorld.pde:6:28: fatal error: pkg_prova1/Num.h: No such file or directory
compilation terminated.

I guess either the new library that i have created is not well referenced so the IDE can find it or the make_libraries command is not what i should use.

Any ideas to do it? I would appreciate a detailed answer as my ROS knowledge is still some fuzzy.

Correct me if i have a wrong understanding of anything.

Thanks in advance!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-03-19 10:56:30 -0500

thepirate16 gravatar image


I got it working removing ROS completely from my computer and re-installing it.

Seems like there was a mess of files and folders in my catkin and in opt, possibly from several trials and errors in a first contact with ROS,

Now it has compiled but i have a different problem, the rosserial connection doesn't work. I guess that is because of the arduino code written, as the rosserial works when using the HelloWorld example.

Thanks saleem for your answer.

I open another question with the actual state (where I solved the problem!)

edit flag offensive delete link more

answered 2016-03-18 12:52:54 -0500

saleem gravatar image

updated 2016-03-18 12:56:41 -0500

I think you are making the libraries inside the libraries/ros_lib instead do this,

rosrun rosserial_arduino ~/sketchbook/libraries/

or try removing the existing ros_lib in libraries and then type the above command.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-03-18 12:45:58 -0500

Seen: 3,341 times

Last updated: Mar 19 '16