Wall E Robot (object/sound recognition, AI)

Wall E Robot

This project is aimed to bring the Wall E robot from the movie into life! it will have a camera in one of his eyes, the information will be passed and processed in the computer, and commands are then sent via bluetooth back the Wall E robot. It can also recognised sounds, and can be controlled manually as a spy robot.

The source code you see in this project are written in C++ and with Qt Framework and OpenCV library.

=============================================
Flow chart

commands
PC ——–>——–>——–> Robot (Arduino)
PC < ——<——– Bluetooth ——> Air —–> Bluetooth —–> Arduino
Serial
communication

[ 27/08/2012 ] Test 1 – Colour Tracking

[ 05/09/2012 ] Test 2 – Servos and motor driver

[ 08/09/2012 ] Test 3 – Controlling Wall-E from PC

[ 11/09/2012 ] Test 4 – Speech Recognition

=============================================
update 05/08/2012

I will need a easy way to create user interface for the control program, there are a couple of options: SDL, Qt.

SDL the convenient library or tool that handle “Create a Window” , “Load a Image File” , “Play Sound and Music” , “Load Font in ttf Format” , “TCP/IP Protocol” , “Using a Gamepad , a Keyboard , and a Mouse” for you. So you can concentrate on creating your own world with these handy tools. It gives you the relative easy way to make a multi-media windows program.
https://sites.google.com/site/sdlgamer/

Also need to learn how to user serial ports.
The tutorial of Win32 Serial Port Programming
https://sites.google.com/site/arduinorccar/communication

=============================================
update 08/08/2012

I think i have most of the project planned, and come up with quite a few functionalities.

For Object tracking and recognition, I will write the code myself with OpenCV in C++. And the program will run on a PC, images are transmitted from Wall E robot using the wireless Wecam, and after processing the corresponding cammands will be sent back to Wall-E via bluetooth.

I have been looking very hard for programming solution for speech recognition, and hope someone has already wriiten a API or some sort. And Iaccidentally bumpped into a YouTube Video showing a much simpler way of doing this – EasyVR Arduino Shield! So I might use that instead of writing codes myself!

=============================================
update 10/08/2012

wall e robot

Wall E robot arrived! :)
I should have started this week, but just before I was going to take the video for my lastest version of the hexapod robot, one of the servos broke!! I guess i just had to wait…

It’s a great toy for 8’s, it’s only got one motor, which means it can only turn left, or go forward. Moves its hands as well, but that’s pretty much it. Here is a video showing roughly the same one:

http://www.youtube.com/watch?v=VEoh8Iws-kk

=============================================
update 12/08/2012

Still waiting for the servo gear to arrive, I am so bored, so I started working on the robot hardware.

I took it apart and amazed by how well it works considering it’s only got so few components.

It was quite dirty since it’s second hand. I had to wash every piece of it with soup water!
I will leave the assembling another day.

=============================================
update 14/08/2012

Finally found the time to look at the robot pieces and could get started to assemble it.

I recycled the motors and motor driver from my previous robot (Wally Object tracking robot).

It was quite challenging to modify the wall e robot to fit the servos. but i did at the end ^.^.
I will start coding another day!

=============================================
update 17/08/2012

[sourcecode language=”cpp”]

colour tracking code!

capwebcam.read(matOriginal);

if(matOriginal.empty() == true) return;
inRange(matOriginal, cv::Scalar(0,0,175), cv::Scalar(100,100,256), matProcessed);
GaussianBlur(matProcessed, matProcessed, cv::Size(9,9), 1.5);
cv::HoughCircles(matProcessed, vecCircles, CV_HOUGH_GRADIENT, 2, matProcessed.rows/4, 100, 50, 10, 400);

for(itrCircles = vecCircles.begin(); itrCircles != vecCircles.end(); itrCircles++){
ui->txtXYRadius->appendPlainText(QString(“ball position x =”) +
QString::number((*itrCircles)[0]).rightJustified(4, ‘ ‘) +
QString(“, y =”) +
QString::number((*itrCircles)[1]).rightJustified(4, ‘ ‘) +
QString(“, radius =”) +
QString::number((*itrCircles)[2], ‘f’, 3).rightJustified(7, ‘ ‘));

cv::circle(matOriginal, cv::Point((int)(*itrCircles)[0], (int)(*itrCircles)[1]), 3, cv::Scalar(0,255,0), CV_FILLED);
cv::circle(matOriginal, cv::Point((int)(*itrCircles)[0], (int)(*itrCircles)[1]), (int)(*itrCircles)[2], cv::Scalar(0,0,255), 3);

}

// Convert OpenCV image to QImage

cv::cvtColor(matOriginal, matOriginal, CV_BGR2RGB);

QImage qimgOriginal((uchar*)matOriginal.data, matOriginal.cols, matOriginal.rows, matOriginal.step, QImage::Format_RGB888);
QImage qimgProcessed((uchar*)matProcessed.data, matProcessed.cols, matProcessed.rows, matProcessed.step, QImage::Format_Indexed8);

// update label on form

