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

Arduino IDE can't find message header

asked 2018-05-24 03:03:49 -0500

RicHykkie gravatar image

Hey, I'm new to ROS and trying to have a led blink at will with my Arduino from my computer using a message, the future goal being to control several ones from my terminal. I am using ROS lunar and the rosserial_arduino package.

I wrote my publisher, subscriber and message, ran the package from a terminal to another as a test and it worked perfectly. Then I put the subscriber code in a new Arduino sketch and adapted it. However, when I try to compile it, I get the following error:

/home/eric/Arduino/blink_one_ros/blink_one_ros.ino:2:30: fatal error: blink_one/Number.h: No such file or directory
 #include <blink_one/Number.h>
                              ^

My include being as follows:

#include <ros.h>
#include <blink_one/Number.h>

I already looked into this answer and several others, but I am afraid that it would be an error from my package so I want to be sure before re-installing ROS.

I did run the often advised:

rm -rf ros_lib/
rosrun rosserial_arduino make_libraries.py <my_path>

And indeed, I can find my message header in my ros_lib/blink_one . Yet it still does not seem to be recognized.

If anyone knows a solution or has some hints, I'd appreciate it!

Thanks!

edit retag flag offensive close merge delete

Comments

is the blink_one msg is written by use? because by default there is no such msg

simbha gravatar image simbha  ( 2018-05-24 03:52:52 -0500 )edit

I don't quite understand the question, sorry. I made it so that the publisher node running in my PC publishes a message into a topic that will be read by the subscriber node, which will be loaded in the Arduino. The message data is an integer, that I want to input in my terminal.

RicHykkie gravatar image RicHykkie  ( 2018-05-24 05:03:48 -0500 )edit

what is the msg type of your topic? please check using rostopic info /topic name . I just want to know what is <blink_one/Number.h>. please let me know the msg type(std_msgs/Int64 or ?) of topic.

simbha gravatar image simbha  ( 2018-05-24 05:09:36 -0500 )edit

It should be an int16 but when I type this, I get Type: blink_one/Number

RicHykkie gravatar image RicHykkie  ( 2018-05-24 05:25:16 -0500 )edit
1

Then why are you including <blink_one/Number.h. It should be #include std_msgs/Int16.h

simbha gravatar image simbha  ( 2018-05-24 05:27:56 -0500 )edit

Sorry, I slightly modified my previous answer after checking. About the use of the include, it's because I call this function void chatterCallback(const blink_one::Number msg) { code... }.

RicHykkie gravatar image RicHykkie  ( 2018-05-24 05:36:05 -0500 )edit

How you have created blink_one/Number.h. Make sure it is available in Arduino/libraries/ros_lib/blink_one/Number.h. refre this link

simbha gravatar image simbha  ( 2018-05-24 05:46:58 -0500 )edit

I created the header by first creating the .msg file, then adding the required lines in the CMakeLists as shown in the msg and srv tutorials and finally catkin_make. Yes, the header is in the ros_lib/blink_one folder.

RicHykkie gravatar image RicHykkie  ( 2018-05-24 05:52:11 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-05-24 06:07:56 -0500

You cannot compile the same source code for a linux ROS node in the arduino IDE for that platform, they are totally different environments with different libraries. Have you looked at this rosserial tutorial for building a subscriber node on an arduino?

@simbha commented that you're using a custom message type for this and checking that you have built the messages correctly. There is no need for this custom message type by the way there are plenty of standard messages that could serve you just as well and make your build process simpler.

Hope this helps.

edit flag offensive delete link more

Comments

@RicHykkie refer this link to generate msgs for Arduino

simbha gravatar image simbha  ( 2018-05-24 06:17:41 -0500 )edit

@PeteBlackerThe3rd Yeah I used this tutorial to adapt my code for Arduino. The Rosserial Arduino Library does appear in my Examples so I assume this has been built properly.

RicHykkie gravatar image RicHykkie  ( 2018-05-24 20:46:26 -0500 )edit

@simbha Thanks for the link, I tried running rosrun rosserial_client make_library.py ~/sketchbook/libraries blink_one but it doesn't seem to have any effect.

Running rosrun rosserial_arduino make_libraries.py /home/eric/sketchbook/libraries/ blink_onecreates the header but still no compiling.

RicHykkie gravatar image RicHykkie  ( 2018-05-24 20:48:58 -0500 )edit

Thank you for your answers.

For now I will try using standard messages, but for later uses I would like to be able to create my own, if possible.

RicHykkie gravatar image RicHykkie  ( 2018-05-24 20:51:27 -0500 )edit
1

answered 2019-04-05 07:23:29 -0500

oligor77 gravatar image

updated 2019-04-05 07:34:53 -0500

Hello there, i know that post is a little bit old. But i had the same problem and found a workaround. My setup is a raspberry which runs ubuntu. I used the ros distribution. Arduino was installed with the install package from the website, not from the ubuntu repository. I found the the libraries for the arduino compilation are stored in the /usr/share/arduino/libraries folder.

  • user : ubuntu
  • package where the msg is defined : hw_arduino_package
  • message in the msg folder : stepperAction.msg

So as workaround i firsat generate the libraries with the python script into a temp folder :

rosrun rosserial_arduino make_libraries.py /home/ubuntu/ardtemp hw_arduino_package

Than i have to copy the generated package library to the arduino library folder.

sudo cp -R /home/ubuntu/ardtemp/ros_lib/hw_arduino_package /usr/share/arduino/libraries/

After that it can be included in the arduino package source with

#include <hw_arduino_package/stepperAction.h>

I know that is not the best practise, but it works for me. Maybe this would help someone.

edit flag offensive delete link more

Comments

Thank you!! :D

root_locus gravatar image root_locus  ( 2019-09-01 13:56:05 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-05-24 03:03:49 -0500

Seen: 1,085 times

Last updated: Apr 05 '19