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

Pain in the 455

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
11 postsPage 1 of 1
11 postsPage 1 of 1

Pain in the 455

Post by roboTT » Tue Apr 15, 2008 4:10 pm

Post by roboTT
Tue Apr 15, 2008 4:10 pm

Anyone here coding Robonova in something different than ROBOBASIC ?

It's cool to have the controller board documentation, but there are some major things missing ;(

I still fight with a method to go over and do some "WAIT" translation to C - the same goes for MOVE24.

Guys, do you know how to implement a WAIT method - or any ideas ?

This is crucial when some synchro moves are made.

I just don't want to land with Robobasic ;/ especially due to the fact that there is no chance to retrieve the data to my laptop with Robobasic while the robot is working - and futher, no chance to command on event.
Anyone here coding Robonova in something different than ROBOBASIC ?

It's cool to have the controller board documentation, but there are some major things missing ;(

I still fight with a method to go over and do some "WAIT" translation to C - the same goes for MOVE24.

Guys, do you know how to implement a WAIT method - or any ideas ?

This is crucial when some synchro moves are made.

I just don't want to land with Robobasic ;/ especially due to the fact that there is no chance to retrieve the data to my laptop with Robobasic while the robot is working - and futher, no chance to command on event.
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by i-Bot » Tue Apr 15, 2008 4:48 pm

Post by i-Bot
Tue Apr 15, 2008 4:48 pm

Are you using the EB command for the servo moves, or individual E6 coomands ?

If you are using EB, then you can check for the motion complete by reading the RAM locations.

In the thread on synchro servo move, you will see some earlier discussion on this topic.
Are you using the EB command for the servo moves, or individual E6 coomands ?

If you are using EB, then you can check for the motion complete by reading the RAM locations.

In the thread on synchro servo move, you will see some earlier discussion on this topic.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by roboTT » Tue Apr 15, 2008 5:03 pm

Post by roboTT
Tue Apr 15, 2008 5:03 pm

Here is how i do it:

Code: Select all

//Pushes E6 to move a single servo
void Servo_move(int which,int position){
     SerialPutc(hCom,0xE6);//move servo
     SerialPutc(hCom,which);//ktore serwo
     SerialPutc(hCom,position);//position
     Sleep(5);
}

..

