Last modified by Soeren Domroes on 2025/01/30 12:18

From version 3.1
edited by stu120505
on 2020/04/03 00:33
Change comment: There is no comment for this version
To version 7.2
edited by stu122612
on 2023/07/06 14:48
Change comment: Update document after refactoring.

Summary

Details

Page properties
Parent
... ... @@ -1,0 +1,1 @@
1 +PP18.Pinball Project - Winter Term 201920.Project Documentation.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.stu120505
1 +XWiki.stu122612
Content
... ... @@ -1,9 +1,10 @@
1 -= Building and Running the Pinball Autopilot on the Pi =
1 += Building and Running the Pinball Autopilot on the Raspberry Pi =
2 2  
3 -The source code lies and building happens inside the folder called {{code language="none"}}pinballProject{{/code}}. For a fresh built, you need a not too old version of {{code language="none"}}make{{/code}}, a C++ compiler (we only tested {{code language="none"}}g++{{/code}}), a internet connection (for downloading the Kieler Compiler), the libraries {{code language="none"}}wiringPi{{/code}} and {{code language="none"}}opencv{{/code}} as well as the command-line tools [[mega-cmd>>url:https://mega.nz/cmd||shape="rect"]] and {{code language="none"}}python2{{/code}}. The tool for mega.nz (and also {{code language="none"}}python2{{/code}}) can be omitted (see below on how to compile without them), everything else except for {{code language="none"}}opencv{{/code}} comes pre-installed with Raspbian. For {{code language="none"}}opencv{{/code}} you need a 4.x version, 4.2.0 ought to work for example. Make sure to enable the option that the entries for {{code language="none"}}pkg-config{{/code}} 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.
3 +The source code lies and building happens inside the folder called {{code language="none"}}pinballProject{{/code}}. For a fresh build, you need a not too old version of {{code language="none"}}make{{/code}}, a C++ compiler (we only tested {{code language="none"}}g++{{/code}}), an internet connection (for downloading the Kieler Compiler), the libraries {{code language="none"}}wiringPi{{/code}} and {{code language="none"}}opencv{{/code}} as well as the command-line tools [[mega-cmd>>url:https://mega.nz/cmd||shape="rect"]] and {{code language="none"}}python2{{/code}}. The tool for mega.nz (and also {{code language="none"}}python2{{/code}}) can be omitted (see below on how to compile without them), everything else except for {{code language="none"}}opencv{{/code}} comes pre-installed with Raspbian. For {{code language="none"}}opencv{{/code}} you need a 4.x version, 4.2.0 ought to work for example. Make sure to enable the option that the entries for {{code language="none"}}pkg-config{{/code}} 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.
4 4  
5 -With all the pre-requisits met, you can use the {{code language="none"}}Makefile{{/code}} to build everything.
5 +With all the prerequisites met, you can use the {{code language="none"}}Makefile{{/code}} to build everything.
6 6  
7 +(% class="wrapped" %)
7 7  |=(((
8 8  Command
9 9  )))|=(((
... ... @@ -141,16 +141,17 @@
141 141  
142 142  = Setting up the Pi for Better Real Time Performance =
143 143  
144 -The program will stick its latency-sensitive threads for controlling the IO pins and for image processing to the cores 3 and 4 of the 4-core Raspberry Pi. To ensure best real-time performance, please configure the kernel parameter (% style="color: rgb(0,0,0);font-family: SFMono-Medium , SF Mono , Segoe UI Mono , Roboto Mono , Ubuntu Mono , Menlo , Courier , monospace;" %)2,3{{code language="none"}}isolcpus={{/code}}(%%) (they count from 0) to the file {{code language="none"}}/boot/cmdline.txt{{/code}} and reboot. This will make sure that the operating system doesn’t schedule any tasks on those cores.
145 +The program will stick its latency-sensitive threads for controlling the IO pins and for image processing to the cores 3 and 4 of the 4-core Raspberry Pi. To ensure best real-time performance, please configure the kernel parameter (% style="color: rgb(0,0,0);font-family: SFMono-Medium , SF Mono , Segoe UI Mono , Roboto Mono , Ubuntu Mono , Menlo , Courier , monospace;" %)2,3{{code language="none"}}isolcpus={{/code}}(%%) (they count starting from 0) to the file {{code language="none"}}/boot/cmdline.txt{{/code}} and reboot. This will make sure that the operating system doesn’t schedule any other tasks on those cores.
145 145  
146 146  = Building and Running on Any Other Linux Machine =
147 147  
148 -The program can be built and partially run on other machines. There you potentially need to install all the requirements yourself. Just {{code language="none"}}wiringPi{{/code}} is not needed. Also don’t use a machine where the current user is called {{code language="none"}}pi{{/code}}. We’ve observed problems with a too old version for {{code language="none"}}make{{/code}}, for example 4.2 should be new enough. Possibly {{code language="none"}}python2{{/code}} needs to be installed on your machine. Compared to a Raspberry Pi, compilation of {{code language="none"}}opencv{{/code}} on your machine is going to be a lot more fun (way faster and no issues with too little RAM) Regarding versions, see the relevant section above, note that {{code language="none"}}pkg-config{{/code}} is needed, too, in case you don’t have that already.
149 +The program can be built and partially run on other machines. There you potentially need to install all the requirements yourself. However, {{code language="none"}}wiringPi{{/code}} is not needed. Also don’t use a machine where the current user is called {{code language="none"}}pi{{/code}}, since that would confuse the compilation flags. We’ve observed problems with a too old version for {{code language="none"}}make{{/code}}, without knowing the exact lower bound, 4.2.1 is definitely new enough. Possibly {{code language="none"}}python2{{/code}} needs to be installed on your machine. Compared to a Raspberry Pi, compilation of {{code language="none"}}opencv{{/code}} on your machine is going to be a lot more fun (way faster and no issues with too little RAM). Regarding versions, see the relevant section above; note that {{code language="none"}}pkg-config{{/code}} is needed, too, in case you don’t have that installed already.
149 149  
150 -Running works like on the Pi. The main program will prompt you for the name (without extension) of a video file in the {{code language="none"}}video{{/code}} folder. Make sure to get some file, at the time of this writing there is a file called {{code language="none"}}1{{/code}} that you can get via {{code language="none"}}make get{{/code}} as well as a few more named files that were created before we had the {{code language="none"}}make capture{{/code}} command.
151 +Running the {{code language="none"}}make{{/code}} commands works like on the Pi. Just {{code language="none"}}make capture{{/code}} is not available. The main program will behave differently. It will prompt you for the name (without extension) of a video file in the {{code language="none"}}video{{/code}} folder. Make sure to get some file in there; at the time of writing this, there is a file called {{code language="none"}}1{{/code}} in the mega.nz-folder that you can get via {{code language="none"}}make get{{/code}}, as well as a few more named video files that were created before we had the {{code language="none"}}make capture{{/code}} command.
151 151  
152 -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.
153 +After choosing a video file, the program starts using the video input in “real time”; however, since things are not really real-time, the logic controller part does not work too well. (Simulating the flow of time properly is not fundamentally a problem but something we didn’t finish implementing.) This means you should mostly ignore the debug-printouts about ticks happening. What you can really test is the image processing / ball detection. This works better than on the Pi, because we are providing controls for pausing or changing the playback speed. Press a key while any of the windows opened by the main program is in focus.
153 153  
155 +(% class="wrapped" %)
154 154  |=(((
155 155  Key
156 156  )))|=(((
... ... @@ -188,3 +188,5 @@
188 188  )))
189 189  
190 190  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).
193 +
194 +The ability to compiler the whole project off the Pi allows for catching type errors etc. more quickly, since compilation on the Pi tends to be a lot slower and also there‘s not the option to use the Kieler IDE on it (so you’d maybe also need to transfer the code). The {{code language="none"}}pinballProject{{/code}} folder contains an Eclipse project that can be used with Kieler. Building from the Kieler IDE still happens by invoking the Makefile. There should be a build configuration using {{code language="none"}}make{{/code}} included in the project. (I’m only specifying “should” since we didn’t really test the experience of importing the project into a workspace too often.)
Confluence.Code.ConfluencePageClass[0]
Id
... ... @@ -1,1 +1,1 @@
1 -73072744
1 +73072735
URL
... ... @@ -1,1 +1,1 @@
1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/PP18/pages/73072744/Dependencies and Compilation
1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/PP18/pages/73072735/Dependencies and Compilation