realtime autonomous car for studying and ros2 cross compiling

22
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

Upload: -

Post on 12-Feb-2017

331 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: Realtime autonomous car for studying and ROS2 cross compiling

Realtime autonomous car for and ROS2 cross compiling

Jim Huang – National Cheng Kung UniversityColin Cheng – Providence University

Johnson Chang - National Chiao Tung UniversityAhua Wang - National Cheng Kung UniversityEdison Chen - National Cheng Kung UniversityJason Haung - National Cheng Kung University

Page 2: Realtime autonomous car for studying and ROS2 cross compiling

duckiebot (From MIT)

Page 3: Realtime autonomous car for studying and ROS2 cross compiling

Lane following

Page 4: Realtime autonomous car for studying and ROS2 cross compiling

Original image

Page 5: Realtime autonomous car for studying and ROS2 cross compiling

Homography transform

Page 6: Realtime autonomous car for studying and ROS2 cross compiling

Line detection

w

Page 7: Realtime autonomous car for studying and ROS2 cross compiling

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

Page 8: Realtime autonomous car for studying and ROS2 cross compiling

Original kernel

Latencymin: 4 (μs)

Avg: 206 (μs) Max: 159001 (μs)

Page 9: Realtime autonomous car for studying and ROS2 cross compiling

Xenomai patched kernel

Latency:Min: 2 (μs)Avg: 11 (μs)Max: 36 (μs)

Page 10: Realtime autonomous car for studying and ROS2 cross compiling

ROS2 cross compiling

Page 11: Realtime autonomous car for studying and ROS2 cross compiling

Tested environment

Target Machine: Raspberry pi 3

Host operating system: Ubuntu 16.04Target operating system: Ubuntu Mate 16.04Cross compiler: Linaro GCC 5.3

Page 12: Realtime autonomous car for studying and ROS2 cross compiling

CMakeCmake is compatible to do cross compile by setting some variables like:

CMAKE_SYSTEM_NAMECMAKE_C_COMPILERCMAKE_CXX_COMPILERCMAKE_SYSROOT

Please check:http://www.vtk.org/Wiki/CMake_Cross_Compiling

Page 13: Realtime autonomous car for studying and ROS2 cross compiling

CMake

Please check:

https://github.com/ncku-ros2-research/cross-compile-ros2/blob/master/ros2_ws/rostoolchain.cmake

Page 14: Realtime autonomous car for studying and ROS2 cross compiling

ROS2 for ARM machine

ROS2 alpha7+ require compiler able to compile C++11 program

And C++11 is only fully support on ARMv6+ machine

Page 15: Realtime autonomous car for studying and ROS2 cross compiling

Root file systemThe 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

Page 16: Realtime autonomous car for studying and ROS2 cross compiling

Root file system

Please check:

https://github.com/ncku-ros2-research/cross-compile-ros2/blob/master/tools/fixQualifiedLibraryPaths

Page 17: Realtime autonomous car for studying and ROS2 cross compiling

Toolchain

Linaro GCC 5.3 (Newest release version right now)

Not recommand to build your own cross compiler (e.g: crosstool-ng)

Page 18: Realtime autonomous car for studying and ROS2 cross compiling

Pkg-config wrapper

Few pkg-config’s environment variables need to be set for cross compiling purpose

PKG_CONFIG_LIBDIRPKG_CONFIG_SYSROOT_DIR

Page 19: Realtime autonomous car for studying and ROS2 cross compiling

Pkg-config wrapper

#!/bin/bash#pkg-config wrapperROOTFS=$(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/pkgconfigexport PKG_CONFIG_SYSROOT_DIR=${ROOTFS}

pkg-config $@

Page 20: Realtime autonomous car for studying and ROS2 cross compiling

Multi-ArchDebian/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

Page 21: Realtime autonomous car for studying and ROS2 cross compiling

Native build as alternateSolution (add swap memory)1) $ sudo apt install dphys-swapfile2) $ vi /etc/dphys-swapfile add CONF_SWAPSIZE=40963) $ /etc/init.d/dphys-swapfile stop4) $ /etc/init.d/dphys-swapfile start

Use “htop” to check for new swap memory

Page 22: Realtime autonomous car for studying and ROS2 cross compiling

LinksDuckietownhttp://duckietown.mit.edu/

Github:https://github.com/ncku-ros2-research/cross-compile-ros2

Slidehttps://www.slideshare.net/secret/BjQIsw6iifmzRa