Skip to content

On-Robot vision processing of a Raspberry Pi camera.

License

Notifications You must be signed in to change notification settings

TIGERs-Mannheim/RobotPi

Repository files navigation

TIGERs Mannheim On-Robot Vision

This repository contains code running on a Raspberry Pi 3A+ with a camera module v1 detecting mainly balls. Additionaly functionality was implemented for the RoboCup 2021 and 2022 technical challenges.

How it works

The ball detection is based on color segmentation similar to the algorithm running on the shared ssl-vision software. It is configured for orange, white, and black. The orange blobs are estimated in 3D space based on their diameter or an intersection of the camera ray with the ground plane. Afterwards a tracking filter is used to estimate motion of each detected ball. The largest ball is reported via a UART to the microcontroller controlling the robot. Depending on its active bot skill the robot can autonomously drive to the ball.

A simple point distance sensor is implemented which estimates the distance to the next obstacle by checking for white and black vertical lines (goals and walls) in front of it. A larger vertical line corresponds to a closer obstacle.

Development

How to build

Build is based on cmake. The applications are cross-compiled on a standard x64 computer.

You need:

  • The sysroot of your target. Available as artifact of the tigers-buildroot project. It contains all the system libraries and files.
    • If you have a local tigers-buildroot setup the required subfolder is tigers-buildroot/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot
    • Alternatively, you may download the sysroot from the tigers-buildroot CI here. Download the rpi3-tigers-sysroot artifact.
  • A toolchain:
  • cmake

☝️ The required compiler is GCC 10.3 for 32-Bit ARM with hardware floating point support. It is the same version tigers-buildroot is configured to use. If tigers-buildroot is updated, this one must be changed as well.

Then go into the repository root folder and run:

  1. Linux build
    cmake -B build -DCMAKE_SYSROOT=/your/path/to/sysroot -DCMAKE_PREFIX_PATH=/your/path/to/toolchain .
    cmake --build build -j
    
  2. Windows build (assuming MinGW environment)
    cmake -B build -G "MinGW Makefiles" -DCMAKE_SYSROOT=/your/path/to/sysroot -DCMAKE_PREFIX_PATH=/your/path/to/toolchain .
    cmake --build build -j
    

You may need to adjust your sysroot and toolchain path.

Eclipse IDE Setup

  1. Download Eclipse Embedded for your platform: 2022-06 Embedded
  2. Unpack the file and start Eclipse
    1. Select a workspace. It should not contain any whitespaces!
  3. Go to Help => Eclipse Marketplace. Install the following plugins:
    1. cmake4eclipse
    2. CMake Editor (optional, syntax highlighting for cmake files)
    3. DevStyle (optional, for a nice dark theme)
  4. Restart Eclipse after plugin installation
  5. In Eclipse open: Window => Preferences
    1. Go to: Run/Debug => String Substitution
    2. Click: New..., Name: TIGERS_ROBOTPI_TOOLCHAIN, Value: path to your cross compilation toolchain
    3. Click: New..., Name: TIGERS_ROBOTPI_ROOTFS, Value: path to your target's sysroot
    4. (Windows only) Go to: C/C++ => Cmake4eclipse => General tab
    5. Change default build system to: MinGW Makefiles

Project Import

  1. In Eclipse select: File => Import...
  2. Under "GIT" select "Projects from Git", hit Next
  3. Select "Clone URI", hit Next
  4. Enter the RobotPi repository URL
  5. Select at least the master branch, others are optional, click Next
  6. Select a local directoy for the project, click Next
  7. Wait for the download to finish and then select "Import existing projects", click Next
  8. Select the RobotPi project and click "Finish"

Compiling

  1. Right click on the RobotPi project and go to: Build Configurations => Set Active
  2. There are different configurations. One for a debug build and one for a release with optimizations enabled.
  3. Choose the configuration you wish to build
  4. Right click on the project and select Build Project
  5. You can also select the build configuration and the build command in the toolbar. It is the small hammer symbol and the symbol right of it. Make sure you select the RobotPi project before using the buttons.

Remote Development Setup

In order to run and debug RobotPi on the actual target hardware you need to setup an SSH connection. Go to Window => Preferences.

  • Navigate to: Remote Development => Remote Connections
  • At the top select Remote Services: SSH
  • Click Add
    • Connection name: RPi Wifi
    • Host: 192.168.42.1
    • User: root
    • Select "Password based authentication"
    • Password: root
  • Click finish and close preferences

How to run

In Eclipse:

  • Go to Run => Run Configurations...
  • Under C/C++ Remote Application
  • Select "RobotPi Release"
  • Check that the Connection is set to "RPi Wifi"
  • Hit Run

How to debug

You may need to install the following packages if gdb fails to start: sudo apt install libpython2.7 libncursesw5 Or on Windows (use 32bit installer!): https://www.python.org/downloads/release/python-2716/

In Eclipse:

  • Go to Run => Debug Configurations...
  • Under C/C++ Remote Application
  • Select "RobotPi Debug"
  • Check that the Connection is set to "RPi Wifi"
  • Hit Debug
  • If everything works will ask you if you want to switch to the Debug View, say yes
  • Eclipse will stop the program at main(), happy debugging!

About

On-Robot vision processing of a Raspberry Pi camera.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages