Robotics StackExchange | Archived questions

Generate header file from custom message for Arduino

Hello everyone! (My configuration: Ubuntu 18.04, ROS1 melodic, x86 intel CPU)

I am struggling with creating a custom message to use in Arduino script later.

My idea was to generate header file (EodImuData.h) and put it into the folder Arduino/libraries/ros_lib/my_folder_with_custom_messages so I can #include std_msgs/EodImuData.h later

I followed the ROS manual: roscustommsg

Basically here is the sequence what I did:

  1. Inside existing ros package, begginer tutorial

  2. I've created msg folder

  3. And added EodImuData.msg file to it. Which looks like that inside the file: C:\fakepath\msg_file.jpg

show it here too:

Header header  
float32 acceleration_x 
float32 acceleration_y  
float32 acceleration_z  
float32 gyro_x 
float32 gyro_y  
float32 gyro_z

for CMakeList.txt

C:\fakepath\cmakeminrequred.jpg

C:\fakepath\cmakefindpackages.jpg

and for package.xml

C:\fakepath\packagemessagegeneration.jpg

C:\fakepath\cmakeaddmsg_files.jpg

After these actions I am expecting that folder catkin_ws/src/devel/include/beginner_tutorial will appear with EodImuData.h file inside, which I can copy to the Arduino/libraries/ros_lib/myfolder and #include it in my arduino script.

But, folder catkin_ws/src/devel/include/beginner_tutorial never has been created, so EodImuData.h file

I've tried another way, but looks like this one isn't correct one, I mean the command:

rosrun rosserial_client make_libraries Arduino/IMU beginner_tutorial

This command, yes, creates the folder Arduino/IMU with all standart libraries (headers files for bunch of common messages), but not a folder beginner_tutorial with header file which based on my custom EodImuData.msg file.

What am I missing/don't understand?

How can I get header file based on my .msg file to use it in Arduino script after?

Unfortunately can't attach CMakeList.txt and package.xml files, only pictures are allowed.

Thank you in advance!

Best, Andrey

Asked by kozinovsky on 2023-03-22 12:17:33 UTC

Comments

Please to not upload or link to screenshots of text. Instead you should copy/paste the text into your description and format it with the 101010 button. It's OK if the description gets long. Please just copy/paste your entire CMakeLists.txt file, so we can easily see if you left anything out.

Asked by Mike Scheutzow on 2023-04-29 13:36:11 UTC

catkin_ws/src/devel/include/beginner_tutorial

This is not the correct path. The correct one is: catkin_ws/devel/include/beginner_tutorial/EodImuData.h

Asked by Mike Scheutzow on 2023-04-29 13:39:30 UTC

Answers

Hi there!

I had the same problem but i use Ubuntu 20.04 and noetic. so I started the whole process from scratch and used these dependencies to generate the package:

catkin_create_pkg biscee_servo_control std_msgs message_generation message_runtime rospy roscpp rosserial_arduino rosserial_msgs

and

cd ~/catkin_ws
catkin_make
. ~/catkin_ws/devel/setup.bash

after that i followed these tutorials: http://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv#Common_step_for_msg_and_srv (maybe the same as you did)

and now I had the package name in my include folder.

After that you can use

rosrun rosserial_client make_libraries path_to_libraries

I hope it helps you!

I am now struggling how to use the generated header in arduino.ide!?

Asked by ageraf on 2023-04-28 06:35:37 UTC

Comments