Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

libavr/libbioloid C library for CM5 released!

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
289 postsPage 13 of 201 ... 10, 11, 12, 13, 14, 15, 16 ... 20
289 postsPage 13 of 201 ... 10, 11, 12, 13, 14, 15, 16 ... 20

Post by kamondelious » Sun Sep 13, 2009 12:54 pm

Post by kamondelious
Sun Sep 13, 2009 12:54 pm

OK, progress!

I put this in dynamixel.c with the appropriate header entry.
Code: Select all
uint8_t *havimo_raw(id_t id) {
  uint8_t packet[] = {id, 3, 0x0F};
  uint16_t count;
  uint8_t len = 0;

  dx_sendpacket(packet, dx_readcallback);
  count = 0;
  read_n = 0;

  if(!read_error && len == read_n)
   return read;
  else
   return NULL;
}


and in my code I have the following :
Code: Select all
void havimo_image(void)
{
  int i = 0;
  uint8_t *data = havimo_raw(HAVIMO);
  for(i=0;i<160*120;i++) {
   printf("%d", data[i]);
  }
}


I am consistently getting a lot of data from my HaViMo now without abnormally long waits.

Next step is to display the image on my screen. :D
OK, progress!

I put this in dynamixel.c with the appropriate header entry.
Code: Select all
uint8_t *havimo_raw(id_t id) {
  uint8_t packet[] = {id, 3, 0x0F};
  uint16_t count;
  uint8_t len = 0;

  dx_sendpacket(packet, dx_readcallback);
  count = 0;
  read_n = 0;

  if(!read_error && len == read_n)
   return read;
  else
   return NULL;
}


and in my code I have the following :
Code: Select all
void havimo_image(void)
{
  int i = 0;
  uint8_t *data = havimo_raw(HAVIMO);
  for(i=0;i<160*120;i++) {
   printf("%d", data[i]);
  }
}


I am consistently getting a lot of data from my HaViMo now without abnormally long waits.

Next step is to display the image on my screen. :D
kamondelious
Savvy Roboteer
Savvy Roboteer
Posts: 29
Joined: Tue Sep 30, 2008 11:18 pm

Post by hamid_m » Sun Sep 13, 2009 10:50 pm

Post by hamid_m
Sun Sep 13, 2009 10:50 pm

Hi kamondelious,

An important question,

where do you save 160*120 bytes of data, while ATMega128 has just 4KB RAM?

Hamid.
Hi kamondelious,

An important question,

where do you save 160*120 bytes of data, while ATMega128 has just 4KB RAM?

Hamid.
hamid_m
Savvy Roboteer
Savvy Roboteer
Posts: 133
Joined: Thu May 03, 2007 4:56 pm

Post by kamondelious » Sun Sep 13, 2009 11:52 pm

Post by kamondelious
Sun Sep 13, 2009 11:52 pm

Good question! That explains why the first few thousand bytes of data look good and the last several thousand are just the same number repeated.

I was already figuring that I need to buffer the throughput, I just haven't gotten to that yet. :wink: I am very much open to suggestions on what to do. I do have your example.c which has been of great help so far, I'm sure there is plenty more for me to glean off of it.

So much to learn, but it's half the fun.
Good question! That explains why the first few thousand bytes of data look good and the last several thousand are just the same number repeated.

I was already figuring that I need to buffer the throughput, I just haven't gotten to that yet. :wink: I am very much open to suggestions on what to do. I do have your example.c which has been of great help so far, I'm sure there is plenty more for me to glean off of it.

So much to learn, but it's half the fun.
kamondelious
Savvy Roboteer
Savvy Roboteer
Posts: 29
Joined: Tue Sep 30, 2008 11:18 pm

Post by gozita007 » Thu Oct 08, 2009 9:50 pm

Post by gozita007
Thu Oct 08, 2009 9:50 pm

Hi i recently started looking at the example.c and i wanted to slowly move a leg up (then down to sort of simulate walking). I saw the case 'a' and 'q' lines which do the servo[i]position++ or --, and used those as examples to figure out a way to move the legs up and down.

