Sample C Coding files and instructions for Robobuilder 57xx

Korean company maker of Robot kits and servos designed for of articulated robots. Re-incarnation of Megarobotics.
17 postsPage 1 of 21, 2
17 postsPage 1 of 21, 2

Sample C Coding files and instructions for Robobuilder 57xx

Post by PedroR » Sat Feb 28, 2009 1:42 am

Post by PedroR
Sat Feb 28, 2009 1:42 am

Hi All

I just installed the software from a recent Robobuilder CD and found a folder called C coding.

I am not sure if this was part of the first CDs that shipped but it is definitely something worth looking at.

I have been watching the excellent progress you have been doing with your own custom implementation/library for Robobuilder :)
This is nowhere near that complete but I believe it may be of interest to look at it, specially for beginners who want to start coding in C.

The PDF file with the explanation is here
http://robosavvy.com/Builders/PedroR/C% ... 20file.pdf

A ZIP file with all the contents is here
http://robosavvy.com/Builders/PedroR/C_programming.zip

The ZIP file includes a full implementation of a C program and you only need to add the exported motion file and compile.


============================================
EDIT / UPDATE:
============================================
This post explains the native implementation of the C code by the manufacturer (Robobuilder).
The community members have further extended this code and added support for sensors, etc.
The thread for the extended version can be found here http://robosavvy.com/forum/viewtopic.ph ... c&start=15



EDIT 2 / UPDATE 2:
============================================
Robobuilder has released the SOURCE CODE for their firmware
.
The code is available here
http://robosavvy.com/RoboSavvyPages/Rob ... Source.zip

and implements almost all the features in the firmware:
- Included "HUNO, DINO, DOGY" basic motions
- Included Battery charging function
- Supported RBC protocols
- Zero position
- PC control mode
- Read firmware version
- Run Motion
- Play Sound
- Read Distance
- Read Sound Input
- Read Button Input
- Read Acceleration sensor value

A document with activities and explanations has also been released. Please look through this thread and you'll find it further down.

============================================
Hi All

I just installed the software from a recent Robobuilder CD and found a folder called C coding.

I am not sure if this was part of the first CDs that shipped but it is definitely something worth looking at.

I have been watching the excellent progress you have been doing with your own custom implementation/library for Robobuilder :)
This is nowhere near that complete but I believe it may be of interest to look at it, specially for beginners who want to start coding in C.

The PDF file with the explanation is here
http://robosavvy.com/Builders/PedroR/C% ... 20file.pdf

A ZIP file with all the contents is here
http://robosavvy.com/Builders/PedroR/C_programming.zip

The ZIP file includes a full implementation of a C program and you only need to add the exported motion file and compile.


============================================
EDIT / UPDATE:
============================================
This post explains the native implementation of the C code by the manufacturer (Robobuilder).
The community members have further extended this code and added support for sensors, etc.
The thread for the extended version can be found here http://robosavvy.com/forum/viewtopic.ph ... c&start=15



EDIT 2 / UPDATE 2:
============================================
Robobuilder has released the SOURCE CODE for their firmware
.
The code is available here
http://robosavvy.com/RoboSavvyPages/Rob ... Source.zip

and implements almost all the features in the firmware:
- Included "HUNO, DINO, DOGY" basic motions
- Included Battery charging function
- Supported RBC protocols
- Zero position
- PC control mode
- Read firmware version
- Run Motion
- Play Sound
- Read Distance
- Read Sound Input
- Read Button Input
- Read Acceleration sensor value

A document with activities and explanations has also been released. Please look through this thread and you'll find it further down.

============================================
Last edited by PedroR on Wed Oct 03, 2012 2:55 pm, edited 6 times in total.
PedroR offline
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Post by i-Bot » Sat Feb 28, 2009 11:52 am

Post by i-Bot
Sat Feb 28, 2009 11:52 am

Hi Pedro,

I didn't check if this is an update, but this was the basis of the current C code for the RBC which we have worked on.

