Home

Main Menu

Who's Online

We have 3 guests and 3 members online
  • xx2747
  • Khashi.E
  • ries

Login Form






Lost Password?
No account yet? Register
Welcome ( Log in )
libavr/libbioloid C library for CM5 released!
Goto page 1, 2, 3 ... 11, 12, 13  Next
 
Post new topic   Reply to topic    RoboSavvy Forum Forum Index -> Bioloid & Robotis
View previous topic :: View next topic  
Author Message
StuartL
Savvy Roboteer
Savvy Roboteer


Joined: 04 Jun 2007
Posts: 348
Location: Thatcham, Berkshire, UK

PostPosted: Tue Dec 16, 2008 10:29 am    Post subject: libavr/libbioloid C library for CM5 released! Reply with quote

Finally Matt and I have released the C library for CM5 development.

Right now there's not much documentation but the example.c should be fairly self explanatory.

Dependencies:
- A working GCC and MAKE for the HOST operating system. For Windows I suggest Cygwin or MINGW. Linux probably already has this installed.
- A working GCC-AVR for the TARGET platform. Note that the CM5 is an ATmega128 so most of the recent AVR gcc targets will work.

Installation:
- Install Cygwin/MINGW/some other gcc/make combo.
- Install gcc AVR.
- Download both the libavr and libbioloid tgz files from the URL below.
- Go into the 'example' directory and type 'make'.
- Let me know if anything untoward happens.
- Transfer the .hex file to your CM5 and use the q, a, w and s keys to move servos 1 and 2 around.
- Join the distribution list to discuss any problems or feature requests.

All files are available at http://www.braincell.cx/bioloid/dist/. I would very much like to know who is downloading it just so we can get a feel for how many people are using different bits of the API when we start evolving the interface.

The distribution list can be joined by emailing the list robot at ecartis at (the domain) braincell dot cx with the command 'subscribe robots'. You will need to reply to the email you receive to confirm the subscription to the list.
Back to top
View user's profile Send private message  
limor
Savvy Roboteer
Savvy Roboteer


Joined: 11 Oct 2004
Posts: 1155
Location: London, UK

PostPosted: Tue Dec 16, 2008 8:40 pm    Post subject: Reply with quote

I looked at the example.c and it looks like programming the CM5 and communicating with the servos has become much easier than ever before. I dont have the Bioloid with me to test now but i will give it a go the next couple of weeks.

One question about the syntax.. I don't recall seeing before a statement in C such as [number] = {..list..}

Code:
    static struct dx_stance s = { 0, { [23] = { DX_NOID, 0 } } };


Question
Back to top
View user's profile Send private message   MSN Messenger
StuartL
Savvy Roboteer
Savvy Roboteer


Joined: 04 Jun 2007
Posts: 348
Location: Thatcham, Berkshire, UK

PostPosted: Tue Dec 16, 2008 9:10 pm    Post subject: Reply with quote

limor wrote:
I looked at the example.c and it looks like programming the CM5 and communicating with the servos has become much easier than ever before. I dont have the Bioloid with me to test now but i will give it a go the next couple of weeks.


Thank you! We've worked very hard on that, and as you'll see from the changelog Matt in particular has contributed a HUGE amount to the repository recently. We wanted to be able to develop high performance software for the Bioloid without having to work at the low levels.

Quote:
One question about the syntax.. I don't recall seeing before a statement in C such as [number] = {..list..}

Code:
    static struct dx_stance s = { 0, { [23] = { DX_NOID, 0 } } };


Question


That's actually a lot easier to understand if you open it out. Firstly the dx_stance structure looks like this:

Code:
struct dx_servo {
    uint8_t id;
    int position;
};

struct dx_stance {
    uint8_t junk;
    struct dx_servo servo[]; // last item in the list should have id=DX_NOID
};


The 'junk' parameter is to avoid compiler bugs with variable length structures. Otherwise, in the stance, there's an array of servo structures.

Code:
static struct dx_stance s = {
    0, // Junk
    { [23] = { DX_NOID, 0 } } // Initialises element 23 of the servo array of structures to the two values DX_NOID and zero.
};


Because element 23 is initialised to those values by implication the compiler must have allocated 0-22 (i.e. 23 other elements in the list). The startup code created by gcc-avr actually allocates these statically from the 4k RAM in the MCU and initialises them all to zero, with element 23 containing the ID of DX_NOID which the library knows to mean is the end of the array.
Back to top
View user's profile Send private message  
limor
Savvy Roboteer
Savvy Roboteer


Joined: 11 Oct 2004
Posts: 1155
Location: London, UK

