uwreact / frc_control

ROS metapackage enabling FRC teams to use ROS on their robots
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

Fix cross-compilation of roscore #66

Open matthew-reynolds opened 5 years ago

matthew-reynolds commented 5 years ago

🐛 Bug Report

Currently, the following extra steps have to be taken to cross-compile the roscore: 1) Manually delete the gazebo_ros source directory 2) Change #include_next to #include in ~/frc2019/roborio/arm-frc2019-linux-gnueabi/usr/include/c++/6.3.0/cstdlib:75 3) Change #include_next to #include in ~/frc2019/roborio/arm-frc2019-linux-gnueabi/usr/include/c++/6.3.0/cmath:45

How to fix: 1) ackerman_steering_controller (Part of ros_controllers) has gazebo_ros listed as a dependency since it is used for tests. We do not want anything to do with Gazebo when we cross compile. Can be fixed by adding --exclude gazebo_ros to the rosinstall_generator command. 2) Fix cmake toolchain. Need to look into this further. I believe the correct behaviour would be to include ~/frc2019/roborio/arm-frc2019-linux-gnueabi/usr/include/math.h. I'm not sure what file is being included right now when I switch from #include_next to #include`. 3) As above.

To elaborate on 2 and 3, here is my (limited) understanding. The following applies to both cstdlib and cmath, it's just quicker to type math than stdlib :)

GNU ISO C++ defines the following two files:

Additionally, GNU ISO C defines the following file: [...]/usr/include/math.h

C++ cmath contains the following, outside of include guards:

#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#include_next <math.h>
#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS

Similarly, C++ math.h includes the following, outside of include guards:

#if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS
# include_next <math.h>
#else

Clearly, the intent here is to include the C math.h. I do not know why #include_next in cmath fails but #include_next in C++ math.h seems to succeed. But my understanding is that the C math.h should be included. Sounds like a configuration issue with the cmake toolchain.

matthew-reynolds commented 5 years ago

It appears the #include_next issues are a result of diff_drive_controller's unusual CMakeLists.txt. Fix proposed in https://github.com/ros-controls/ros_controllers/pull/425.

matthew-reynolds commented 5 years ago
  1. is fixed by uwreact/frc_control#72
  2. and 3. are fixed by ros-controls/ros_controllers#425

Leaving this issue open until a new release of ros_controllers is released containing the fix to 2. and 3.