//This is used to peek the data from the registry
//mainly used to receive actual servo positions
void Memory_read(int low,int high){
   SerialPutc(hCom,0xF7);
   SerialPutc(hCom,low);
   SerialPutc(hCom,high);
   SerialPutc(hCom,0x00);



//This is my WAIT implementation
//it goes to endless loop untill actual servo value reaches required value.
int Servo_wait(int ktore,int wartosc){

   while(ROBONOVA.servo[ktore].value!=wartosc){
      if(GetTickCount()-tick>10){
         Memory_read(0x20+ktore,0x03);Sleep(5);
         tick=GetTickCount();
      }
   }
   return 1;

}




And when i perform the move with WAIT, i do this like that:

Servo_move(14,10);
Servo_wait(14,10);

And that is really working fine.

But i have noticed, that when i do plenty of moves at once - for example:




Code: Select all
//g6a
Servo_move(0,100);Servo_move(1,76);Servo_move(2,145); Servo_move(3,93); Servo_move(4,100);
//g6d
Servo_move(18,100);Servo_move(19,76);Servo_move(20,145); Servo_move(21,93);Servo_move(22,100);

Servo_wait(4,100);

//g6b
Servo_move(6,100);Servo_move(7,30);   Servo_move(8,80);
//g6c
Servo_move(12,100);Servo_move(13,30);Servo_move(14,80);
         
Servo_wait(2,120);



Robonova does not do that correct, it likes to loose itself somewhere in the middle, at the beggining without reason.


I have a separate thread that receives the data to buffer, so i am aware when i can send the next data.


The thing is that when i perform many moves - for example required for forward_walk, robonova does some strange things.. Exceeds the values of the servos, doesn't move at all, stops, pauses or just mixes them all at once.

I rewrote the desired servo values from working robobasic code, and due to the fact ( i believe ) that there is no MOVE24 possible from C, each servo move is spawned with some ms delay.. so everything starts to be desynched.


i-Bot, got some idea?

It gets me really p!ssed.. as i've managed to receieve all AD data values and so on, but when it is time to code some real stuff - like walking and autonomus moves, i fail at the beggining.

Hitec should really post official documentation for the RN-1 board.
Here is how i do it:

Code: Select all

//Pushes E6 to move a single servo
void Servo_move(int which,int position){
     SerialPutc(hCom,0xE6);//move servo
     SerialPutc(hCom,which);//ktore serwo
     SerialPutc(hCom,position);//position
     Sleep(5);
}

..

//This is used to peek the data from the registry
//mainly used to receive actual servo positions
void Memory_read(int low,int high){
   SerialPutc(hCom,0xF7);
   SerialPutc(hCom,low);
   SerialPutc(hCom,high);
   SerialPutc(hCom,0x00);



//This is my WAIT implementation
//it goes to endless loop untill actual servo value reaches required value.
int Servo_wait(int ktore,int wartosc){

   while(ROBONOVA.servo[ktore].value!=wartosc){
      if(GetTickCount()-tick>10){
         Memory_read(0x20+ktore,0x03);Sleep(5);
         tick=GetTickCount();
      }
   }
   return 1;

}




And when i perform the move with WAIT, i do this like that:

Servo_move(14,10);
Servo_wait(14,10);

And that is really working fine.

But i have noticed, that when i do plenty of moves at once - for example:




Code: Select all
//g6a
Servo_move(0,100);Servo_move(1,76);Servo_move(2,145); Servo_move(3,93); Servo_move(4,100);
//g6d
Servo_move(18,100);Servo_move(19,76);Servo_move(20,145); Servo_move(21,93);Servo_move(22,100);

Servo_wait(4,100);

//g6b
Servo_move(6,100);Servo_move(7,30);   Servo_move(8,80);
//g6c
Servo_move(12,100);Servo_move(13,30);Servo_move(14,80);
         
Servo_wait(2,120);



Robonova does not do that correct, it likes to loose itself somewhere in the middle, at the beggining without reason.


I have a separate thread that receives the data to buffer, so i am aware when i can send the next data.


The thing is that when i perform many moves - for example required for forward_walk, robonova does some strange things.. Exceeds the values of the servos, doesn't move at all, stops, pauses or just mixes them all at once.

I rewrote the desired servo values from working robobasic code, and due to the fact ( i believe ) that there is no MOVE24 possible from C, each servo move is spawned with some ms delay.. so everything starts to be desynched.


i-Bot, got some idea?

It gets me really p!ssed.. as i've managed to receieve all AD data values and so on, but when it is time to code some real stuff - like walking and autonomus moves, i fail at the beggining.

Hitec should really post official documentation for the RN-1 board.
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by i-Bot » Wed Apr 16, 2008 11:56 am

Post by i-Bot
Wed Apr 16, 2008 11:56 am

The E6 command you are using is the equivalent of the RoboBasic SERVO instruction. It is not a point to point move, so not equivalent to MOVE G??.

The EB command is the MOVE equivalent. This also has some limitations due to the slow communications link, but is the correct basis for group moves.

Is your C3024 interpreter in STOP mode ?. This should give more time for the serial comms. You might also up the serial speed to 115K.

As described in the other thread the start may be a bit ragged, but the point to point should make them all stop together.

It may be we have to patch in a new command, which does not update the desired servo positions until the entire data is received.

From your code it is not clear how you wait for a response before sending the next character. I see you sent characters one after each other, which can overrun the limited (3 bytes) buffer in the C3024. You will need to follow the protocol if you send longer commands such as a MOVE G24.
The E6 command you are using is the equivalent of the RoboBasic SERVO instruction. It is not a point to point move, so not equivalent to MOVE G??.

The EB command is the MOVE equivalent. This also has some limitations due to the slow communications link, but is the correct basis for group moves.

Is your C3024 interpreter in STOP mode ?. This should give more time for the serial comms. You might also up the serial speed to 115K.

As described in the other thread the start may be a bit ragged, but the point to point should make them all stop together.

It may be we have to patch in a new command, which does not update the desired servo positions until the entire data is received.

From your code it is not clear how you wait for a response before sending the next character. I see you sent characters one after each other, which can overrun the limited (3 bytes) buffer in the C3024. You will need to follow the protocol if you send longer commands such as a MOVE G24.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by roboTT » Wed Apr 16, 2008 3:01 pm

Post by roboTT
Wed Apr 16, 2008 3:01 pm

i-Bot,

there is a separate thread continously receiving data from the Board.

It does the:

pseudocode

Code: Select all
while(1){


a=receivedatafromcom();

switch(a){

   case 0xCOMMANDRESPONSE1:
   receive_all_bytes_left();
   break;


  case 0xCOMMANDRESPONSE2:
receive_all_bytes_left();
 break

}

}



Btw,

isn't the EB command requiring FIRST_SERVO LAST_SERVO arguments ?

SYNC_MOVE 0xEB Writes a position value to a C3024
Servo Synchronous motion. PTP
should be on



Byte 1
0xEB 0xEB Command and echo

Byte 2
PTP ( 1 byte) On= 1, Off = 0 PTP ( 1 byte) On = 1, Off = 0 PTP value and
echo

Byte 3
First servo Number (1 byte)

Byte 4
Last servo Number (1 byte)

Byte 5
to end Repeats for number of servos (last-first)




So having this implemented,
how would you use that to move servo 0 and 18 to a one position?

i-Bot - the STOP mode, what is this setting?
i-Bot,

there is a separate thread continously receiving data from the Board.

It does the:

pseudocode

Code: Select all
while(1){


a=receivedatafromcom();

switch(a){

   case 0xCOMMANDRESPONSE1:
   receive_all_bytes_left();
   break;


  case 0xCOMMANDRESPONSE2:
receive_all_bytes_left();
 break

}

}



Btw,

isn't the EB command requiring FIRST_SERVO LAST_SERVO arguments ?

SYNC_MOVE 0xEB Writes a position value to a C3024
Servo Synchronous motion. PTP
should be on



Byte 1
0xEB 0xEB Command and echo

Byte 2
PTP ( 1 byte) On= 1, Off = 0 PTP ( 1 byte) On = 1, Off = 0 PTP value and
echo

Byte 3
First servo Number (1 byte)

Byte 4
Last servo Number (1 byte)

Byte 5
to end Repeats for number of servos (last-first)




So having this implemented,
how would you use that to move servo 0 and 18 to a one position?

i-Bot - the STOP mode, what is this setting?
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by roboTT » Sat Apr 19, 2008 10:03 am

Post by roboTT
Sat Apr 19, 2008 10:03 am

Urgh!!

i did not read that correctly..

It is clear that we set the servoes to be moved and then we set their desired positions in 0xEB.

Sorry i-Bot, my fault :)

I'll work on it, and drop some results.
Urgh!!

i did not read that correctly..

It is clear that we set the servoes to be moved and then we set their desired positions in 0xEB.

Sorry i-Bot, my fault :)