I simply changed to use AVR Studio and avr-gcc instead of Codevision AVR. This also required some defines to ensure the header files from Motionbuilder could be used. Also used some functions from the Procyon AVR library to help in the debug.

Later I added the routine for the IR controller.

Since then the versions from l3v3rv have added support for the other sensors, but I think still have a strong base on the Robobuilder provided source.
Hi Pedro,

I didn't check if this is an update, but this was the basis of the current C code for the RBC which we have worked on.

I simply changed to use AVR Studio and avr-gcc instead of Codevision AVR. This also required some defines to ensure the header files from Motionbuilder could be used. Also used some functions from the Procyon AVR library to help in the debug.

Later I added the routine for the IR controller.

Since then the versions from l3v3rv have added support for the other sensors, but I think still have a strong base on the Robobuilder provided source.
i-Bot offline
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by l3v3rz » Sat Feb 28, 2009 4:10 pm

Post by l3v3rz
Sat Feb 28, 2009 4:10 pm

Yes, still very much based on i-bots port which has a major advantage that you can download the free open source tool chain.

I've added support for the PSD and the accelerometer and a simple terminal based menu interface. It now supports 18 different motions including some soccer related ones which I'm interested in trying to link with PC based webcam.

There's now a google code project http://code.google.com/p/robobuilderlib/ so its under version control. Any one who wants to join - just send me or joe your google ID. (Please join!! :) )

cheers
Yes, still very much based on i-bots port which has a major advantage that you can download the free open source tool chain.

I've added support for the PSD and the accelerometer and a simple terminal based menu interface. It now supports 18 different motions including some soccer related ones which I'm interested in trying to link with PC based webcam.

There's now a google code project http://code.google.com/p/robobuilderlib/ so its under version control. Any one who wants to join - just send me or joe your google ID. (Please join!! :) )

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

Post by PedroR » Sat Feb 28, 2009 4:16 pm

Post by PedroR
Sat Feb 28, 2009 4:16 pm

Hi all

Sorry if I generated any confusion.
It was not my intention at all.

I had not understood that this was the base of your code.
Every time I installed Robobuilder software I downloaded the latest version from the Website. It was only yesterday that I performed a full install from a CD and discovered this.....

I didn't realize this was already the base of your code.

Anyway, I will keep the post here just as a mention to "the original/official implementation" but I will edit the post to mention your own customized/extended versions.

Thanks and once again I apologise if I generated any confusion.
Hi all

Sorry if I generated any confusion.
It was not my intention at all.

I had not understood that this was the base of your code.
Every time I installed Robobuilder software I downloaded the latest version from the Website. It was only yesterday that I performed a full install from a CD and discovered this.....

I didn't realize this was already the base of your code.

Anyway, I will keep the post here just as a mention to "the original/official implementation" but I will edit the post to mention your own customized/extended versions.

Thanks and once again I apologise if I generated any confusion.
PedroR offline
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Post by PedroR » Sat Feb 28, 2009 11:44 pm

Post by PedroR
Sat Feb 28, 2009 11:44 pm

hi l3v3rz

If you'd like I can work on a PC library to make simple BLOB detection.
I have already collected a lot of material as I wanted to do that myself and can code it in relatively short time.
My idea would be to set a colour to look for and tolerance threshold and return the blobs that are found. That's the way the HaViMo camera for Bioloid does it and it's fairly successfully in Robot Soccer.

Also, if there was the possibility to add an instruction to the firmware that let us talk to the servo bus that would be excellent. Something like the PC Control Mode of the native firmware.
I don't really have the expertise on ATMEGA 128 to do it otherwise I would contribute it myself.

Either implement an instruction to change it to full pc control mode or implement and instruction that sends the specified bytes and returns the number of bytes we want (IDEAL).
Lets say, a command like
servobus 0x21 0x23 0x26 0x78, 2
This would tell it to put bytes 0x21 0x23 0x26 0x78 and then return the next "2" bytes received (which would be the answer)
I would need to establish a timeout in case we are querying an in existent servo (which will never return the expected 2 bytes) but other than that it would really unleash a LOT of power in terms of sharing the control between the ATMEGA and the PC.