ui->lblOriginal->setPixmap(QPixmap::fromImage(qimgOriginal));
ui->lblProcessed->setPixmap(QPixmap::fromImage(qimgProcessed));

[/sourcecode]

=============================================
update 24/08/2012

The Servo Gear finally arrived! (actually the servo did, i guess they must have send me the wrong thing, ^.^ )

Anyway, i immediately fixed the hexapod robot, and started making the video, hope I can finally begin working on the coding for Wall E robot.

=============================================
update 27/08/2012

As a starting point, I wrote a Qt program to detect colour (red), and send out command via serial port to arduino, to turn Wall E’s head to follow the object. I will extend the object that can be tracked to faces, certain objects, light source etc..

I struggled so much at the beginning, because everytime i connect to arduino via serial port, it freezes the video. I later realized it’s the thread issue. when the program is waiting for data from serial port (or reading, or writing? i am not sure), it actually hangs the thread, so I decided to modify both serialport class, and video class to have their own thread when running.

Some people suggest it’s not a very good idea to use thread if we don’t have a formal education on this subject. And I did find it confusing how to start with thread, because some say we shouldn’t make QThread subclass and we should instead move a object into a thread. But since it’s in the official documentation that we should make it subclass, I followed the latter.

I am still very new to Qt and OpenCV, since I only started learning these a few days back, and I was already thinking about multithreading, and I now realized how crazy that was!

With frustrations, I spent the whole weekend and my bank holiday just debugging the code. I dropped my diet routine, my exercises, and my movies! But I won at the end. Altought it is still not as good as I would expect, tracking is quite slow and inaccurate, and the head shakes a lot, at least it works ^.^

I will look around for some better algorithm, at the meantime might add a few more functionality in the program like adjusting the video properties, and better threading coding…

see you now..

=============================================
update 28/08/2012

The whole reason i spent so much time coding the colour tracking was because, i needed to write a program that does multithreading, and that’s because i need to listen to the serial port for input from arduino while processing video.

I need to confirm arduino has completed the previous command before i send another one out. but still, it’s not fast enough.

I saw someone has done a project similar to this, but he doesn’t listen to signal from arduino, but send out commands from computer every frame he processes. and the result is actually better than mine!

i am thinking, with enough delay between each frame, there might be a possibility that this could work. I can also say good bye to the confusing multi-threading programming too!

I should also stop sending commands when there is nothing detected.

should calculate the middle point of the detected image, so it will work regardless the size of the detected image.

i might try it out tomorrow.

=============================================
update 29/08/2012

So I tried sending commands without feedback signal from arduino, and it works great! I modified the code based on my initial Qt program, using single thread, it wasn’t lagging at all! So now I know what was slowing the program down, must be the ‘serial port data listener’. For whatever reason either I am using it wrong, or by nature it is blocking other processes, I should avoid using it. But in the future when I add the command recognition functionality, I will need to somehow send data back to computer, to run certain applications, for example, if I want Wall-E to track Faces, I would say ‘Wall E, follow faces’, and arduino will send the computer the command, and open ‘track faces application’.

=============================================
update 01/09/2012

Assembling the eye.

=============================================
update 02/09/2012

Improving the Tracking computer programs:

1. options to the device.2. options to each object tracking.
this is very useful when it comes to camera devices: http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=cv_cap_prop_contrast
re-writing the colour tracking algorithm, here is how it works in the new version:

1. Preprocess the image using cv::inRange(), with necessary colour bounds to isolate a desired colour. It might be a good idea to transform to a color-space like HSV or YCbCr for more stable color bounds because chrominance and luminance are better separated. You can use cvtColor() for this. I imagine we will only need to worry about the Hue and Saturation channels as the Value channel doesn’t contain any color info (i.e., the Value range would be left untouched [0, 255]).

link to cv::cvtColor()

http://opencv.willowgarage.com/documentation/cpp/miscellaneous_image_transformations.html

but how to determine the min/max colour boundries?

2. smooth the image (pre-process) with GuassianBlur to get rid of some of the jagginess. I used a bigger dilation kernel than erosion kernel (5×5 vs. 3×3) to get rid of some noisy pixels. The smoothing might help this also tweaking the thresholds could make the erosion unnecessary.

3. compare sizes if multiple objects detected, choose the biggest one.

=============================================
update 05/09/2012

Finally I have some time to sit down and continue my project! I finished the inside layout and tidied up all the cablings tonight. I Also tested the servos and motor driver, all seem working fine!

But i just have to say how much i hate soldering right now!! I literally spent 2 hours trying to solder a switch to some long cables. The first try, i found the cables was a bit out of contacts, so I put hot glue to stick them together, didn’t help. So I tried very hard, to take the glue off, and replace all the cables with new ones, and soldered again.

This time was better. I then installed it on the robot, and hot-glued it on. Only found that the switch itself isn’t working properly, I have to occasionally push the plastic bit. I guess i might have damaged the switch when I was taking the hot glue off…

