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

Generate header file from custom message for Arduino

asked 2023-03-22 12:17:33 -0500

kozinovsky gravatar image

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: ros_custom_msg

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:\fakepathmsg_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
  • According to the ROS guide, all I need to do is to modify CMakeList.txt and package.xml which I did, attached the screenshots of changes for these two files inside beginner_tutorials

for CMakeList.txt

C:\fakepath\cmake_min_requred.jpg

C:\fakepath\cmake_find_packages.jpg

and for package.xml

C:\fakepath\package_message_generation.jpg

C:\fakepath\cmake_add_msg_files.jpg

  • after these changes to CMakeList.txt and package.xml I go to the ~/catkin_ws folder and apply catkin_make command

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

edit retag flag offensive close merge delete

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.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-04-29 13:36:11 -0500 )edit

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

Mike Scheutzow gravatar image Mike Scheutzow  ( 2023-04-29 13:39:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-04-28 06:39:50 -0500

ageraf gravatar image

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/Cre... (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!?

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2023-03-22 12:17:33 -0500

Seen: 282 times

Last updated: Apr 28 '23