0
$\begingroup$

Rosanswers logo

Hi, I am using Ubuntu 20.04 and ROS Noetic. I followed the rosserial tutorial arduino setup page but I cannot compile the ros_lib HelloWorld example in Arduino. It gives me the following error. I am not able to resolve it and I would like to ask for your help! Thanks a lot!

    In file included from /home/kk/Arduino/libraries/ros_lib/std_msgs/Time.h:7:0,
                 from /home/kk/Arduino/libraries/ros_lib/ros/node_handle.h:40,
                 from /home/kk/Arduino/libraries/ros_lib/ros.h:38,
                 from /home/kk/Arduino/libraries/ros_lib/examples/HelloWorld/HelloWorld.pde:6:
/home/kk/Arduino/libraries/ros_lib/ros/msg.h:40:10: fatal error: cstring: No such file or directory
 #include <cstring>
          ^~~~~~~~~
compilation terminated.

exit status 1
Error compiling for board Arduino Leonardo.

Originally posted by ytosclee on ROS Answers with karma: 97 on 2020-09-20

Post score: 6


Original comments

Comment by NEngelhard on 2020-09-28:
https://github.com/ros-drivers/rosserial/issues/518

$\endgroup$

6 Answers 6

0
$\begingroup$

Rosanswers logo

Hey, I ran into the same issue and after hours of searching google, I found the following workaround:

First you have to delete the ros_lib folder that was created when you initially ran rosrun rosserial_arduino make_libraries.py . It should be located in /home/Arduino/libraries or wherever you installed arduino IDE.

Then open the Arduino IDE, in the menu bar go to Tools -> Manage Libraries and search for "rosserial"

You should see Rosserial Arduino Library by Michael Furguson. Install it, I installed 0.7.9

Now you can try to compile your HellowWorld program again and it should work.

Not sure why this worked but hopefully it works for you too.


Originally posted by groscore with karma: 76 on 2020-09-27

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by ytosclee on 2020-09-30:
Thanks, it solves my problem.

Comment by PeterMilani on 2021-01-23:
I found that I had to use 0.7.9 as listed above. version 0.9.4 had the same issue.

Comment by traemand on 2021-06-10:
I got this error from installing the rosserial library through the Arduino IDE library manager. but if i instead ran the python script as the comment explains above (or, taken from this link: http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup), everything works fine.

$\endgroup$
0
$\begingroup$

Rosanswers logo

Hi ytoclee

Got same issue here when installing arduino libraries using:

rosrun rosserial_arduino make_libraries.py

Just delete the folder 'ros_lib' inside arduino libraries. Then, inside Arduino IDE, Sketch/Include Library/Manage Libraries... search by "rosserial" and install: Rosserial Arduino Library by Michael Ferguson

Using version 0.7.9, worked with fresh new Arduino Uno and Arduino Mega. Also able to compile for Seeeduino Zero (integrated on Odyssey X86J4105)

Let me know if this solves your problem ;)


Originally posted by Was5K with karma: 11 on 2020-09-28

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by ytosclee on 2020-09-30:
Thanks, it solves my problem.

$\endgroup$
0
$\begingroup$

Rosanswers logo

I faced the same problem and solved it by changing the "msg.h" in ~/Arduino/libraries/ros_lib/ros destination generated by rosrun rosserial_arduino make_libraries.py . with "msg.h" file from "rosserial lib" (0.7.8 version) which was downloaded from the Library manager of Arduino IDE (directory of this file in downloaded library: ~/Rosserial_Arduino_Library/src/ros/).

If you don't have any custom messages you want to use in your Arduino IDE you can download the full "rosserial" library from the Library Manager.


Originally posted by Alexander Tadiashvili with karma: 11 on 2020-11-06

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Arnolvalencia1 on 2021-03-11:
thanks, follow your steps and solve the problem.

$\endgroup$
0
$\begingroup$

Rosanswers logo

Step 1 : https://www.arduino.cc/en/software/

Extract and copy in home and run ./arduino

vahid@vahid:~/arduino-1.8.13$ ./arduino

Step 2 :

sudo apt-get install ros-indigo-rosserial-arduino sudo apt-get install ros-indigo-rosserial

Step 3 :

cd /src git clone https://github.com/ros-drivers/rosserial.git cd catkin_make catkin_make install

Step 4 :

Generate ROS library

Open two terminal : Terminal 1 : $ Run roscore

Terminal 2 : vahid@vahid:~$ cd arduino-1.8.13/ vahid@vahid:~/arduino-1.8.13$ cd libraries/ vahid@vahid:~/arduino-1.8.13/libraries$ rm -rf ros_lib vahid@vahid:~/arduino-1.8.13/libraries$ rosrun rosserial_arduino make_libraries.py .

Then open the Arduino IDE, in the menu bar go to Tools -> Manage Libraries and search for "rosserial"

You should see Rosserial Arduino Library by Michael Furguson and install 0.7.9

Step 5 : How to run :

vahid@vahid:~/arduino-1.8.13$ ./arduino

Go to example find ros_lib and based on your application run example codes.

For example open HelloWorld and compile after that open one terminal

vahid@vahid:~/catkin_ws$ rosrun rosserial_python serial_node.py /dev/ttyUSB0

Open other terminal and type rostopic list. You can see chatter topic

vahid@vahid:~/catkin_ws$ rostopic list /chatter


Originally posted by VAHID with karma: 11 on 2020-12-27

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

Just edit the msg.h file located Arduino/libraries/Rosserial_Arduino_Library/src/ros in line 40 write #include <string.h> and in line 68 and 182 remove std:: before memcpy

Hope this will work for you


Originally posted by Saad_Ahmed with karma: 41 on 2021-05-29

This answer was NOT ACCEPTED on the original site

Post score: 4


Original comments

Comment by Raj_28 on 2021-09-03:
Hey, this works but why this changes? can you explain

$\endgroup$
0
$\begingroup$

Rosanswers logo

I didn't find any ros_lib folder as mentioned in above answers. But fixed it. the problem is in your ros/msg.h file #include <cstring> no longer works, replace it with #include <string.h> and the std::memcpy() function is not a part of std anymore, so change it to memcpy().

Summary: (Changes) File - ros/msg.h

  1. Change -> #include <cstring> to #include <string.h>
  2. Change -> std::memcpy() to memcpy()

And it will work!


Originally posted by Yash Sahu with karma: 71 on 2021-07-19

This answer was NOT ACCEPTED on the original site

Post score: 6


Original comments

Comment by Marcus Barnet on 2022-01-26:
it worked perfect for me!

$\endgroup$

Your Answer

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