for(int alpha = 0; alpha <= 154; alpha++)
{
s.servo[11].position--;
s.servo[13].position--;
//timer_delay(1);
}

I wanted the servos to be at roughly 45 degree (which is around 154 in servo position). When i tried to add the timer_delay line it doesn't seem to work the way i wanted(which is to slowly increment or decrement the servo position). When i took out the delay, it would just go straight the 45 degree position, shaking the robot and causing it to fall over. Is there a way to slowly increment servo positions with a different timer_delay?
Hi i recently started looking at the example.c and i wanted to slowly move a leg up (then down to sort of simulate walking). I saw the case 'a' and 'q' lines which do the servo[i]position++ or --, and used those as examples to figure out a way to move the legs up and down.

for(int alpha = 0; alpha <= 154; alpha++)
{
s.servo[11].position--;
s.servo[13].position--;
//timer_delay(1);
}

I wanted the servos to be at roughly 45 degree (which is around 154 in servo position). When i tried to add the timer_delay line it doesn't seem to work the way i wanted(which is to slowly increment or decrement the servo position). When i took out the delay, it would just go straight the 45 degree position, shaking the robot and causing it to fall over. Is there a way to slowly increment servo positions with a different timer_delay?
gozita007
Newbie
Newbie
Posts: 2
Joined: Thu Oct 08, 2009 9:41 pm

Post by Suicidal.Banana » Sat Oct 10, 2009 3:21 pm

Post by Suicidal.Banana
Sat Oct 10, 2009 3:21 pm

have you tried to do something like
timer_delay(0.5);
just guessing here though
have you tried to do something like
timer_delay(0.5);
just guessing here though
Suicidal.Banana
Savvy Roboteer
Savvy Roboteer
Posts: 78
Joined: Tue Jun 16, 2009 12:54 pm

Post by billyzelsnack » Sun Oct 11, 2009 4:28 am

Post by billyzelsnack
Sun Oct 11, 2009 4:28 am

gozita007 wrote:Hi i recently started looking at the example.c and i wanted to slowly move a leg up (then down to sort of simulate walking). I saw the case 'a' and 'q' lines which do the servo[i]position++ or --, and used those as examples to figure out a way to move the legs up and down.

for(int alpha = 0; alpha <= 154; alpha++)
{
s.servo[11].position--;
s.servo[13].position--;
//timer_delay(1);
}

I wanted the servos to be at roughly 45 degree (which is around 154 in servo position). When i tried to add the timer_delay line it doesn't seem to work the way i wanted(which is to slowly increment or decrement the servo position). When i took out the delay, it would just go straight the 45 degree position, shaking the robot and causing it to fall over. Is there a way to slowly increment servo positions with a different timer_delay?


I don't know anything how the lib works, but it looks like that loop is just setting some member variables over and over again. You probably need to call some sort of update function inside the loop to actually make an update happen. Saying that.. It's probably not what you want to do anyway because servos can't reach their targets instantly and it'll most likely stutter.
gozita007 wrote:Hi i recently started looking at the example.c and i wanted to slowly move a leg up (then down to sort of simulate walking). I saw the case 'a' and 'q' lines which do the servo[i]position++ or --, and used those as examples to figure out a way to move the legs up and down.

for(int alpha = 0; alpha <= 154; alpha++)
{
s.servo[11].position--;
s.servo[13].position--;
//timer_delay(1);
}

I wanted the servos to be at roughly 45 degree (which is around 154 in servo position). When i tried to add the timer_delay line it doesn't seem to work the way i wanted(which is to slowly increment or decrement the servo position). When i took out the delay, it would just go straight the 45 degree position, shaking the robot and causing it to fall over. Is there a way to slowly increment servo positions with a different timer_delay?


I don't know anything how the lib works, but it looks like that loop is just setting some member variables over and over again. You probably need to call some sort of update function inside the loop to actually make an update happen. Saying that.. It's probably not what you want to do anyway because servos can't reach their targets instantly and it'll most likely stutter.
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

