/robo_car

remote-controlled & autonomous driving robotic car

Primary LanguageC++MIT LicenseMIT

RoboCar

DEPRECATED, checkout RoboCar_Platform and RoboCar_SDK

The main aim of this repo is to set up a low-cost remote-controlled robotic car and later on a completely autonomous driving car with a Raspberry Pi 3b+


example

Table of Contents:

Hardware

To build this platform, two essential part have to be considered. On the one hand the used hardware components and on the other hand the wiring of the individual components

Components

Here are listed all hardware components that were used to build this RoboCar

Without a Lidar sensor the cost is about ~140€ . With a Lidar the cost is about ~230€ - ???.

Datasheets for every component can be found under /hardware

Circuit Diagram

The Circuit Diagram is shown below to connect the individual components. A pdf file is under /circuit_diagram


example

Software

This Software is written in C++, build with CMake and is divided in Remote-controlled and Autonomous driving with different submodules:

Remote-controlled:

RoboCar:

RoboControl:

RoboSLAM:

As first step build the hokuyo_node with subsequent commands:


sudo apt-get install ros-kinetic-driver-common

Go into catkin workspace ~/catkin_ws/src and clone hokuyo_node:


git clone https://github.com/ros-drivers/hokuyo_node.git

go back to ~/catkin_ws and build:


catkin_make

Install hector_mapping and hector_trajectory_server:


sudo apt-get install ros-kinetic-hector-mapping ros-kinetic-hector-trajectory-server

Launch file for hector_mapping and hector_trajectory_server

launch file to start the hokuyo_node, the hector_mapping and the hector_trajectory_server packages with the correct parameters can be found here

Autonomous driving:

ROS drivers

Writing drivers to convert raw sensor data to ROS compliant message data:

Data topics:

  • /visual/odom       -> data from an odometry sensor/source (camera odometry)
  • /imu/data            -> data from an inertial measurement unit (imu) sensor (mpu6050)
  • /scan                   -> data from a Laser scanner (hokuyo)
  • /camera/data      -> data from a plugged in camera (picamera)

Sensor data fusion

In order to obtain the most accurate position, the data sources visual odometry, lidar odometry and imu will be merged with an extended kalman filter

Create a correct transformation tree of the robot

Navigation stack

Operating System

As operating system Ubuntu Mate was selected. Due to the reason that currently no official raspberry pi 3b+ image is provided (25.10.2018), litte hacks are necessary to get it running.

Problem: The Rasperry Pi 3b+ shows only a rainbow screen and will not boot


Instructions to install Ubuntu Mate for Raspberry Pi 3b+


  1. Download Ubuntu Mate image for Raspberry Pi 2/3 here

  2. Flash Ubuntu Mate image on sd card

  3. Insert sd card into a Raspberry Pi 2 or Raspberry Pi 3

  4. Boot Raspberry Pi 2/3 and insert subsequent command for a kernel update


sudo CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt rpi-update

alternative:


sudo BRANCH=stable rpi-update
  1. Insert sd card into Raspberry Pi 3b+, now the raspi should start booting

  2. No wifi is available!

    • Install a new raspbian image on sd card
    • boot a raspberry pi with this sd card
    • copy folder /lib/firmware/brcm on a usb
    
     sudo cp -r /lib/firmware/brcm /path_to_usb
     
    • boot Raspberry Pi 3b+ with Ubuntu Mate
    • replace current /lib/firmware/brcm with the folder on usb stick
    
     sudo cp -r /path_to_usb/lib/firmware/brcm /lib/firmware/brcm
     
  3. Reboot and wifi should be available

  4. Enable ssh on boot. Insert in terminal:


sudo systemctl enable ssh

Instructions to install ROS on Ubuntu Mate


  1. Setup sources.list

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  1. Setup keys

wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
  1. Update packages

sudo apt-get update
  1. Install ros-kinetic-desktop-full

sudo apt-get install ros-kinetic-desktop-full
  1. Initialize rosdep

sudo rosdep init

rosdep update
  1. Setting up the ROS environment variables

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc

source ~/.bashrc
  1. Create a catkin workspace

mkdir -p ~/catkin_ws/src

cd ~/catkin_ws/

