Sunday, 13 January 2013

Controlling servo motors using hand movement (Visual Servoing)



Its been a while since my last entry. My attempts to update this blog more often are to no avail due to the laziness disease which infected me since birth , lack of ideas, and loss of courage, which flowed down the sinkhole. I have no idea what im saying ..really.

Anyway, life are as usual. My latest project i did was to trying to control two servo motors based on the gestures  position of my hand. I did this in order to help two of my student with their FYP. By this, i hope that their project scopes is narrowed, and with that they can start concentrating on other part of the project.

This project consists of using MATLAB as the image processing tools and Arduino UNO to control the movement of the servo.I used Adafruit's motor shield, however it is unnecessary as u can connect two servos directly to the Arduino board. For the webcam, i used Logitech C210 webcam to capture image. Hand position was tracked using simple Background Subtraction method which is quite similar to what i did for my diploma project years ago. In this method, a moving image frame is differentiated with the background image so that only the moving object is produced. The image was then converted from grayscale to a binary image and from there a tracking position of the hand is calculated by simply averaging the white pixels position on both the x-axis and y-axis of the image.This may not track the centroid of the moving object but will give a position near to it.From here the position of the hand is translated into pan-tilt rotation angle using a simple linear conversion and command is sent to the Arduino for servo rotation.

Below is the source code for Arduino:


and here is the source code for MATLAB for acquisition and image processing:



and here is the function required by the above`s source code to calculate the centroid position:



Some lessons learned from this project:

  1. USB can't source enough power to run two servos smoothly . I guess my servo used quite a lot of power. Arduino board keeps getting disconnected from the PC's  USB port every time the servos  make a sudden and fast move. I have to move my hands slowly so that Arduino wouldn't get disconnected. Future improvement: use a powered USB hub or external power supply.
  2. Using delay in Arduino to overcome this effect will worsen the tracking performance. Data from MATLAB will get accumulated in Arduino's buffer and will be read later after the delay.
  3. Different lighting conditions can effect the performance of the tracking system. I have to fiddle round the binary threshold to produce the desired tracking performance (smooth tracking, no noise in the binary image). I used 0.7 in a well lit environment and 0.5 in the opposite.
  4. In MATLAB , use fwrite() instead of fprintf() for serial communication. fprintf() only handle ASCII data 0 ~ 127, limiting  the movement of the servo rotation.


Saturday, 5 May 2012

Thesis writing..

1. Still haven't finish writing my thesis. Damn..this is probably the longest writing i've ever done. Hit the 50 page mark but my supervisor said the thesis needs to be somewhere 100 - 200 pages long.. arghh this thing is killing me!

2. The Avengers was a really good movie!. All of the superheroes were awesome, but Captain America was superb-awesomeness! it kind of reminds me of the game captain America i used to play during my childhood years..and Hulk.. yeaa..that green monster is in-fact indestructible..

3. okay thats it for now, gotta continue wif da thesis writing..

Thursday, 26 April 2012

Damn i need to start writing again..

1) This is the second time i started writing on this blog after a long break. Guess i have to write more often starting from now..present career requires me to do so.

2)Although its already been a month, but i'm married ..Syukur Alhamdullilah!.Married life couldn't be any better.Time to update the current status on this blog.

3)I still have the same old interest...Arduino, Electronics, Robotics , Control Bla..bla...but... i now have a deep interest in automotive technologies, especially automotive electronics.. need to find a project which uses arduino for automotive purposes...

thats it for now... need to write my damn thesis . Dunno when im gonna finish it...

Thursday, 20 January 2011

The Iphone controlled Arduino bot!

Actually, its been a while since i completed this project .Lately, I've been busy with work and study leave matters so i dont have time to upload this project on the net. Anyway, my Arduino robot is powered using Arduino Duemilanove ( i know it is a bit outdated), a wishield from Asynclabs and two toshiba's motorcontroller (TA7291p). Controlling the robot is done using my Iphone with TouchOSC app.




Communication between the iphone and the robot is done via a wifi router and using OSC ( Open Sound Controller ) protocol. All the tedious work of programming OSC protocol is simplified using the OSC library for wishield. Below is the video for this project:



Friday, 14 January 2011

Its been a while!!

Well its been a while now since my last post. Im gonna get this blog up and runnin again!

Monday, 26 October 2009

Yohoo..wake up at 8.00

Today woke up at 8.00 A.M in the morning. A huge success after weeks of sleeping and waking up late. Went to the Lab at 9.00 A.M and met Yoshida Sensei. Today the plan is to help my labmate, Suto-Kun build his Pulley-Belt machine for his research experiment. We planned to finish the pulley mechanism structure before 12.00 but encountered some technical problem . It seems that the Aluminium pulley structure cannot be drilled with a 2mm drill bit and we ended up breaking 3 drill bit during the process. Instead we had to use 3.5 mm drill bit and later fix the axle to the pulley with a screw...what a day.

I haven't yet update my Iphone's OS and plan to do so today. . arghh.. why is it everytime i wanna do something , a lot of problem appeared in my mind, pulling me back..Gosh i guess that is life.

2009-10-26

ahh..the Monday blues..woke up at 1.30 PM today. I think this habit is killing me, seriously. Got to break away from this cycle. Tomorrow got to wake upat 9.00 AM early coz i have a meeting with Yoshida Sensei.
I've been thinking whether i should update my Iphone to OS 3.1 or just leave it to OS 3.0. It seems that OS 3.1 have many new features and many new apps require OS 3.1 to run. But one of the problem that i'm facing is that if i update my iphone the all of my previous cydia apps will be removed and reinstalling them is a bit problematic. I have some cydia apps that i really depend on in my daily life n i dont really want to remove them coz even after reinstalling them back, my previous settings will be resetted. But i guess , i'll should update my phone after all. I'll be posting the method here if it works .