Post by BillB » Tue Oct 13, 2009 2:07 pm

Post by BillB
Tue Oct 13, 2009 2:07 pm

gozita007 wrote:
Hi i recently started looking at the example.c and i wanted to slowly move a leg up (then down to sort of simulate walking). I saw the case 'a' and 'q' lines which do the servo[i]position++ or --, and used those as examples to figure out a way to move the legs up and down.

for(int alpha = 0; alpha <= 154; alpha++)
{
s.servo[11].position--;
s.servo[13].position--;
//timer_delay(1);
}

I wanted the servos to be at roughly 45 degree (which is around 154 in servo position). When i tried to add the timer_delay line it doesn't seem to work the way i wanted(which is to slowly increment or decrement the servo position). When i took out the delay, it would just go straight the 45 degree position, shaking the robot and causing it to fall over. Is there a way to slowly increment servo positions with a different timer_delay?


You need to send the new positions to the servos by using dx_set_stance . See below:

Code: Select all
for(int alpha = 0; alpha <= 154; alpha++)
{
s.servo[11].position--;
s.servo[13].position--;
dx_set_stance(&s);
timer_delay(1);
}


That should work.
gozita007 wrote:
Hi i recently started looking at the example.c and i wanted to slowly move a leg up (then down to sort of simulate walking). I saw the case 'a' and 'q' lines which do the servo[i]position++ or --, and used those as examples to figure out a way to move the legs up and down.

for(int alpha = 0; alpha <= 154; alpha++)
{
s.servo[11].position--;
s.servo[13].position--;
//timer_delay(1);
}

I wanted the servos to be at roughly 45 degree (which is around 154 in servo position). When i tried to add the timer_delay line it doesn't seem to work the way i wanted(which is to slowly increment or decrement the servo position). When i took out the delay, it would just go straight the 45 degree position, shaking the robot and causing it to fall over. Is there a way to slowly increment servo positions with a different timer_delay?


You need to send the new positions to the servos by using dx_set_stance . See below:

Code: Select all
for(int alpha = 0; alpha <= 154; alpha++)
{
s.servo[11].position--;
s.servo[13].position--;
dx_set_stance(&s);
timer_delay(1);
}


That should work.
BillB
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 232
Joined: Sun Aug 06, 2006 1:00 am
Location: Hampshire, UK

make Error

Post by bryanjeal » Sun Nov 22, 2009 6:11 am

Post by bryanjeal
Sun Nov 22, 2009 6:11 am

First, I would like to thank Matt and Stuart for creating this awesome set of tools for programming the CM-5!

I know everything works (not just from reading the responses on the forum, but I have complied the example and the tools on a ubuntu machine); however, I have a problem when I try to "make" the programmer tool on my MacBook (OSX 10.6):

Code: Select all
bash-3.2$ ls
bin                            libbioloid-latest.tgz
doc                             libcompat
example                        libcompat-latest.tgz
libavr                            psx-latest.tgz
libavr-2009-09-17-r1396.tgz   tools
libbioloid

bash-3.2$ cd tools/
bash-3.2$ ls
LICENCE           dxpktchk.c               rom2bin
Makefile           programmer.c
das         robotis_decrypt.c

bash-3.2$ make
gcc        -Wall -g -std=gnu99 -Os -I../libcompat  -lm  programmer.c ../libcompat/compat/console.c ../libcompat/compat/serial.c   -o programmer
programmer.c: In function ‘main’:
programmer.c:112: error: ‘B1000000’ undeclared (first use in this function)
programmer.c:112: error: (Each undeclared identifier is reported only once
programmer.c:112: error: for each function it appears in.)
make: *** [programmer] Error 1
bash-3.2$


If anyone can share some insight that would be appreciated!

-Bryan
First, I would like to thank Matt and Stuart for creating this awesome set of tools for programming the CM-5!