catkin_make

source ~/catkin_ws/devel/setup.bash
  1. If you want access to source builded ros packages everywhere in your linux system

echo “source ~/catkin_ws/devel/setup.bash” >> ~/.bashrc
  1. Start roscore master

roscore

Add write permission to the hokuyo port /dev/ttyACM0


The hokuyo laser scanner needs write permission to the /dev/ttyACM0 port to get scans. For this add your current "user_name" to the dialout group.


sudo adduser "user_name" dialout

sudo reboot

Create a systemd service for roscore master


  1. Create a file named roscore.service in /etc/systemd/system and insert:

[Unit]
Description=start roscore master as a systemd service

[Service]
Type=simple
ExecStart=/bin/bash -c "source /opt/ros/kinetic/setup.bash; /usr/bin/python /opt/ros/kinetic/bin/roscore"

[Install]
WantedBy=multi-user.target
  1. Enable this service on boot

sudo systemctl enable roscore.service
  1. Now the roscore master should be available on boot. Check status with:

sudo systemctl status roscore.service

Create a systemd service for hokuyo_hector_slam.launch file


  1. Create a file named hector.service in /etc/systemd/system and insert:

[Unit]
Description=start hokuyo_node and hector_mapping as a systemd service
Requires=roscore.service
After=roscore.service
After=network.target

[Service]
Type=simple
ExecStart=/bin/bash -c "source /opt/ros/kinetic/setup.bash; source /path_to_catkin_ws/devel/setup.bash; /opt/ros/kinetic/bin/roslaunch /path_to_launch_file/robo_car/software/remote_controlled/roboslam/hokuyo_hector_slam.launch"
Restart=on-failure

[Install]
WantedBy=multi-user.target

Please change the /path_to_catkin_ws and the /path_to_launch_file to your needs

  1. Enable this service on boot

sudo systemctl enable hector.service
  1. Now the this service should be available on boot. Check status with:

sudo systemctl status hector.service

Wiring Pi update


  1. Check WiringPi software with gpio -v

  2. If errors occur, remove current wiring pi version


sudo apt-get purge wiringpi
  1. Clone current wiring pi version from source and build

sudo apt install git

git clone git://git.drogon.net/wiringPi

cd wiringPi

./build
  1. Check the new version of wiring pi

gpio -v

gpio readall

Project Layout


/circuit_diagram
    robocar_circuit_diagram.pdf

/hardware
    /chassis
    /motors
    /power_supply
    /raspberry
    /sensors
    README.md

/images
    circuit_diagram_robocar.png

/scripts
    README.md
    os_settings.sh
    ros_install.sh

/software
    /gui
        /build
        /images
        /include
            ClientSocket.h
            Socket.h
            SocketException.h
            mainwindow.h
        /src
            ClientSocket.cpp
            Socket.cpp
            mainwindow.cpp
            mainwindow.ui
        main_gui.cpp
        CMakeLists.txt
    /robocar
        /build
        /configs
        /include
            /car
                /bus
                    I2C.h
                /sensors
                    Camera.h
                    CameraServo.h
                    GearMotor.h
                    MPU6050.h
                    PCA9685.h
                    SteeringServo.h
                    Ultrasonic.h
                 Car.h
            /server
                /communication
                    ServerSocket.h
                    Socket.h
                    SocketException.h
                Server.h
            /slam
                SlamMap.h
        /src
            /car
                /bus
                    I2C.cpp
                /sensors
                    Camera.cpp
                    CameraServo.cpp
                    GearMotor.cpp
                    MPU6050.cpp
                    PCA9685.cpp
                    SteeringServo.cpp
                    Ultrasonic.cpp
                Car.cpp
            /server
                /communication
                    ServerSocket.cpp
                    Socket.cpp
                Server.cpp
            /slam
                SlamMap.cpp
        CMakeLists.txt
        robocar_main.cpp
    /testing
        client.cpp
        client.h
        gearmotor.py
        hokuyo_lidar.py
        main_client.cpp
        main_i2c.cpp
        main_server.cpp
        main_serversocket.cpp
        picamera_stream.py
        server.cpp
        server.h
        servomotor.py
        ultrasonic.py
    README.md
LICENSE
README.md