Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Building and Running the Pinball Autopilot on the Raspberry Pi

The source code lies and building happens inside the folder called pinballProject. For a fresh builtbuild, you need a not too old version of make, a C++ compiler (we only tested g++), a internet connection (for downloading the Kieler Compiler), the libraries wiringPi and opencv as well as the command-line tools mega-cmd and python2. The tool for mega.nz (and also python2) can be omitted (see below on how to compile without them), everything else except for opencv comes pre-installed with Raspbian. For opencv you need a 4.x version, 4.2.0 ought to work for example. Make sure to enable the option that the entries for pkg-config get configured. It can be built from source on the Raspberry Pi in a few hours, make sure not to use too many threads for compilation because of limited RAM, also perhaps increase the swap.

With all the pre-requisits met, you can use the Makefile to build everything.

CommandFunctionality (All the builds are incremental, i.e. only happen once when the source code is unchanged.)
makesame as make build_all
make build_allBuild the main executable as well as the tools video_capture and calibrate.
make buildBuild the main executable “main”.
make runBuild and execute the main executable.
make ...xyzMake file called “...xyz”, if a recipe exists. Most notably for ...xyzcalibrate
make capture

Build video_capture and execute it. This tool can only be executed on the Pi and can record a video
during manual gameplay which is then uploaded to mega.nz with a new numerical file-name.

make get

Executes a python script that can (interactively) get a recorded video from the mega.nz folder.
Intended for getting video input files transferred to a different machine (not the Pi) for testing the image detection.

make cleanRemoves all generated files except for _pi_logged_in, downloaded videos and the downloaded Kieler Compiler.
make clean_allLike make clean, but without the exceptions. This will delete everything in the folder video!

For instructions on how to use the ./calibrate, see World Coordinate System.

...

After choosing a video file, the program starts using the video input in “real time”; since things are not really real-time, the controller does not work too well. (Simulating time properly is not fundamentally a problem but something we didn’t finish implementing.) This means you can mostly ignore the debug-printouts about ticks happening. What you can do is test the image processing / ball detection. This works better than on the Pi, because we are providing controls for pausing or changing the playback speed.

KeyPlayback effect
<space>play/pause
+increase playback speed ×2
-decrease playback speed ×0.5
.while paused, advance by one frame

If you recalibrate the coordinate system on the Pi, you might want to transfer the config file for the coordinate system (however there is nothing really depending on the coordinate transformation being correct inside the image detection anyways).