Combining Robobuilder with Artificial Neural Networks

Korean company maker of Robot kits and servos designed for of articulated robots. Re-incarnation of Megarobotics.
12 postsPage 1 of 1
12 postsPage 1 of 1

Combining Robobuilder with Artificial Neural Networks

Post by AlexanderHWUK » Mon Mar 29, 2010 7:59 pm

Post by AlexanderHWUK
Mon Mar 29, 2010 7:59 pm

Hello there, long time no see!

I stopped posting in the forums as I had solved my critical problems with the Robobuilder, however I have not stopped working a single day!

This may not be groundbreaking in the Robobuilder field, but its always interesting to see what it can be done with a Robotic platform. I have created a cool interface between the Robobuilder and some C# ANN libraries I obtained from a website (Heaton Research).

Image

With these GUIs, I can:
    - Test the PSD value and change the Distance threshold for testing.
    - Test the Robobuilder using predefined probabilities
    - Load and Save probability values in text files
    - Train an Artificial Neural Network "virtually" (Setting the desired virtual output values), and use its values to test the Robobuilder
    - Train an Artificial Neural Network "manually" (Allowing the Robobuilder to walk around, detecting the objects), and save them for future use
    - Set the different parameters of the ANN (Inputs, Outputs, Epochs, Learning Rate, Training Momentum, Number of Neurons in Hidden layer)


All works in realtime, fully debugged and with lots of error Message boxes!

I am happy to provide the code to anyone interested (C# - Windows Forms and Console app + C# Libraries), and a big thanks to all the people who helped me in this forum to understand how the Robobuilder works, specially l3v3rz and Pedro ;)

Enjoy!

Alex
Hello there, long time no see!

I stopped posting in the forums as I had solved my critical problems with the Robobuilder, however I have not stopped working a single day!

This may not be groundbreaking in the Robobuilder field, but its always interesting to see what it can be done with a Robotic platform. I have created a cool interface between the Robobuilder and some C# ANN libraries I obtained from a website (Heaton Research).

Image

With these GUIs, I can:
    - Test the PSD value and change the Distance threshold for testing.
    - Test the Robobuilder using predefined probabilities
    - Load and Save probability values in text files
    - Train an Artificial Neural Network "virtually" (Setting the desired virtual output values), and use its values to test the Robobuilder
    - Train an Artificial Neural Network "manually" (Allowing the Robobuilder to walk around, detecting the objects), and save them for future use
    - Set the different parameters of the ANN (Inputs, Outputs, Epochs, Learning Rate, Training Momentum, Number of Neurons in Hidden layer)


All works in realtime, fully debugged and with lots of error Message boxes!

I am happy to provide the code to anyone interested (C# - Windows Forms and Console app + C# Libraries), and a big thanks to all the people who helped me in this forum to understand how the Robobuilder works, specially l3v3rz and Pedro ;)

Enjoy!

Alex
AlexanderHWUK offline
Savvy Roboteer
Savvy Roboteer
Posts: 27
Joined: Tue Mar 02, 2010 4:54 pm

Post by l3v3rz » Mon Mar 29, 2010 10:58 pm

Post by l3v3rz
Mon Mar 29, 2010 10:58 pm

Sounds (and looks) really cool. I'd love to get a copy to play with.

Cheers
Sounds (and looks) really cool. I'd love to get a copy to play with.

Cheers
l3v3rz offline
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by scarab » Tue Mar 30, 2010 11:50 am

Post by scarab
Tue Mar 30, 2010 11:50 am

Wow, this looks awesome! I'm a new Robobuilder owner so hopefully I can leverage off your knowledge now! :)

I don't own a Windows machine. but as it's written in C# perhaps it will work with the Mono libraries under Linux?
Wow, this looks awesome! I'm a new Robobuilder owner so hopefully I can leverage off your knowledge now! :)

I don't own a Windows machine. but as it's written in C# perhaps it will work with the Mono libraries under Linux?
scarab offline
Robot Builder
Robot Builder
Posts: 10
Joined: Thu Mar 25, 2010 2:04 pm

Post by AlexanderHWUK » Tue Mar 30, 2010 5:43 pm

Post by AlexanderHWUK
Tue Mar 30, 2010 5:43 pm

Right, done a few changes to the code, and is practically bug safe now.

I have a major presentation this thursday, so I will prefer to keep the code for now, but after that I will pack it up and put it... somewhere.

Actually, any suggestions? Does Robosavvy have any webspace to store stuff like this? If not I can just send it to anyone interested.

For any questions, just ask

Alex
Right, done a few changes to the code, and is practically bug safe now.

I have a major presentation this thursday, so I will prefer to keep the code for now, but after that I will pack it up and put it... somewhere.

Actually, any suggestions? Does Robosavvy have any webspace to store stuff like this? If not I can just send it to anyone interested.

For any questions, just ask

Alex
AlexanderHWUK offline
Savvy Roboteer
Savvy Roboteer
Posts: 27
Joined: Tue Mar 02, 2010 4:54 pm

Post by scarab » Tue Mar 30, 2010 6:56 pm

Post by scarab
Tue Mar 30, 2010 6:56 pm

Why not create yourself a project space on code.google.com and commit your source to that?
Why not create yourself a project space on code.google.com and commit your source to that?
scarab offline
Robot Builder
Robot Builder
Posts: 10
Joined: Thu Mar 25, 2010 2:04 pm

Post by AlexanderHWUK » Tue Mar 30, 2010 7:05 pm

Post by AlexanderHWUK
Tue Mar 30, 2010 7:05 pm

Ok, thanks for the suggestion, I will look into it when I have time ;)

Alex
Ok, thanks for the suggestion, I will look into it when I have time ;)