I know everything works (not just from reading the responses on the forum, but I have complied the example and the tools on a ubuntu machine); however, I have a problem when I try to "make" the programmer tool on my MacBook (OSX 10.6):

Code: Select all
bash-3.2$ ls
bin                            libbioloid-latest.tgz
doc                             libcompat
example                        libcompat-latest.tgz
libavr                            psx-latest.tgz
libavr-2009-09-17-r1396.tgz   tools
libbioloid

bash-3.2$ cd tools/
bash-3.2$ ls
LICENCE           dxpktchk.c               rom2bin
Makefile           programmer.c
das         robotis_decrypt.c

bash-3.2$ make
gcc        -Wall -g -std=gnu99 -Os -I../libcompat  -lm  programmer.c ../libcompat/compat/console.c ../libcompat/compat/serial.c   -o programmer
programmer.c: In function ‘main’:
programmer.c:112: error: ‘B1000000’ undeclared (first use in this function)
programmer.c:112: error: (Each undeclared identifier is reported only once
programmer.c:112: error: for each function it appears in.)
make: *** [programmer] Error 1
bash-3.2$


If anyone can share some insight that would be appreciated!

-Bryan
bryanjeal
Newbie
Newbie
Posts: 1
Joined: Sun Nov 22, 2009 6:03 am

Post by gozita007 » Wed Dec 02, 2009 4:09 am

Post by gozita007
Wed Dec 02, 2009 4:09 am

Hi, recently I accidently left the battery pack charging for around 24hrs, and found the cm5 to be quite hot when I discovered my mistake. When I start up the bioloid, it gives me these errors:

14(missing): no response
16(missing): no response
18(missing): no response

The other servos seems to be fine, and i can still upload to it. Is this a problem with the CM5 or the specific servos? Any help would be appreciated.
Hi, recently I accidently left the battery pack charging for around 24hrs, and found the cm5 to be quite hot when I discovered my mistake. When I start up the bioloid, it gives me these errors:

14(missing): no response
16(missing): no response
18(missing): no response

The other servos seems to be fine, and i can still upload to it. Is this a problem with the CM5 or the specific servos? Any help would be appreciated.
gozita007
Newbie
Newbie
Posts: 2
Joined: Thu Oct 08, 2009 9:41 pm

Re: make Error

Post by RandomMatt » Sun Dec 13, 2009 11:22 am

Post by RandomMatt
Sun Dec 13, 2009 11:22 am

bryanjeal wrote:
Code: Select all
programmer.c: In function ‘main’:
programmer.c:112: error: ‘B1000000’ undeclared (first use in this function)


If anyone can share some insight that would be appreciated!

-Bryan


The problem is that B1000000 isn't declared. The real problem is that there is not a standard way in unix (well POSIX) to specify 1Mbit serial ports. You can easily fix the problem on your computer by looking at the man page for cfsetispeed and see what it says you should use - then patch libcompat/compat/serial.h to define B1000000 to that value.
bryanjeal wrote:
Code: Select all
programmer.c: In function ‘main’:
programmer.c:112: error: ‘B1000000’ undeclared (first use in this function)


If anyone can share some insight that would be appreciated!

-Bryan


The problem is that B1000000 isn't declared. The real problem is that there is not a standard way in unix (well POSIX) to specify 1Mbit serial ports. You can easily fix the problem on your computer by looking at the man page for cfsetispeed and see what it says you should use - then patch libcompat/compat/serial.h to define B1000000 to that value.
RandomMatt
Savvy Roboteer
Savvy Roboteer
Posts: 117
Joined: Sat Dec 20, 2008 11:16 pm

Post by limor » Fri Feb 05, 2010 8:34 pm

Post by limor
Fri Feb 05, 2010 8:34 pm

Hi RandomMatt and StuartL,
I've been trying out the the libbioloid and have a couple of questions

- I can't find the source code for dx_set_torque_enable(). I've run grep on all files but it doesn't appear anywhere except for in example.c (which compiles, hence it must be somewhere) and in libbioloid.html . where is it hidden ?

