Friday, 22 January 2016

Team Bohemian Raspbian




About The Team


Team Bohemian Raspbian consists of four members, Luke, Kamil, Shaun and Heng. Both Luke and Shaun come from the BSc in Applied Electronics, Heng from the BEng in Electronic Engineering and Kamil from the BSc in Applied Computing. With all the different backgrounds leads to many different strengths and weaknesses of the group but mainly it brings different approaches to the problem at hand.

Assignment Overview

From the overlay of the first sprint, a number of assignments where created:
  1. OpenCV- Raspberry Pi 2 running OpenCV and creating a co-ordinates system as the output for tracking a face. This was assigned to Luke.
  2. Servo Controls- This take’s the co-ordinate system and apply it to the servo motors accordingly. This was assigned to Shaun.
  3. Sound Overlay- This will take different sound outputs based on movements and apply them for the period of time the motors are moving. This was assigned to Heng.
  4. Threads and IPC- This will combine all of the previous three parts into one big program. This was assigned to Kamil.

The Layout of these assignments can be seen in the image found in Kamils Thread’s section below. Each part operates isolated from the rest and using the threads system passes the relevant information to their desired location.

Assignment Timeline

The sprint itself was split into four tasks. 


  • Task one is the starting point. This is the preliminary code to test each individual part. 
  • Task two is the setting up of the code for communications to the different sections. 
  • Task 3 is combining the previous tasks through the Threads.
  • Task 4 is the final debugging of the code.
The Gant Chart below shows the timeline of set aside for each of these Tasks.



Design Overview

Threads by Kamil Mech

According to this documentation here, Linux OS uses pipes, message queues, semaphores and shared memory for its inter-process communication.

In this project, we have agreed to use a message bus for our thread communication. Threads will be able to emit and receive messages.

Advantage of this approach is scalability - It will be easy to add-on new functionality and 'listen' for data from other threads.

My implementation will be inspired by documentation mentioned above and this approach here. I will ensure code is easy to understand and the utility is easy to use. We do not need unnecessary complexity at this stage.


In our case:

Sidenote:
Future years may look at using Johnny Five

Sound Overlay by Heng

Sounds is the key for an object to look alive. In this phase, different sounds will be added to the lampbotics under different events such as different movements (up,down,tilt,left,right,etc), power startup, power off, and the list goes on. Apart from that, silent mode is considered as well.

In order to play various types of music files such as .wav, .mp3 files using the standard audio output , a Python library has to be used to allow audio files to be played on Raspberry Pi 2.  One of the alternatives is Pygame. Pygame is a set of Python modules designed for writing games. It is pre-installed on the Pi. One can use the Pygame Mixer Music Module to play audio files. Some other methods are available as well such as subprocess module, pyaudio, etc.

The movement sound effect will be played according to the Duty Cycle of PWM which is the period where servo motor is performing actions. Flags / Variables will be set according to different servo movements and this will indicates which sounds to be played.


Here are some of the useful links to produce sound effect:
https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/code
http://raspberrypi.stackexchange.com/questions/7088/playing-audio-files-with-python
http://www.pygame.org/docs/ref/music.html

Servo Motor Control by Shaun Kavanagh

The servos used in this Lampbotics project will be controlled from an output from a raspberry pi. The servo motors are controlled using Pulse Width Modulation, PWM. PWM is a modulation technique where the width of a rectangular pulse wave is varied. The period of the pulse wave remains the same so as the width of the Y-max pulse increases the width of the Y-min decreases. The “duty cycle” refers to the proportion “on” time to the period as a percentage.

The servos can rotate from 0° to 180°, by offsetting the 0 reference point in the code we can have     -90° to + 90° for the x-axis and y-axis. Since not all servos have exactly 0° to 180° range of motion some trial and error may be required for testing the outer limits of the motors. These motors require a constant rectangular pulse to maintain position.

The information about the control of the servos was sourced at Jameco Electronics, (jameco), this provided useful and easy to understand information concerning servo motors.




OpenCV by Luke Byrne

Open Source Computer Vision (OpenCV) is a vision systems package library that is used by a number of different applications. For this project OpenCV will be used in conjunction with the Python Development tool on the Raspberry Pi 2 Board. The goal of the addition of this software is to bring to life the Lampbotics project. Looking at a robot dace around is not something new and people understand that this is a programmed movement however with the addition of vision systems to a robotic platform it adds a level of mystery to the user experience as nobody is expecting a robot to look at your movements and follow what you do.

For the first iteration of this project, OpenCV is only required to control Pan and Tilt servo motors. The simplest way to implement this is by obtaining the x and y co-ordinates of a face using facial recognition programs. This x and y coordinate system is then outputted to the servo motors to adjust their orientation. The OpenCV facial recognition software comes as a sample program with the library’s and can be tweaked in order to obtain the outputs needed. The inspiration for using this package comes from previous blog post and expanding what has been done in other years.


(Thanks to Philip for the picture)

Team Bohemian Raspbian:- Post 1




No comments:

Post a Comment