Alex
AlexanderHWUK offline
Savvy Roboteer
Savvy Roboteer
Posts: 27
Joined: Tue Mar 02, 2010 4:54 pm

Post by l3v3rz » Fri May 14, 2010 5:49 pm

Post by l3v3rz
Fri May 14, 2010 5:49 pm

Hi,

Are you going to upload / make available your source code on this for other people to try ? If you want I'm happy to add you as a contributor to the RobobuilderLib google project ( http://code.google.com/p/robobuilderlib )- so you can add the source (or I'll do it for you if you want).

BTW Ive created a modified foirmware that enable the PSD and accelerometers to be read more quickly - so if your code has a problem with response time from the robot I/we could look to convert to use the DCMP firmware.

cheers
Hi,

Are you going to upload / make available your source code on this for other people to try ? If you want I'm happy to add you as a contributor to the RobobuilderLib google project ( http://code.google.com/p/robobuilderlib )- so you can add the source (or I'll do it for you if you want).

BTW Ive created a modified foirmware that enable the PSD and accelerometers to be read more quickly - so if your code has a problem with response time from the robot I/we could look to convert to use the DCMP firmware.

cheers
l3v3rz offline
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by AlexanderHWUK » Fri May 14, 2010 6:28 pm

Post by AlexanderHWUK
Fri May 14, 2010 6:28 pm

Hello!

Goodness, I was expecting that after finishing the project, I would have enough time to create a google code project and upload everything there!
But time after time I found I was terribly busy, but I've got no excuse now!

Let me check the google code projects and I'll try creating one, so I can upload everything there. If it doesn't work or I can't figure it out then I may take you on your offer ;)

Thanks for the interest!

Alex

Edit: Done!

Created a googlecode project http://code.google.com/p/robobuilderann/ and here you can find all the code (for now its in a winrar file, however I would like to know if you can use subversion or similar in case anyone is interested in editing it).
I'll write something in the wiki explaining how the thing works, but I made a shortcut that can be clicked to start the GUI.
Word of warning! The code was practically finished when I ended the project, however I played around with it a bit afterwards, which may have caused some bugs. However if the Robobuilder is plugged in, and the files are in the right places, everything should work!

Alex
Hello!

Goodness, I was expecting that after finishing the project, I would have enough time to create a google code project and upload everything there!
But time after time I found I was terribly busy, but I've got no excuse now!

Let me check the google code projects and I'll try creating one, so I can upload everything there. If it doesn't work or I can't figure it out then I may take you on your offer ;)

Thanks for the interest!

Alex

Edit: Done!

Created a googlecode project http://code.google.com/p/robobuilderann/ and here you can find all the code (for now its in a winrar file, however I would like to know if you can use subversion or similar in case anyone is interested in editing it).
I'll write something in the wiki explaining how the thing works, but I made a shortcut that can be clicked to start the GUI.
Word of warning! The code was practically finished when I ended the project, however I played around with it a bit afterwards, which may have caused some bugs. However if the Robobuilder is plugged in, and the files are in the right places, everything should work!