I'll work on it, and drop some results.
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by roboTT » Sat Apr 19, 2008 3:45 pm

Post by roboTT
Sat Apr 19, 2008 3:45 pm

Ok, went through totally separate implementation to see if 0xEB does all the magic thing, and using this - i would be able to code MOVE24, MOVEG6A and others.

Now, within ROBOBASIC in the beggining i do:

PTP SETON
PTP ALLON

'== motor diretion setting ======================
DIR G6A,1,0,0,1,0,0
DIR G6B,1,1,1,1,1,1
DIR G6C,0,0,0,0,0,0
DIR G6D,0,1,1,0,1,0

'== motor start position read ===================
GETMOTORSET G6A,1,1,1,1,1,0
GETMOTORSET G6B,1,1,1,0,0,0
GETMOTORSET G6C,1,1,1,0,0,0
GETMOTORSET G6D,1,1,1,1,1,0
SPEED 5
MOTOR G24



What is always to be used in my project.

As all my motors are on, and the speed is set - i would like to perform a movement of servoes 7,8 to position 0x64 - which stands for the 'middle'.


Here goes the code:


Code: Select all
   
SerialPutc(hCom,0xEB);A=SerialGetc(hCom);   //SYNC MOVE
SerialPutc(hCom,0x01);a=SerialGetc(hCom);    //PTP
 
