Monday, March 25, 2013

Video streaming using Gstreamer

A major part of our project is to stream live video from a camera mounted on the Bot to the Android phone. We are using "Microsoft Lifecam Vx-5000" connected to Beaglebone via USB to capture the video.
Gstreamer is an open souce multi-media framework and is widely used for media streaming. It is well documented and provides an easy to use command line interface. The major hurdle in using Gstreamer was to find the right set of commands to reduce the lag in the streaming to less than a second.

Gstreamer Commands Used:
Beaglebone:
 gst-launch v4l2src device=/dev/video0 ! videorate ! video/x-raw-yuv,width=160,height=120,framerate=6/1 !   
 jpegenc quality=30 ! multipartmux ! tcpserversink port=5000  

Client(PC and Android):
 gst-launch tcpclientsrc host=localhost port=5000!multipartdemux!jpegdec!autovideosink  

We used very low resolution (160 X 120) to achieve the low lag requirement. Using these commands, the lag in the streaming was reduced to less than half a second.


Gstreamer on Android:

We followed the tutorial given here to install Gstreamer on Android. We had to install JNI and Gstreamer SDK to build Gstreamer projects in Eclipse. After configuring Eclipse, we made small modifications (changed the string in the gst_parse_launch to the client command given above) to this tutorial to make the app work according to our requirement.

Saturday, March 23, 2013

PWM on Beaglebone- Interfacing of Servo Motor

The parallax boe bot comes with a continuous servo motor. To drive the motor, we required PWM output from the Beaglebone. The Beaglebone has three PWM modules, each with 2 outputs. Accessing the PWM modules is very easy. The tutorial found here gave us detailed step by step instructions on how to configure the PWM module.

The servo motor requires a PWM wave of 50Hz for proper operation. The speed and direction of rotation is controlled by the duty cycle of the PWM wave.

  1. Duty cycle of 1500us stops the motor
  2. Duty cycle of 1300us makes the motor rotate in one direction
  3. Duty cycle of 1700us makes the motor rotate in the other direction
The speed of rotation varies linearly as the duty cycle, i.e. a duty cycle of 1400us makes the motor rotate at half speed and so on. The speed remains constant if the duty cycle is reduced below 1300us or increased above 1700us.

We used the two outputs of EHRPWM0 (Enhanced High Resolution PWM) module to control the two servo motors of the bot. The PWM outputs are connected to pins 29 and 31 of header P9 on the Beaglebone. To interface the servo motor:
  1. Connect VCC, Ground and PWM output pin to appropriate leads of the motor
  2. Configure MUX settings, so that pin 29 outputs PWM wave
     echo 1 > /sys/kernel/debug/omap_mux/mcasp0_aclkx  
    
  3. Request EHRPWM0:0 from the OS
     echo 1 > /sys/class/pwm/ehrpwm.0:0/request  
    
  4. Set PWM frequency
     echo 50 > /sys/class/pwm/ehrpwm.0:0/period_freq  
    
  5. Set PWM duty cycle
     echo 1300000 > /sys/class/pwm/ehrpwm.0:0/duty_ns  
    
  6. Run
     echo 1 > /sys/class/pwm/ehrpwm.0:0/run  
    
These steps were followed to output PWM wave(period of 20ms and duty cycle of 1300us) from the terminal. The same was then converted into C program using file operations

Thursday, March 21, 2013

GPIO on Beaglebone- Blinking LEDs

The first program that we wrote, was the famous "Hello World" of the embedded universe, .i.e. blinking of a led connected to a GPIO port. Access to GPIO ports is provided through the sysfs interface on Angstrom. To blink an led we must:

  1. Look up GPIO number of the pin in the Beaglebone reference manual. For example, pin 3 on P8 is connected GPIO1_6. To obtain the GPIO number we must multiply the port number by 32 and add the pin number. So GPIO1_6 would be 1x32 + 6 = 38
  2. Next we must export this pin, so that it is accessible from user space.
     echo 38 > /sys/class/gpio/export  
    
  3. Set the direction of the pin as output
     echo out > /sys/class/gpio/gpio38/direction  
    
  4. Write values to the 'value' file
     echo 1 > /sys/class/gpio/gpio38/value  
    
The above steps were followed to blink an led from the terminal. The same was then converted into a C program using C file operations (fopen, fprintf)

Wednesday, March 20, 2013

Getting Wifi - Connectivity on the beagle bone

Getting the Wifi connectivity on the beagle bone was a tricky process . It took us some time to get to know the packages that have to be installed to get Wi-fi Connectivity on the beagle bone.
We are using the Belkin F5D7050 USB Wi-fi adapter to connect to the Wi-fi networks. The adapter is connected to the USB port on the beagle bone.
After doing a lot of Google search we found that we had to install two packages onto the Linux distribution to get Wifi connectivity on the beagle bone .

  1. The first was the firmware required for the Wi-fi adapter . The firmware required for this is rt73-firmware. The firmware was downloaded from the angstrom distribution webpage. (http://www.angstrom-distribution.org/)
  2. The second package that we installed was wireless-tools which was also downloaded from the angstrom distribution webpage.
Once we had installed the two packages we had to specify the network ssid and the passphrase in the /etc/wpa_supplicant.conf file. Once this was done we just restarted the beagle bone and did ifup wlan0 to get the wifi connection up on the beagle bone. 



Sunday, March 17, 2013

Installation of Ångström OS on the beagle bone

The installation of the Angstrom OS on the Beagle bone was a quite a simple process . 
  1. Download the latest Angstrom Distribution image onto your PC . (Available at http://beagleboard.org/latest-images)
  2. Connect the micro SD card to your PC .
  3. Write the image to the micro SD card. 
  4. Connect the micro SD card to the beagle bone and the power the beagle bone. 
  5. ssh into the beagle bone to access the files on the beagle bone.
We followed the tutorial on this page http://beagleboard.org/static/beaglebone/latest/README.htm .








Friday, March 15, 2013

Overview

In this project, we intend to develop a remote control robot with a webcam mounted on it that transmits a live video feed to an Android application on the user's phone. The Android application will be used to control the robot.

Embedded Side:

A beagle bone will be mounted on a small robot. The output pins of the beagle bone will be connected to the actuators of the motor to control the robot. A camera will be mounted on the robot, which will be interfaced with the beagle bone via USB. There will be ping sensors attached on the front of the robot to detect any obstacles within its range. A Wi-fi adapter will be used to connect the beagle bone to the network.

Android Side:

The user will control the robot using an android application. The live video feed from the robot will be rendered on the android application. The user will use the phone's accelerometer to control the Bot.

Components: 

Given below is the list of hardware and software components that will be used in the project.

Hardware:
  1. Beaglebone
  2. Belkin F5D7050 Wi-fi adapter
  3. Parallax Boebot 
  4. Webcam
  5. Parallax ping sensors
  6. Android phone
Software:
  1. Angstrom OS for Beaglebone
  2. Gstreamer for streaming
  3. Eclipse and ADT tools
BLOCK DIAGRAM / ARCHITECTURE:


Friday, March 1, 2013

Welcome!

Welcome to our blog. We are a team of 3 students at the University of Pennsylvania, who have undertaken a project to build an Android controlled robot as part of the Embedded systems programming course