More complex stuff could then be done without the need to revert back to the native firmware like changing servo id's,setting up PID gains, querying servos, etc etc
hi l3v3rz

If you'd like I can work on a PC library to make simple BLOB detection.
I have already collected a lot of material as I wanted to do that myself and can code it in relatively short time.
My idea would be to set a colour to look for and tolerance threshold and return the blobs that are found. That's the way the HaViMo camera for Bioloid does it and it's fairly successfully in Robot Soccer.

Also, if there was the possibility to add an instruction to the firmware that let us talk to the servo bus that would be excellent. Something like the PC Control Mode of the native firmware.
I don't really have the expertise on ATMEGA 128 to do it otherwise I would contribute it myself.

Either implement an instruction to change it to full pc control mode or implement and instruction that sends the specified bytes and returns the number of bytes we want (IDEAL).
Lets say, a command like
servobus 0x21 0x23 0x26 0x78, 2
This would tell it to put bytes 0x21 0x23 0x26 0x78 and then return the next "2" bytes received (which would be the answer)
I would need to establish a timeout in case we are querying an in existent servo (which will never return the expected 2 bytes) but other than that it would really unleash a LOT of power in terms of sharing the control between the ATMEGA and the PC.

More complex stuff could then be done without the need to revert back to the native firmware like changing servo id's,setting up PID gains, querying servos, etc etc
PedroR offline
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Post by l3v3rz » Sun Mar 01, 2009 1:05 am

Post by l3v3rz
Sun Mar 01, 2009 1:05 am

The servobus should be straightforward. Might change the API a bit to simply

X0421222324 = Xtranmit 4 bytes, 21,22,23,24

I think the response is always 2 bytes

Look for it in the next release in the next few days

The blob stuff sounds good, I use the Aforge to capture the image from the webcam and was looking to use its template library, but I'll post my .NET code soon as well

cheers
The servobus should be straightforward. Might change the API a bit to simply

X0421222324 = Xtranmit 4 bytes, 21,22,23,24

I think the response is always 2 bytes

Look for it in the next release in the next few days

The blob stuff sounds good, I use the Aforge to capture the image from the webcam and was looking to use its template library, but I'll post my .NET code soon as well

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

Post by PedroR » Sun Mar 01, 2009 9:15 pm

Post by PedroR
Sun Mar 01, 2009 9:15 pm

hey l3v3rz

Your API proposal seems a lot better/simpler :)

With regards to the number of bytes returned please note it is not always 2.
IF the instruction returns a packet, it is 2 bytes always.
BUT there are instructions that do not return any packet: in particular the Synchronized Position move and the Runtime Speed Set.
A summary of this can be found on the last page (71) of the wCK manual.
The right column in the table shows which packets are returned by the instructions (and what is their meaning).

Thank you very much for all your work and support.
I will probably port my wCK DLL library and Remocon DLL to your new firmware and merge them in a super class :idea:

I think that once support for this is added the only thing missing to make a full, much improved firmware, is a battery charging routine right?
I found some data on that here http://www.edaboard.com/ftopic273063.html but I can't really understand most of it though......
hey l3v3rz

Your API proposal seems a lot better/simpler :)

With regards to the number of bytes returned please note it is not always 2.
IF the instruction returns a packet, it is 2 bytes always.
BUT there are instructions that do not return any packet: in particular the Synchronized Position move and the Runtime Speed Set.
A summary of this can be found on the last page (71) of the wCK manual.
The right column in the table shows which packets are returned by the instructions (and what is their meaning).

Thank you very much for all your work and support.
I will probably port my wCK DLL library and Remocon DLL to your new firmware and merge them in a super class :idea:

I think that once support for this is added the only thing missing to make a full, much improved firmware, is a battery charging routine right?
I found some data on that here http://www.edaboard.com/ftopic273063.html but I can't really understand most of it though......
PedroR offline
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Post by l3v3rz » Mon Mar 02, 2009 1:24 am