SerialPutc(hCom,0x07);b=SerialGetc(hCom);   //Servo1
SerialPutc(hCom,0x08);c=SerialGetc(hCom);    //Servo2
 
SerialPutc(hCom,0x64);d=SerialGetc(hCom);    //Desire for Servo1
SerialPutc(hCom,0x64);e=SerialGetc(hCom);    //Desire for Servo2
 




And what gets me dizzy here, is that on the 3rd/4th byte i put into controller values of the servos that i would like to setup.

Next two bytes are the desired positions for those two servos.

And,
compiling,
run..

And?

And the trouble is, that even if board echoes back (
SerialGetc(hCom);) the values correctly - robonova is NOT performing moves on the 7,8 servo - bot moves group A.



Now, due to the fact that i promised myself to code robonova1 with C, and that it is now more than just a project and slightly becomes a fight with myself - it is crucial for me to fix it up, and get this piece of servos running correctly.


Ok, so ideas:

- I think there should be some Sleep implemented, but the question is how often, how long ? Maybe after each sent character / received character i need to sleep for some ms ?

- If above is not the trick, then what? i am thinking of a command WAIT in robobasic - it has to WAIT for smth, for some bytes receieved from boards saying "Ok, i am ready to proceed futher ?" - is this a 0x00 byte sent via board?



Having all that in mind, i know that i am closer than futher - but there is still some piece missing...


i-Bot, pls.. ;)
Ok, went through totally separate implementation to see if 0xEB does all the magic thing, and using this - i would be able to code MOVE24, MOVEG6A and others.

Now, within ROBOBASIC in the beggining i do:

PTP SETON
PTP ALLON

'== motor diretion setting ======================
DIR G6A,1,0,0,1,0,0
DIR G6B,1,1,1,1,1,1
DIR G6C,0,0,0,0,0,0
DIR G6D,0,1,1,0,1,0

'== motor start position read ===================
GETMOTORSET G6A,1,1,1,1,1,0
GETMOTORSET G6B,1,1,1,0,0,0
GETMOTORSET G6C,1,1,1,0,0,0
GETMOTORSET G6D,1,1,1,1,1,0
SPEED 5
MOTOR G24



What is always to be used in my project.

As all my motors are on, and the speed is set - i would like to perform a movement of servoes 7,8 to position 0x64 - which stands for the 'middle'.


Here goes the code:


Code: Select all
   
SerialPutc(hCom,0xEB);A=SerialGetc(hCom);   //SYNC MOVE
SerialPutc(hCom,0x01);a=SerialGetc(hCom);    //PTP
 
SerialPutc(hCom,0x07);b=SerialGetc(hCom);   //Servo1
SerialPutc(hCom,0x08);c=SerialGetc(hCom);    //Servo2
 
SerialPutc(hCom,0x64);d=SerialGetc(hCom);    //Desire for Servo1
SerialPutc(hCom,0x64);e=SerialGetc(hCom);    //Desire for Servo2
 