There is a reason I love programming so much! When I was at Uni doing projects, I always left all the soldering and cabling works to my lab partner, and I would take care of all the coding and maths. I just don’t have the hands to do these things i guess… :(

=============================================
update 08/09/2012

We can now control Wall E robot from PC.

We can also use it as a spy robot :)

=============================================
update 11/09/2012

Added Speech recognition, so i can now control wall-e with my voice.

I am using EasyVR arudino Shield. The shield is great, easy to use, and work quite well actually. But it’s intolerate to background noise, even it’s just a little.

At first, I trained the robot with commands, and it’s all working fine. But when I switched on the robot, it starts ignoring my commands, being unresponsive. I later realize it’s the noise from the servo and motor that interferes the input from the Mic.

So I re-trained the robot with the motor and servos on, to simulate the noisy environment. And really, it works much better, although still not ideal.

To conclude, I don’t recommend using EasyVR on a robot that is sitting next to servos and motors, or operate in a noisy environment.

For future work, i will migrate the speech recognition to the computer site, and send commands via bluetooth. (actually that’s even better because now I don’t need to send signal back from Wall E robot to computer anymore, so communication will be strickly one way, see last few updates about the bluetooth listener issue)

Source Code Download And Fund Raising

To raise money for new robot parts and the time spent on improving the codes, I am starting a fund raise for this project. To say thank you, anyone who donate more than $10, I will send you the source code of this project, and any future update version of the source code.

Amount does not matter, every little helps. You can donate through paypal via the link below (Donate button).
Thank you!

19 thoughts on “Wall E Robot (object/sound recognition, AI)

  1. Stephine

    Hi! Good day! Sir, I would like to ask help from you. I am actually building a project that is almost same concept as yours but for some reasons, I can’t ask the codes from you ‘coz of your terms and conditions that I must need to donate atleast $10. I’m actually I’m just a poor guy that needs to finish my studies and I need to make a proposal. So if you don’t mind sir please do send me a mail if we could make some other conditions aside from using money.

    Reply
  2. Maurizio

    Hi Oscar,
    Many thanks for this cool conversion project for pixar Wall-E!
    Just donated 10 euros via paypal to your account to say thank you and support your great projects…. it’s a pleasure to read about them on your blog ^^
    Now I’m hoping to get arduino code/stuff as for Wall-E soon and start to build mine!

    I follow you! ^^
    greetings from Italy!
    Nasoftz

    Reply
  3. San

    Hi Oscar,

    I really want to build this project and I am shopping WALL-E online. Would you mind providing which model is it? Turns out that there are multiple version of remote controlled WALL-E on the market.

    Really appreciate it.
    Thanks
    San

    Reply
  4. Frederic

    Hi Oscar,
    another great gadget you built/modded, thank you.
    I´m still figuring out the hexapod code so I don´t need another new project yet but Wall-E is my kids all-time favourite movie robot (Johnny 5 left aside, who he is the Uber-robot but just out of my price range big time).

    But cheers for the great instructables!
    Frederic

    Reply
    1. Oscar Post author

      Hi Frederic
      Same here! I really enjoyed building this robot! wish i have more time to keep working on my Wall-E… he’s still sitting in my bedroom :D

      Reply
  5. Mike

    Hi Oscar

    Just came across this post as I was going to start my own project with Wall-e. Then I started exploring the quadcopter tutorials – absolutely great stuff. Getting ready to retire so I am lining up my projects. I hope the offer still holds for a copy of the software for wall-e. Love moding code – makes life easier. Either way just donated 10 lbs via paypal to support the site.

    Thanks for posting this great stuff.

    Reply
  6. Dj_Garfield

    Amazing project !!! Even if it dates a little , how goes Mr Wall E ?
    You made a very big thing , but you still have to teach him to dance :) HAHA :)

    Reply
    1. Oscar Post author

      haha… wall-E is standing at the corner in my room, staring at me when i am busy building quadcopters :D
      Poor wall-E ….

      Reply
  7. Frank

    Hi!

    Thanks for your great explanation and congratulations for this project!

    I was checking at ebay.com this Wall-E toy but I’m not sure which one can be useful as the cheap look like the tracks can’t move, and the ones that move are expensive… could you tell me which can I select? Thanks!

    Kind regards
    Frank

    Reply
    1. Oscar Post author

      To be honest, I didn’t know which wall-e toy to buy, because I had no idea! the one I have is a random second hand toy I bough from ebay, only costed me $5. But that was almost two years ago…
      I think any wall-e toy with a wired remote control should work. but make sure the size is big enough to put servos, arduino board, and battery in it.

      Reply
  8. Fadi

    It is a great effort ….. thank you very much for sharing.
    Actually I am a beginner in this domain and I will be a gratitude if you can provide the list of parts that you use …:(

    Reply
      1. saran raj

        Hi Oscar
        hey i am new to this domain i doing my final year project in this domain so plaese help me to do that .
        my first problem is how to find the object using image then how can i give input to motors

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you Robot? *

I only check blog comments once or twice a week, if you want a quick reply you can post your question on this forum IntoFPV.com... You might get a faster response from me there (multirotor related only).