ROS Serial Advanced Config tutorial fails to compile - solution

asked 2019-04-15 13:59:00 -0600

chrisalbertson gravatar image

updated 2019-04-15 14:36:18 -0600

gvdhoorn gravatar image

The tutorial example fails to compile. (see my proposed "fix" below)

I use the current Arduino IDE and the board is STM32 using the "new" STM32 core from ST Micro. But the same failure happes with the "Uno". It is not a compiler issue but a build system issue. (See my proposed solution below)

This tutorial fails

The example is designed to compile in the Arduino environment. This environment is unusual in how it figures out where to look for #include *.h files. The IDE scans the subdirectories in ../Arduino/libraries/... and in this case, gets it wrong.

If you follow the tutorial instructions and create your own local copy of ros.h and use "" and not <> then, of course, your local copy of ros.h is found as it should be. But because you own local copy is found the include path now does not include the directory where the systems ros.h lives and all further #includes from there fail.

If you follow the above linked tutorial this is the error:

ros.h:4:29: error: ros/node_handle.h: No such file or directory
ros.h:4:29: error: ros/node_handle.h:
No such file or directory

Certainly ros/node_handle.h exists but Arduino IDE fails to look in ..../Arduino/libraries/ros_lib/ros for it

Here is the solution:

1) Place a one line file called "ros_lib.h" that contains only a single comment "// this file is empty" in .../Arduino/libraries/ros_lib

2) In the main sketch, the first non-comment line should be "#include <ros_lib.h>"

The above will trick the Arduino IDE build system into placing ../Arduino/libraries/ros_lib on the include path.

Would someone please confirm the problem and the solution. After confirmation the tutorial needs to be updated.

edit retag flag offensive close merge delete


I've never worked with the STM32, but I have done a litle bit of work with a few Arduinos and ROS and I have to say that I've never encountered this issue. Everything just seemed to work right "out of the box" when following the tutorials. Perhaps there's something that was missed during installation?

jayess gravatar image jayess  ( 2019-04-15 15:57:29 -0600 )edit

Yes, but have you tried the exact tutorial in the link? Few people would have the need to use a local "ros.h" as the tutorial has you do. You can use ROS Serial for years and never trigger this issue

Does the linked tutorial work for you?

The version of the IDE may matter. The tororial may work with older IDE version. I'm using MacOS X and that might matter.

Hre is the cause. In /Arduino/Libraries you potentially have many libraries. How does the IDE know which of them to place in the compiler's search path? It uses a program to scan the .ino file and then hunts the libraries. So if it sees ros.h and finds it in ros_lib/ then it places ros_lib in the path But if ros.h is found in the local sketch then this does not happen.

That said, there ...(more)

chrisalbertson gravatar image chrisalbertson  ( 2019-04-15 17:53:11 -0600 )edit

Looking at it again, it's a different tutorial than I originally thought. I wish that I could test it out for you, but unfortunately I don't have any Arduinos or STM32s handy.

jayess gravatar image jayess  ( 2019-04-15 18:26:34 -0600 )edit