And what gets me dizzy here, is that on the 3rd/4th byte i put into controller values of the servos that i would like to setup.

Next two bytes are the desired positions for those two servos.

And,
compiling,
run..

And?

And the trouble is, that even if board echoes back (
SerialGetc(hCom);) the values correctly - robonova is NOT performing moves on the 7,8 servo - bot moves group A.



Now, due to the fact that i promised myself to code robonova1 with C, and that it is now more than just a project and slightly becomes a fight with myself - it is crucial for me to fix it up, and get this piece of servos running correctly.


Ok, so ideas:

- I think there should be some Sleep implemented, but the question is how often, how long ? Maybe after each sent character / received character i need to sleep for some ms ?

- If above is not the trick, then what? i am thinking of a command WAIT in robobasic - it has to WAIT for smth, for some bytes receieved from boards saying "Ok, i am ready to proceed futher ?" - is this a 0x00 byte sent via board?



Having all that in mind, i know that i am closer than futher - but there is still some piece missing...


i-Bot, pls.. ;)
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by roboTT » Sun Apr 20, 2008 12:35 pm

Post by roboTT
Sun Apr 20, 2008 12:35 pm

Still challenging the 0xEB..

Here is the snippet from the Port sniffer set to listen on COM1:

I send the 0xEB :

Port opened by process "rn1.exe" (PID: 3684)

Request: 4/20/2008 13:28:03.65564

EB ë

Answer: 4/20/2008 13:28:03.68664 (+0.0313 seconds)

EB ë

Request: 4/20/2008 13:28:03.68664 (+0.0000 seconds)

01 .

Answer: 4/20/2008 13:28:03.70164 (+0.0156 seconds)

01 .

Request: 4/20/2008 13:28:03.73364 (+0.0313 seconds)

06 .

Answer: 4/20/2008 13:28:03.74864 (+0.0156 seconds)

06 .

Request: 4/20/2008 13:28:03.74864 (+0.0000 seconds)

01 .

Answer: 4/20/2008 13:28:03.78064 (+0.0313 seconds)

01 .

Request: 4/20/2008 13:28:03.78064 (+0.0000 seconds)

64 d

Answer: 4/20/2008 13:28:03.79564 (+0.0156 seconds)

64



So i am telling the controller that :

- i use 0XEB
- i use PTP 0x01
- i want to controll servoes from 0x06
- i want to controll 1 servo from 0x06 (0x01)
- i want to move the selected servo to 0x64


Well, seems like board is taking it allright.

But hey!
Robonova is not moving servo 0x06 to position 0x64.
Robonova does some random moves on few servoes at once...

Am i missing something, or the Protocol described in PDF is not correct ?:/
Still challenging the 0xEB..

Here is the snippet from the Port sniffer set to listen on COM1:

I send the 0xEB :

Port opened by process "rn1.exe" (PID: 3684)

Request: 4/20/2008 13:28:03.65564

EB ë

Answer: 4/20/2008 13:28:03.68664 (+0.0313 seconds)

EB ë

Request: 4/20/2008 13:28:03.68664 (+0.0000 seconds)

01 .

Answer: 4/20/2008 13:28:03.70164 (+0.0156 seconds)

01 .

Request: 4/20/2008 13:28:03.73364 (+0.0313 seconds)

06 .

Answer: 4/20/2008 13:28:03.74864 (+0.0156 seconds)

06 .

Request: 4/20/2008 13:28:03.74864 (+0.0000 seconds)

01 .

Answer: 4/20/2008 13:28:03.78064 (+0.0313 seconds)

01 .

Request: 4/20/2008 13:28:03.78064 (+0.0000 seconds)

64 d

Answer: 4/20/2008 13:28:03.79564 (+0.0156 seconds)

64



So i am telling the controller that :

- i use 0XEB
- i use PTP 0x01
- i want to controll servoes from 0x06
- i want to controll 1 servo from 0x06 (0x01)
- i want to move the selected servo to 0x64