Post by l3v3rz
Mon Mar 02, 2009 1:24 am

OK - thanks for that.

I've now two variants of theat command, 'x' (lowercase) that waits for and displays a response, and 'X' (uppercase) that just sends with no wait. I'm begining to look at charging but its complex as you must ensure the battery is not overcharged as it can overheat and cause damage - hence my caution.

hex file for r15 is now available from the http://code.google.com/p/robobuilderlib

If also created a second project called robobuildervc that has my .NET code based client.

regards
OK - thanks for that.

I've now two variants of theat command, 'x' (lowercase) that waits for and displays a response, and 'X' (uppercase) that just sends with no wait. I'm begining to look at charging but its complex as you must ensure the battery is not overcharged as it can overheat and cause damage - hence my caution.

hex file for r15 is now available from the http://code.google.com/p/robobuilderlib

If also created a second project called robobuildervc that has my .NET code based client.

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

Post by PedroR » Mon Mar 02, 2009 2:13 am

Post by PedroR
Mon Mar 02, 2009 2:13 am

there is an added level of complexity here which is the cases where we are querying an inexistent/disconnected servo.

let's say I query the position of servo 1. I send the packet and wait for a response with 2 bytes.
In case servo 1 is disconnected those 2 bytes will never arrive hence locking the program.... maybe a conservative timeout solves this problem. please be aware that depending on the instruction you send the delay between sending the packet and getting the response is different.

Page 25 of the wCk manual details that. I believe the longest is 121145 but they don't mention which units this is....
there is an added level of complexity here which is the cases where we are querying an inexistent/disconnected servo.

let's say I query the position of servo 1. I send the packet and wait for a response with 2 bytes.
In case servo 1 is disconnected those 2 bytes will never arrive hence locking the program.... maybe a conservative timeout solves this problem. please be aware that depending on the instruction you send the delay between sending the packet and getting the response is different.

Page 25 of the wCk manual details that. I believe the longest is 121145 but they don't mention which units this is....
PedroR offline
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Post by limor » Wed Oct 14, 2009 10:32 am

Post by limor
Wed Oct 14, 2009 10:32 am

Robobuilder has released the SOURCE CODE for their firmware.
The code is available here
http://robosavvy.com/RoboSavvyPages/Rob ... Source.zip

and implements almost all the features in the firmware:
- Included "HUNO, DINO, DOGY" basic motions
- Included Battery charging function
- Supported RBC protocols
- Zero position
- PC control mode
- Read firmware version
- Run Motion
- Play Sound
- Read Distance
- Read Sound Input
- Read Button Input
- Read Acceleration sensor value


Following up to the release of the source code, they have release a 70-page document describing the C development environment and API together with 10 detailed projects.

http://robosavvy.com/RoboSavvyPages/Rob ... Source.zip

Image
Robobuilder has released the SOURCE CODE for their firmware.
The code is available here
http://robosavvy.com/RoboSavvyPages/Rob ... Source.zip

and implements almost all the features in the firmware:
- Included "HUNO, DINO, DOGY" basic motions
- Included Battery charging function
- Supported RBC protocols
- Zero position
- PC control mode
- Read firmware version
- Run Motion
- Play Sound
- Read Distance
- Read Sound Input
- Read Button Input
- Read Acceleration sensor value


Following up to the release of the source code, they have release a 70-page document describing the C development environment and API together with 10 detailed projects.

http://robosavvy.com/RoboSavvyPages/Rob ... Source.zip

Image
limor offline
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK

undefined symbol 'g10MSEC'

Post by ebrand » Mon Mar 15, 2010 9:38 pm

Post by ebrand
Mon Mar 15, 2010 9:38 pm

I am currently using CodeVisionAVR and cannot get rid of the following error without changing the code. Its like my c files aren't connecting with my main file during build:

Error: C:\...\robobuilder_2nd_Ccode\src\comm.c(55): undefined symbol 'g10MSEC'
Error: C:\...\src\comm.c(88): undefined symbol 'gTx0Buf'

Any ideas what I could be doing wrong? I get this error in the first and second versions of the C code tutorials.

My goal is to get Robobuilder to go through a maze using just the chip and not his bluetooth or the serial port. If it is completely hopeless trying to use the C code from the tutorial, will the library built by the community work for a maze?

Thanks in advance!
I am currently using CodeVisionAVR and cannot get rid of the following error without changing the code. Its like my c files aren't connecting with my main file during build:

Error: C:\...\robobuilder_2nd_Ccode\src\comm.c(55): undefined symbol 'g10MSEC'
Error: C:\...\src\comm.c(88): undefined symbol 'gTx0Buf'

Any ideas what I could be doing wrong? I get this error in the first and second versions of the C code tutorials.

My goal is to get Robobuilder to go through a maze using just the chip and not his bluetooth or the serial port. If it is completely hopeless trying to use the C code from the tutorial, will the library built by the community work for a maze?

Thanks in advance!
ebrand offline
Robot Builder
Robot Builder
Posts: 9
Joined: Mon Mar 15, 2010 9:32 pm

Post by i-Bot » Mon Mar 15, 2010 11:29 pm

Post by i-Bot
Mon Mar 15, 2010 11:29 pm

I have not used codevision, but it should work OK for your project.

The codevision early versions compiled all source .c file simultaneously, so there was no need to define variables in files as external. Later versions complile the .c file seperate, so you might get problems as you describe. You need to define the global variables giving a problem as extern in the comm.c , so they are resolved later by the linker.
I have not used codevision, but it should work OK for your project.

The codevision early versions compiled all source .c file simultaneously, so there was no need to define variables in files as external. Later versions complile the .c file seperate, so you might get problems as you describe. You need to define the global variables giving a problem as extern in the comm.c , so they are resolved later by the linker.
i-Bot offline
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by l3v3rz » Mon Mar 15, 2010 11:35 pm

Post by l3v3rz
Mon Mar 15, 2010 11:35 pm

Are you using the full version of CV AVR V2 ? or the evaluation edition ?- its 3K limit I think causes problems when you link.
Are you using the full version of CV AVR V2 ? or the evaluation edition ?- its 3K limit I think causes problems when you link.
l3v3rz offline
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

CodeVision Version

Post by ebrand » Tue Mar 16, 2010 12:05 am

Post by ebrand
Tue Mar 16, 2010 12:05 am

I am using CodeVisionAVR 2.04.4a Advanced. So how do I get the structs to be external then? I was able to get rid of all of the errors except for ones revolving around structs. I still have a bit of trouble with scopes in C.
I am using CodeVisionAVR 2.04.4a Advanced. So how do I get the structs to be external then? I was able to get rid of all of the errors except for ones revolving around structs. I still have a bit of trouble with scopes in C.
ebrand offline
Robot Builder
Robot Builder
Posts: 9
Joined: Mon Mar 15, 2010 9:32 pm

just combined all of the files

Post by ebrand » Tue Mar 16, 2010 4:06 am

Post by ebrand
Tue Mar 16, 2010 4:06 am

I gave up on trying to link all the files together and just put them all in main.c. The problem I'm getting now is the following:

Error: C:\...\maze.c(2391): a value of type 'flash unsigned char [9][16]' can't be assigned to an entity of type 'flash unsigned char *'

Anyone else have this problem or know how to fix it?
I gave up on trying to link all the files together and just put them all in main.c. The problem I'm getting now is the following:

Error: C:\...\maze.c(2391): a value of type 'flash unsigned char [9][16]' can't be assigned to an entity of type 'flash unsigned char *'

Anyone else have this problem or know how to fix it?
ebrand offline
Robot Builder
Robot Builder
Posts: 9
Joined: Mon Mar 15, 2010 9:32 pm

Next
Next
17 postsPage 1 of 21, 2
17 postsPage 1 of 21, 2
cron