PostPosted: Tue Dec 16, 2008 9:26 pm    Post subject: Reply with quote

thanks
I've only been using C for 26 years.
it's great to learn a new trick
Laughing
Back to top
View user's profile Send private message   MSN Messenger
billyzelsnack
Savvy Roboteer
Savvy Roboteer


Joined: 30 Dec 2006
Posts: 330

PostPosted: Wed Dec 17, 2008 5:35 am    Post subject: Reply with quote

You got me beat limor. I've got just 20 something years of C and I've not seen it either.
Back to top
View user's profile Send private message   Visit poster's website
BillB
Savvy Roboteer
Savvy Roboteer


Joined: 06 Aug 2006
Posts: 225
Location: Hampshire, UK

PostPosted: Wed Dec 17, 2008 8:53 am    Post subject: Reply with quote

Yipee - now programing the CM5 has become a whole lot easier.

Thank you Matt, Thank you StuartL. Thank you, thank you thank you.
Back to top
View user's profile Send private message  
BillB
Savvy Roboteer
Savvy Roboteer


Joined: 06 Aug 2006
Posts: 225
Location: Hampshire, UK

PostPosted: Wed Dec 17, 2008 9:48 am    Post subject: Reply with quote

I have just tried to make the example. But the make failed because it could notfind the file: "trig_tables.c".

I can find a "make_trig_tables.c" file but no "trig_tables.c" file

Any suggestions? Would simply renaming "make_trig_tables.c" to "trig_tables.c" do the trick?
Back to top
View user's profile Send private message  
StuartL
Savvy Roboteer
Savvy Roboteer


Joined: 04 Jun 2007
Posts: 348
Location: Thatcham, Berkshire, UK

PostPosted: Wed Dec 17, 2008 10:54 am    Post subject: Reply with quote

BillB wrote:
I have just tried to make the example. But the make failed because it could notfind the file: "trig_tables.c".


This probably means that the local gcc doesn't work. The trig tables are calculated at compile time and need to compile make_trig_table.c into make_trig_table.exe which is then used to generate trig_tables.c, used by the gccavr compiler to link in the now "statically" defined trig tables.

Try a manual compilation as follows:

Code:
gcc -o make_trig_tables make_trig_tables.c
Back to top
View user's profile Send private message  
BillB
Savvy Roboteer
Savvy Roboteer


Joined: 06 Aug 2006
Posts: 225
Location: Hampshire, UK

PostPosted: Wed Dec 17, 2008 5:47 pm    Post subject: Reply with quote

Thank you Stuart for helping me out with the compile problem. I abandoned trying to compile on my PC - and it compiled first time with no errors on my Mac.

Still getting to grips with the code though. The example appears straight forward and demonstrates how easy you and Matt have made it to access and control the Dynamixels.

