Roadmap

Introduction

In Berlin we had a meetup group Autonomous Robots Berlin. Now it is not active, but earlier this group held a competition. The rules were simple:

  1. Every car must make at least 3 loops in a row without human intervention.
  2. Fastest of these loops counts (so you can gradually increase speed on the track;).
  3. There are two paths available with the same starting point: a long loop for lane holding and an obstacle avoidance loop. The obstacle avoidance loop is shorter than just lane holding, but for each cone hit 2 seconds are added to your total score. Each participant is free to choose which loop to take.
  4. The vehicle can leave the track if it comes back and it did not take a shortcut.

The race took place at The Drivery’s Gravity Gym track

Software setup

I was given a DonkeyCar which had only:

  • 1GB RAM RaspberryPi
  • two motors, which recieved only PWM signals
    • throttle
    • steering
  • RaspberryPi camera

It is a very basic setup, because no sensors for obstacle detection, or just for odometry to get some localization.

Robocar uses ROS1 Noetic. For testing and training purposes it can be run across multiple machines, when a car sends camera images and on computer I can visualize and work with them.

Installation

On PC

  • Windows users
    • You will need to be on Windows 11 Build 22000 or later.
    • Install driver for vGPU to run Linux GUI apps
    • Install WSL2. Open Microsoft Store and install Ubuntu 20.04.
    • Download and install VcXsrv Windows X Server. Open and set:
      • check multiple windows and set display number to 0;
      • in next window check start no client;
      • finally check all extra settings;
      • enable Outgoing Connection from Windows Firewall
    • Run Ubuntu 20.04
    • In WSL run export DISPLAY=127.0.0.1:0.0 # you can also add it to ~/.bashrc
    • Create a .xsession file in the user home directory e.g. echo xfce4-session > ~/.xsession
  • Install ROS1 Noetic
  • Update/Install Git and Python3
# Install Git and Python3 if not installed
apt-get update && apt-get install -y git python3-pip
# or just add it to ~/.bashrc with
# echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source /opt/ros/noetic/setup.bash
  • Download and build my repository
git clone --recurse-submodules https://github.com/CatUnderTheLeaf/rosRoboCar.git

source /opt/ros/noetic/setup.bash
cd /path/to/robocar_ws

# Install dependencies
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro noetic

# Building packages
# Add CATKIN_IGNORE to robot_only packages, e.g. raspicam_node
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3

# Source this workspace
source devel/setup.bash

On a car

  • A DonkeyCar has RaspberryPi, so first make it work. If there are problems check resolve connectivity problems
  • Install ROS1 Noetic from sources. In the catkin_make_isolated step add -j2 flag, so it will not stuck.
  • Download this repository.
  • Unfortunately dependencies can not be resolved, as there are no binary packages. So download in ~/ros_catkin_ws/src following repositories: image_transport, replace image_common, image_pipeline, replace vision_opencv.
  • Install compressed_image_transport, image_transport_plugins, camera_calibration_parsers, camera_info_manager, image_geometry, image_proc with a command
./src/catkin/bin/catkin_make_isolated -j2 --install -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 --install-space /opt/ros/noetic --pkg YOUR_PACKAGE_NAME
  • Install libs for i2cpwm_board node:
    • install libi2c-dev
    • add target_link_libraries(i2cpwm_board i2c) to CMakeLists.txt
    • add to i2cpwm_controller.cpp
extern "C" {
    #include <unistd.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <linux/i2c-dev.h>
    #include <i2c/smbus.h> // additional header file
}

Code of this package was copied from this tutorial, because original was deleted(?). That tutorial was made when libi2c-dev was version 3. Now it is version 4 and some big changes were made.

Running ROS across multiple machines

Connect your car and PC. Don’t forget to export ROS_IP and ROS_MASTER_URI

Now a car can be launched with

roslaunch donkeycar donkey.launch simulation:=0

On PC:

 rosrun image_view image_view image:=//raspicam/image _image_transport:=compressed

Next: Calibration and Setup