Alex
AlexanderHWUK offline
Savvy Roboteer
Savvy Roboteer
Posts: 27
Joined: Tue Mar 02, 2010 4:54 pm

Post by l3v3rz » Fri May 14, 2010 7:52 pm

Post by l3v3rz
Fri May 14, 2010 7:52 pm

Looks a great start - I'm looking forward to having a play with it. (and read your dissertation) - good luck with your exams !

I use http://tortoisesvn.net/. Its an SVN client thats simple to use and integrates nicely with windows. You can see in windows folders if the files are out of date, and then single click will commit all the updates.

If you go to the "source" tab on the project it gives you details of URLs and password to use to check in and out. Any one can extract a read-only dump. I've been really impressed with Google project and I see the bioloid people are starting to use it now as well.

cheers
Looks a great start - I'm looking forward to having a play with it. (and read your dissertation) - good luck with your exams !

I use http://tortoisesvn.net/. Its an SVN client thats simple to use and integrates nicely with windows. You can see in windows folders if the files are out of date, and then single click will commit all the updates.

If you go to the "source" tab on the project it gives you details of URLs and password to use to check in and out. Any one can extract a read-only dump. I've been really impressed with Google project and I see the bioloid people are starting to use it now as well.

cheers
l3v3rz offline
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by l3v3rz » Fri May 14, 2010 7:58 pm

Post by l3v3rz
Fri May 14, 2010 7:58 pm

Incidentally - I'd be interested in your thoughts about how this could be modified to 'train' a robot to balance, using the outputs from the accelerometer - do you think thats possible - and if so what configuration of ANN and type of training would you use ??

I have created a very basic balance program but am now trying to work out how to improve it and ideally self learn. How would a GA stack up against using ANN for instance ?

Any tips welcome

cheers
Incidentally - I'd be interested in your thoughts about how this could be modified to 'train' a robot to balance, using the outputs from the accelerometer - do you think thats possible - and if so what configuration of ANN and type of training would you use ??

I have created a very basic balance program but am now trying to work out how to improve it and ideally self learn. How would a GA stack up against using ANN for instance ?

Any tips welcome

cheers
l3v3rz offline
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by AlexanderHWUK » Fri May 14, 2010 9:42 pm

Post by AlexanderHWUK
Fri May 14, 2010 9:42 pm

Uhm, a very interesting proposal!

To be honest, I had thought of doing a similar thing (teach a robot how to walk) for my project, but when I realised my time constraints I changed it into something more simplistic (detecting obstacles and remembering patterns).

However, keeping balance would be a very interesting problem to solve with an ANN. When comparing ANNs to anything else, you have to think if you have enough data. ANNs are awesome when you have lots and lots of input data (either because you robot can take thousands of measurings a second, or because it can stay on the surface of Mars for a whole year, with lots of rocks).

So to keep balance, you could design a simple ANN (Same structure as the one I used for this project: Sigmoidal Feed-Forward BackPropagation ANN), as they work well for this type of "data" problems. For example, you already know what is bad or good (big accelerations are bad for example, as you don't want the robot to fall, etc.), so you could use a supervised ANN.

Nevertheless, it would be very interesting as well, designing an unsupervised ANN without telling the robot what it must do to keep the balance. I recommend having it attached to a string or something, as it will fall many times this way!

To learn about coding ANNs, I may recommend that you read over the code and libraries in my project, however I would not recommend you to program them as I did. The libraries I used were very "low level", in other words, it actually creates the matrices and everything needed to simulate the ANNs, hardcore style. At the end of the project I have learnt there are other more "high-level" approaches to designing ANNs, even though the way I chose was perfect for learning how an ANN actually works.

Both the libraries and the online course I used to learn how to code ANNs in C# was obtained from Heaton Research. The online course is a little
meh , however the libraries are pretty interesting to have a look at if you already know C#. To be fair it was a pretty crazy coincidence that your code to communicate with the Robobuilder was in C#, it saved me a lot of trouble!

Anyways, to answer your well posed question, I do recommend using an ANN, if you are planning on more complicated learning in the future (Such as combining balance with other sensors) or specially if you don't know much about GA. The BIG advantage of the ANNs in this case is if, you do not know as a programmer, what would keep the Robobuilder upright (It is easy enough to say "If you accelerate in +x, try to move to -x", however that may not be as easy to program when moving servos, or when the robot is walking for example).

So my recommendation is do a simple ANN that can run parallel to the code you send to the robot, and create 2 inputs, 2 outputs. The inputs being the positive and negative directions of an accelerometer axis (You can use one input if you want, but you will have to use an activation function like the Hyperbolic activation func.), and the two outputs being a servo in each arm, to expand & contract depending where it is being pushed from. You will see (if you run it in real time, or obtaining data every 0.2 sec or so) how the robot at the beginning does not know what to do, and will do random stuff when you push it. However, shifting the weight of the robot will affect the acceleration, which if you have supervised it correctly, will learn what arm to move depending of where you push him.

Heh, it may sound as tricky, but it only took a year for me to learn ;) There is just so many possibilities with learning mechanisms, that the only way to find the best one is by experimenting. I find this area very interesting, and if you need any help with research or coding I am happy to help ;)