- The documentation and code mentions the M1 replacement firmware for the AX12. Can you share this code? i'm really interested in having alternative firmware more geared for advanced PC driven control-loops. Also, if there are any special conversions of the hex file that need to be run before flashing the file, please share. (i saw your file robotis_decrypt.c so i thought maybe that has to do with AX12 firmware encoding ?)

Thanks!
Limor
Hi RandomMatt and StuartL,
I've been trying out the the libbioloid and have a couple of questions

- I can't find the source code for dx_set_torque_enable(). I've run grep on all files but it doesn't appear anywhere except for in example.c (which compiles, hence it must be somewhere) and in libbioloid.html . where is it hidden ?

- The documentation and code mentions the M1 replacement firmware for the AX12. Can you share this code? i'm really interested in having alternative firmware more geared for advanced PC driven control-loops. Also, if there are any special conversions of the hex file that need to be run before flashing the file, please share. (i saw your file robotis_decrypt.c so i thought maybe that has to do with AX12 firmware encoding ?)

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

Post by RandomMatt » Fri Feb 05, 2010 8:56 pm

Post by RandomMatt
Fri Feb 05, 2010 8:56 pm

limor wrote:- I can't find the source code for dx_set_torque_enable(). I've run grep on all files but it doesn't appear anywhere except for in example.c (which compiles, hence it must be somewhere) and in libbioloid.html . where is it hidden ?


Most of the dx_get_* and dx_set_* functions are defined using the DX_RAM macro. Have a look in libbioloid/bioloid/dynamixel_memory.h


limor wrote:The documentation and code mentions the M1 replacement firmware for the AX12. Can you share this code?


I don't want to give it away. It was several months of work.

The M1 firmware requires a PSX-B to authenticate against before it'll let you switch the torque on. I'll stick a copy of the firmware in psx-latest.tgz at somepoint over the next week - but you'll need to get a PSX-B board to use it sensibly.
limor wrote:- I can't find the source code for dx_set_torque_enable(). I've run grep on all files but it doesn't appear anywhere except for in example.c (which compiles, hence it must be somewhere) and in libbioloid.html . where is it hidden ?


Most of the dx_get_* and dx_set_* functions are defined using the DX_RAM macro. Have a look in libbioloid/bioloid/dynamixel_memory.h


limor wrote:The documentation and code mentions the M1 replacement firmware for the AX12. Can you share this code?


I don't want to give it away. It was several months of work.

The M1 firmware requires a PSX-B to authenticate against before it'll let you switch the torque on. I'll stick a copy of the firmware in psx-latest.tgz at somepoint over the next week - but you'll need to get a PSX-B board to use it sensibly.
RandomMatt
Savvy Roboteer
Savvy Roboteer
Posts: 117
Joined: Sat Dec 20, 2008 11:16 pm

Post by limor » Sun Feb 07, 2010 12:03 pm

Post by limor
Sun Feb 07, 2010 12:03 pm

RandomMatt wrote:
limor wrote:The documentation and code mentions the M1 replacement firmware for the AX12. Can you share this code?


I don't want to give it away. It was several months of work.

The M1 firmware requires a PSX-B to authenticate against before it'll let you switch the torque on. I'll stick a copy of the firmware in psx-latest.tgz at somepoint over the next week - but you'll need to get a PSX-B board to use it sensibly.


I would like to write a very particular firmware for AX12 that will allow me to read/write to the robot servos at 200Hz+.
It would be great is if you could share your knowledge of
(a) the process of taking a Atmega8 hex file and converting/encrypting it to AX12 bootloader flash format (is this required?)
(b) code for working the PWM signals to the MOSFETs
(c) reading the POT and toggling any Atmega8 pin that does something on the AX12

Your work and contribution are very much appreciated.
RandomMatt wrote:
limor wrote:The documentation and code mentions the M1 replacement firmware for the AX12. Can you share this code?


I don't want to give it away. It was several months of work.