Upon running the compiled .hex file on a CM5 I noticed that if you press a key before you reach the infinate while loop you will reach a menu. Upon examining your code library it appears that this menu is part of the "Supervisor" (sounds like something from the Matrix Smile ). The supervisor has already proved very useful (for reconfiguring Dynamixel Id's).

My question is that I cannot see where in the Example.c code the Supervisor is involved. It appears to be before the main(). Could you please point out to me where the supervisor is started/initiated.

Apologies if this is a silly C question- my C is a bit rusty after 15 years of neglect.
Back to top
View user's profile Send private message  
StuartL
Savvy Roboteer
Savvy Roboteer


Joined: 04 Jun 2007
Posts: 348
Location: Thatcham, Berkshire, UK

PostPosted: Wed Dec 17, 2008 6:04 pm    Post subject: Reply with quote

The key hook is done in libbioloid/bioloid/cm5.c at line 21 where cm5_init is set to appear in section ".init8". This gets called before 'main' and therefore ensures that all the library initialisation routines get called before the user application. It's the linker that makes sure that .init8 gets called between .init7 and .init9 and that main() gets called after .init9.

The supervisor has a lot of convenient features. As well as letting you renumber dynamixels you can also reset them (handy if the eeprom gets corrupted), scan the bus for devices, read and write memory locations and (the reason for initially writing it) it checks that your robot complies with the 'robot' definition before letting main() run, making sure you don't end up running the wrong software on the wrong robot or trying to run code when a servo has been renumbered.
Back to top
View user's profile Send private message  
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer


Joined: 08 Aug 2007
Posts: 205
Location: Barcelona

PostPosted: Wed Dec 17, 2008 7:59 pm    Post subject: Reply with quote

It looks great, StuartL&Matt

I think it's the moment to try again programming the CM-5 Smile
_________________
http://www.siempreaprendiendo.es/english/index.html
Back to top
View user's profile Send private message   Visit poster's website
BillB
Savvy Roboteer
Savvy Roboteer


Joined: 06 Aug 2006
Posts: 225
Location: Hampshire, UK

PostPosted: Wed Dec 17, 2008 8:45 pm    Post subject: Reply with quote

Quote:
The key hook is done in libbioloid/bioloid/cm5.c at line 21 where cm5_init is set to appear in section ".init8"


Ah - thats the Monkey. Thanks Stuart.
Back to top
View user's profile Send private message  
StuartL
Savvy Roboteer
Savvy Roboteer


Joined: 04 Jun 2007
Posts: 348
Location: Thatcham, Berkshire, UK

PostPosted: Thu Dec 18, 2008 12:07 pm    Post subject: Reply with quote

siempre.aprendiendo wrote:
It looks great, StuartL&Matt


As you'll see from the changelog Matt deserves most of the credit for the recent work. He keeps talking about creating an account but as far as I know he hasn't done so yet. He is on the distribution list, though.

Quote:
I think it's the moment to try again programming the CM-5 Smile


The functionality available with well written C is surprising. As most people reading this will know we've managed 20-servo forward and reverse kinematics at 40Hz with the biped using the stock ATmega128 at 16MHz.

Of course if you consider the servos as MCUs in their own right a 20-servo biped has 20 x 8MHz MCUs and 1 x 16MHz MCUs. That's a lot of processing power if you can make the software appropriately parallel.

One of the biggest overheads we're seeing are for 32-bit arithmetic (needed for accurate trig) and interrupt overhead. If we can switch to the platform we're thinking of (see other thread) both of these should be resolved natively and even if the clock rate doesn't increase that much (which it should) the overheads should be much lower and hence performance will jump dramatically. We're even now thinking about how we can increase the speed of the servo bus so that we can go faster than 40Hz.
Back to top
View user's profile Send private message  
brijesh
Newbie
Newbie


Joined: 02 Sep 2008
Posts: 4

PostPosted: Sat Dec 20, 2008 5:21 pm    Post subject: Reply with quote

I have down loaded and been going through it. Great work guys.

When I was looking through code I saw that you are kind of implementing the sprintf() functionality in sio_printf_real(). At least thats what it seemed like with a cursory first look at the code.

Any particular reason?

thanks
Back to top
View user's profile Send private message  
StuartL
Savvy Roboteer
Savvy Roboteer


Joined: 04 Jun 2007
Posts: 348
Location: Thatcham, Berkshire, UK

PostPosted: Sat Dec 20, 2008 6:26 pm    Post subject: Reply with quote

What do you mean by "any particular reason"? Do you mean "why in that source file?" or "why do you need a sprintf?".
Back to top
View user's profile Send private message  
Display posts from previous:   
Post new topic   Reply to topic    RoboSavvy Forum Forum Index -> Bioloid & Robotis All times are GMT
Goto page 1, 2, 3 ... 11, 12, 13  Next
Page 1 of 13

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Robonova Humanoid Bioloid Comprehensive Kit Robobuilder 5710K Humanoid Robobuilder 5720T Humanoid MechRC ShadowStalker KHR 1 HV and KHR 2 HV Humanoids KHR 3HV Humanoid Kit
Robonova-I
Intro | Forum | Buy
Bioloid
Intro | Forum | Buy
Robobuilder 5710K
Intro | Forum | Buy
Robobuilder 5720T
Intro | Forum | Buy
MechRC
Intro | Forum | Buy
KHR 1HV & 2HV
1HV 2HV | Forum | Buy
KHR 3HV
Intro | Forum | Buy
POBbot Wheeled Platforms (POB) POPbot Arduino Wheeled Robot Microcamp Atmega8 Activity / Introductory Kit Robobox 3 Educational Robot Kit Robotis OLLO - Starter Robotics Kits Sparkfun Products Roboard X86 Embedded Robot Board
Edu Robots
Intro | Buy
Arduino Robot
Intro | Buy
Cheap Robot
Intro | Buy
Wheeled Robot
Intro | Buy
Kids Robots
Intro | Buy
Sparkfun Electronics
Buy
x86 Robot Board
Intro | Forum | Buy



Powered by phpBB ©

In Our Store

 
Inex - POP-BOT Lite - Arduino Mobile Robot Platform
Inex - POP-BOT Lite - Arduino Mobile Robot Platform
£53.50   £61.53 inc. VAT
 

GoogleSearch

Google
robosavvy.com
Web


© 2009 RoboSavvy
All rights reserved. Privacy Policy.