His sole purpose was nothing more nor less than to prove that God was no longer necessary.

- Karel Čapek, R.U.R.: Rossum's Universal Robots

Follow us on

follow_the_Project_on_facebook

Share this page with friends via

email icon facebook icon twitter icon
linkedin icon google plus icon blogger icon

Programming the Blue Seal Robot

Preparing

In this chapter we are going to learn how to program the Blue Seal Robot. We will show how to use Python in order to operate the stepper motors, both sensors, LED and the shutdown button by several scripts. All the scripts will be started automatically at the startup of the Raspberry Pi and will be running simultaneously while exchanging data.

We will also learn how to create a TCP-IP based script which will communicate with the Blue Seal Controller and share receive commands with the parallel process controlling motors and LED.

Therefore the tasks have to be distributed among several parallel running processes which will share data with each other. The Blue Seal Robot consists of these four parallel Python processes:

  • button.py
    - waits for action on the shutdown button and shuts down the Raspberry Pi when action detected,
  • SEAL.py
    - controls the stepper motors and LED, obtains instructions from process "TCP-IP-server.py" via Python function mmap,
  • TCP-IP-server.py
    - communicates with the Blue Seal Controller and controls the ultrasonic sensor, the instructions from the Controller are shared via mmap,
  • gyroanglesmeasurement.py
    - measures the orientation of the robot in real-time and shares it again with mmap.

Of course, all the processes start automatically at start of the Raspberry Pi and run in the background as daemon services.


In order to simplify the code as much as possible, there are several classes which help us to control the stepper motors, LED or the sensors. The dependencies are shown in the following graphic:

The Button


We are going to introduce every single component in these sections:

A special attention deserves the section on communication between the SEAL.py and TCP-IP-server.py where we define a special string based front with commands and their statuses shared via the function mmap. We also define class commands_management which will be used by processes SEAL.py and TCP-IP-server.py and will help them to handle the string-based front(e.g., return next element, mark element as executed or delete all executed elements).

The class OS_cmnds_mngmnt will be used only by TCP-IP-server.py and will be an analogous to the class commands_management. It will help us to handle the commands coming from the Controller.



Blue Seal Project created by Jiří Daněk (2013-2016)