The M1 firmware requires a PSX-B to authenticate against before it'll let you switch the torque on. I'll stick a copy of the firmware in psx-latest.tgz at somepoint over the next week - but you'll need to get a PSX-B board to use it sensibly.


I would like to write a very particular firmware for AX12 that will allow me to read/write to the robot servos at 200Hz+.
It would be great is if you could share your knowledge of
(a) the process of taking a Atmega8 hex file and converting/encrypting it to AX12 bootloader flash format (is this required?)
(b) code for working the PWM signals to the MOSFETs
(c) reading the POT and toggling any Atmega8 pin that does something on the AX12

Your work and contribution are very much appreciated.
limor
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK

Post by limor » Sun Feb 07, 2010 12:08 pm

Post by limor
Sun Feb 07, 2010 12:08 pm

btw: the avr-gcc library that comes with Cygwin doesnt compile the libbioloid and errors on the trig_tables and other things. The one that works is the MinGW compiler (who's community web site has been hijacked by spammers).
You may want to consider changing the documentation text to reflect that as it takes 30 seconds from download to having example.hex if you go the MinGW route but 3 days and no results if you go the Cygwin route
:)
btw: the avr-gcc library that comes with Cygwin doesnt compile the libbioloid and errors on the trig_tables and other things. The one that works is the MinGW compiler (who's community web site has been hijacked by spammers).
You may want to consider changing the documentation text to reflect that as it takes 30 seconds from download to having example.hex if you go the MinGW route but 3 days and no results if you go the Cygwin route
:)
limor
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK

Post by RandomMatt » Sun Feb 07, 2010 3:54 pm

Post by RandomMatt
Sun Feb 07, 2010 3:54 pm

limor wrote:I would like to write a very particular firmware for AX12 that will allow me to read/write to the robot servos at 200Hz+.
It would be great is if you could share your knowledge of
(a) the process of taking a Atmega8 hex file and converting/encrypting it to AX12 bootloader flash format (is this required?)
(b) code for working the PWM signals to the MOSFETs
(c) reading the POT and toggling any Atmega8 pin that does something on the AX12


200Hz isn't a problem - the M1 firmware runs its PID at 1KHz, much faster isn't sensible because of the response time of the motor. The problem is the communications, at 1MBit/s an AX12 board has 160 clock cycles per byte to do its stuff, at 2MBit/s you have 80.

a) there is no encryption - once you have a .bin file it is easy to use tools/programmer to program a servo.
b) and c) read the ATMega8 datasheet - it is all done in hardware... more helpfully, libbioloid has code to read ADCs in hw/cm5/battery.c. And read the documentation for libavr - toggling pins, messing with UARTs is what that does best.
limor wrote:I would like to write a very particular firmware for AX12 that will allow me to read/write to the robot servos at 200Hz+.
It would be great is if you could share your knowledge of
(a) the process of taking a Atmega8 hex file and converting/encrypting it to AX12 bootloader flash format (is this required?)
(b) code for working the PWM signals to the MOSFETs
(c) reading the POT and toggling any Atmega8 pin that does something on the AX12


200Hz isn't a problem - the M1 firmware runs its PID at 1KHz, much faster isn't sensible because of the response time of the motor. The problem is the communications, at 1MBit/s an AX12 board has 160 clock cycles per byte to do its stuff, at 2MBit/s you have 80.

a) there is no encryption - once you have a .bin file it is easy to use tools/programmer to program a servo.
b) and c) read the ATMega8 datasheet - it is all done in hardware... more helpfully, libbioloid has code to read ADCs in hw/cm5/battery.c. And read the documentation for libavr - toggling pins, messing with UARTs is what that does best.
RandomMatt
Savvy Roboteer
Savvy Roboteer
Posts: 117
Joined: Sat Dec 20, 2008 11:16 pm

PreviousNext
289 postsPage 13 of 201 ... 10, 11, 12, 13, 14, 15, 16 ... 20
289 postsPage 13 of 201 ... 10, 11, 12, 13, 14, 15, 16 ... 20