Alex

P.S. By the way I added you as an owner of my project so you can edit stuff if you want, don't know if it worked
Uhm, a very interesting proposal!

To be honest, I had thought of doing a similar thing (teach a robot how to walk) for my project, but when I realised my time constraints I changed it into something more simplistic (detecting obstacles and remembering patterns).

However, keeping balance would be a very interesting problem to solve with an ANN. When comparing ANNs to anything else, you have to think if you have enough data. ANNs are awesome when you have lots and lots of input data (either because you robot can take thousands of measurings a second, or because it can stay on the surface of Mars for a whole year, with lots of rocks).

So to keep balance, you could design a simple ANN (Same structure as the one I used for this project: Sigmoidal Feed-Forward BackPropagation ANN), as they work well for this type of "data" problems. For example, you already know what is bad or good (big accelerations are bad for example, as you don't want the robot to fall, etc.), so you could use a supervised ANN.

Nevertheless, it would be very interesting as well, designing an unsupervised ANN without telling the robot what it must do to keep the balance. I recommend having it attached to a string or something, as it will fall many times this way!

To learn about coding ANNs, I may recommend that you read over the code and libraries in my project, however I would not recommend you to program them as I did. The libraries I used were very "low level", in other words, it actually creates the matrices and everything needed to simulate the ANNs, hardcore style. At the end of the project I have learnt there are other more "high-level" approaches to designing ANNs, even though the way I chose was perfect for learning how an ANN actually works.

Both the libraries and the online course I used to learn how to code ANNs in C# was obtained from Heaton Research. The online course is a little
meh , however the libraries are pretty interesting to have a look at if you already know C#. To be fair it was a pretty crazy coincidence that your code to communicate with the Robobuilder was in C#, it saved me a lot of trouble!

Anyways, to answer your well posed question, I do recommend using an ANN, if you are planning on more complicated learning in the future (Such as combining balance with other sensors) or specially if you don't know much about GA. The BIG advantage of the ANNs in this case is if, you do not know as a programmer, what would keep the Robobuilder upright (It is easy enough to say "If you accelerate in +x, try to move to -x", however that may not be as easy to program when moving servos, or when the robot is walking for example).

So my recommendation is do a simple ANN that can run parallel to the code you send to the robot, and create 2 inputs, 2 outputs. The inputs being the positive and negative directions of an accelerometer axis (You can use one input if you want, but you will have to use an activation function like the Hyperbolic activation func.), and the two outputs being a servo in each arm, to expand & contract depending where it is being pushed from. You will see (if you run it in real time, or obtaining data every 0.2 sec or so) how the robot at the beginning does not know what to do, and will do random stuff when you push it. However, shifting the weight of the robot will affect the acceleration, which if you have supervised it correctly, will learn what arm to move depending of where you push him.

Heh, it may sound as tricky, but it only took a year for me to learn ;) There is just so many possibilities with learning mechanisms, that the only way to find the best one is by experimenting. I find this area very interesting, and if you need any help with research or coding I am happy to help ;)

Alex

P.S. By the way I added you as an owner of my project so you can edit stuff if you want, don't know if it worked
AlexanderHWUK offline
Savvy Roboteer
Savvy Roboteer
Posts: 27
Joined: Tue Mar 02, 2010 4:54 pm

Post by l3v3rz » Sun May 16, 2010 10:57 am

Post by l3v3rz
Sun May 16, 2010 10:57 am

thanks - great reply.
thanks - great reply.
l3v3rz offline
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm


12 postsPage 1 of 1
12 postsPage 1 of 1
cron