0
$\begingroup$

Rosanswers logo

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!


Originally posted by RicHykkie on ROS Answers with karma: 13 on 2018-05-24

Post score: 0


Original comments

Comment by simbha on 2018-05-24:
is the blink_one msg is written by use? because by default there is no such msg

Comment by RicHykkie on 2018-05-24:
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.

Comment by simbha on 2018-05-24:
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.

Comment by RicHykkie on 2018-05-24:
It should be an int16 but when I type this, I get Type: blink_one/Number

Comment by simbha on 2018-05-24:
Then why are you including <blink_one/Number.h. It should be #include std_msgs/Int16.h

Comment by RicHykkie on 2018-05-24:
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... }.

Comment by simbha on 2018-05-24:
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

Comment by RicHykkie on 2018-05-24:
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.

Comment by simbha on 2018-05-24:
are the examples of ros_lib are compiling successfully?

Comment by RicHykkie on 2018-05-24:
Yes they do.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by PeteBlackerThe3rd with karma: 9529 on 2018-05-24

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by simbha on 2018-05-24:
@RIcHykkie refer this link to generate msgs for Arduino

Comment by RicHykkie on 2018-05-24:
@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.

Comment by RicHykkie on 2018-05-24:
@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.

Comment by RicHykkie on 2018-05-24:
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.

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by oligor77 with karma: 11 on 2019-04-05

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by root_locus on 2019-09-01:
Thank you!! :D

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.