Realtime autonomous car for and
ROS2 cross compiling
Jim Huang – National Cheng Kung University
Colin Cheng – Providence University
Johnson Chang - National Chiao Tung University
Ahua Wang - National Cheng Kung University
Edison Chen - National Cheng Kung University
Jason Haung - National Cheng Kung University
duckiebot (From MIT)
Lane following
Original image
Homography transform
Line detection
w
Lane control procedure
Do color thresholding to extract the desired color area
Do canny edge detection
Do hough transform and get the segments
Apply Lane filter to get the best lane estimation
Do PID control
Original kernel
Latency
min: 4 (μs)
Avg: 206 (μs)
Max: 159001 (μs)
Xenomai patched kernel
Latency:
Min: 2 (μs)
Avg: 11 (μs)
Max: 36 (μs)
ROS2 cross compiling
Tested environment
Target Machine: Raspberry pi 3
Host operating system: Ubuntu 16.04
Target operating system: Ubuntu Mate 16.04
Cross compiler: Linaro GCC 5.3
CMake
Cmake is compatible to do cross compile by setting
some variables like:
CMAKE_SYSTEM_NAME
CMAKE_C_COMPILER
CMAKE_CXX_COMPILER
CMAKE_SYSROOT
Please check:
http://www.vtk.org/Wiki/CMake_Cross_Compiling
CMake
Please check:
https://github.com/ncku-ros2-research/cross-
compile-
ros2/blob/master/ros2_ws/rostoolchain.cmake
ROS2 for ARM machine
ROS2 alpha7+ require compiler able to compile
C++11 program
And C++11 is only fully support on ARMv6+
machine
Root file system
The symlink in rootfs directory will broken
after copied from target machine because it
used to point to an absolute path like:
“/usr/lib/libxxx.so” but it is now locate to some
path like “~/workspace/rootfs/usr/lib/libxxx.so”
This is quite tricky but can be fixed by writing a
shell script
Root file system
Please check:
https://github.com/ncku-ros2-research/cross-
compile-
ros2/blob/master/tools/fixQualifiedLibraryPath
s
Toolchain
Linaro GCC 5.3 (Newest release version right
now)
Not recommand to build your own cross
compiler (e.g: crosstool-ng)
Pkg-config wrapper
Few pkg-config’s environment variables need
to be set for cross compiling purpose
PKG_CONFIG_LIBDIR
PKG_CONFIG_SYSROOT_DIR
Pkg-config wrapper
#!/bin/bash
#pkg-config wrapper
ROOTFS=$(realpath ../rootfs)
ROS2_WS_PATH=$(realpath ../ros2_ws)
export PKG_CONFIG_DIR=
export PKG_CONFIG_LIBDIR=${ROS2_WS_PATH}/install/lib/pkgconfig:${ROOTFS}/usr/lib/arm-
linux-gnueabihf/pkgconfig:${ROOTFS}/opt/ros/kinetic/lib/pkgconfig:${ROOTFS}/usr/lib/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=${ROOTFS}
pkg-config $@
Multi-Arch
Debian/Ubuntu use multi-arch design and
store the libraries in directories like:
/usr/lib/arm-none-eabihf
In order to let compiler search these
directories, the output message of command
“arm-none-eabihf-gcc --print-multiarch” must
be set
Native build as alternate
Solution (add swap memory)
1) $ sudo apt install dphys-swapfile
2) $ vi /etc/dphys-swapfile
add CONF_SWAPSIZE=4096
3) $ /etc/init.d/dphys-swapfile stop
4) $ /etc/init.d/dphys-swapfile start
Use “htop” to check for new swap memory
Links
Duckietown
http://duckietown.mit.edu/
Github:
https://github.com/ncku-ros2-research/cross-compile-ro
s2
Slide
https://www.slideshare.net/secret/BjQIsw6iifmzRa

Realtime autonomous car for studying and ROS2 cross compiling