Well, seems like board is taking it allright.

But hey!
Robonova is not moving servo 0x06 to position 0x64.
Robonova does some random moves on few servoes at once...

Am i missing something, or the Protocol described in PDF is not correct ?:/
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by i-Bot » Sun Apr 20, 2008 6:12 pm

Post by i-Bot
Sun Apr 20, 2008 6:12 pm

The pdf is not correct for this move. Check out the thread on synchro servo move. The format is EB, first servo number, count of servos to move, servo data...
The pdf is not correct for this move. Check out the thread on synchro servo move. The format is EB, first servo number, count of servos to move, servo data...
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by roboTT » Sun Apr 20, 2008 9:02 pm

Post by roboTT
Sun Apr 20, 2008 9:02 pm

Fixed.


Correct flow :

SerialPutc(hCom,0xEB);SerialGetc(hCom);//sync move
SerialPutc(hCom,0x06);SerialGetc(hCom);// start from servo no
SerialPutc(hCom,0x02);SerialGetc(hCom);// how many servoes ?
SerialPutc(hCom,0x64);SerialGetc(hCom);// servo1 pos
SerialPutc(hCom,0x64);SerialGetc(hCom);// servox pos


So, seems like no PTP in byte2.

Thanks i-Bot.
Fixed.


Correct flow :

SerialPutc(hCom,0xEB);SerialGetc(hCom);//sync move
SerialPutc(hCom,0x06);SerialGetc(hCom);// start from servo no
SerialPutc(hCom,0x02);SerialGetc(hCom);// how many servoes ?
SerialPutc(hCom,0x64);SerialGetc(hCom);// servo1 pos
SerialPutc(hCom,0x64);SerialGetc(hCom);// servox pos


So, seems like no PTP in byte2.

Thanks i-Bot.
roboTT
Savvy Roboteer
Savvy Roboteer
Posts: 62
Joined: Mon Mar 10, 2008 10:06 am

Post by tum » Mon May 19, 2008 3:07 pm

Post by tum
Mon May 19, 2008 3:07 pm

roboTT wrote:Fixed.


Correct flow :

SerialPutc(hCom,0xEB);SerialGetc(hCom);//sync move
SerialPutc(hCom,0x06);SerialGetc(hCom);// start from servo no
SerialPutc(hCom,0x02);SerialGetc(hCom);// how many servoes ?
SerialPutc(hCom,0x64);SerialGetc(hCom);// servo1 pos
SerialPutc(hCom,0x64);SerialGetc(hCom);// servox pos


So, seems like no PTP in byte2.

Thanks i-Bot.



For a minute there I thought you were programming in C for the AVR128 and then noticed the GetTickCount ;)

Are you using the comms protocol the robobasic IDE uses to communicate with the robonova servos individually? How are you finding the speed? Are you able to get realtime movements and feedback across the serial port?
roboTT wrote:Fixed.


Correct flow :

SerialPutc(hCom,0xEB);SerialGetc(hCom);//sync move
SerialPutc(hCom,0x06);SerialGetc(hCom);// start from servo no
SerialPutc(hCom,0x02);SerialGetc(hCom);// how many servoes ?
SerialPutc(hCom,0x64);SerialGetc(hCom);// servo1 pos
SerialPutc(hCom,0x64);SerialGetc(hCom);// servox pos


So, seems like no PTP in byte2.

Thanks i-Bot.



For a minute there I thought you were programming in C for the AVR128 and then noticed the GetTickCount ;)

Are you using the comms protocol the robobasic IDE uses to communicate with the robonova servos individually? How are you finding the speed? Are you able to get realtime movements and feedback across the serial port?
tum
Savvy Roboteer
Savvy Roboteer
Posts: 34
Joined: Fri Jun 08, 2007 5:28 am


11 postsPage 1 of 1
11 postsPage 1 of 1