Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can send use a sync_write #1

Open
metropt opened this issue Sep 8, 2016 · 3 comments
Open

Can send use a sync_write #1

metropt opened this issue Sep 8, 2016 · 3 comments

Comments

@metropt
Copy link

metropt commented Sep 8, 2016

I'm trying to write the goal pos to two motors however I need to send the following packet two times to make it work whatever id I choose first only the first motor on the chain is activated 🈂️

            dxl_set_txpacket_id( 254 );
            dxl_set_txpacket_length( 10 ); //Length (L+1) X N + 4   (L: Data Length per RX-64, N: the number of RX-64s)
            dxl_set_txpacket_instruction( 131 );
            dxl_set_txpacket_parameter( 0, GOAL_POSITION_L );
            dxl_set_txpacket_parameter( 1, 2 );
            dxl_set_txpacket_parameter( 2, 2 );
            dxl_set_txpacket_parameter( 3, dxl_get_lowbyte( goal_pos_[0] ) );
            dxl_set_txpacket_parameter( 4, dxl_get_highbyte( goal_pos_[0] ) );
            dxl_set_txpacket_parameter( 5, 1 );
            dxl_set_txpacket_parameter( 6, dxl_get_lowbyte( goal_pos_[0] ) );
            dxl_set_txpacket_parameter( 7, dxl_get_highbyte( goal_pos_[0] ) );
@Xevel
Copy link
Owner

Xevel commented Sep 8, 2016

Hi!
I'm not really sure what is going wrong here, are you sure the rest of the setup is OK?
Can you move the second servo with a write_data packet?

And also, if you are using the version of the lib I have on this repo, why don't you simply use the sync_write functions instead of building the packet yourself (less error-prone)?
Sync_read example that also shows the sync_write

@metropt
Copy link
Author

metropt commented Sep 13, 2016

Hello,

I tried the sync_write from you lib and it works well however now I'm getting problems with sync_read. I got a lot incorrect status packet:

[ INFO] [1473761250.694434838]: 1=559
[ INFO] [1473761250.694477383]: 2=300

[ INFO] [1473761250.714561671]: 1=559
[ INFO] [1473761250.714606049]: 2=300

[ INFO] [1473761250.734441294]: 1=559
[ INFO] [1473761250.734487448]: 2=300

[ INFO] [1473761250.754562067]: 1=559
[ INFO] [1473761250.754605699]: 2=300

[ INFO] [1473761250.774435077]: 1=559
[ INFO] [1473761250.774478255]: 2=300

[ INFO] [1473761250.794558795]: 1=559
[ INFO] [1473761250.794600594]: 2=300

...

[ INFO] [1473761251.274591423]: 1=559
[ INFO] [1473761251.274632121]: 2=300

[ INFO] [1473761251.294593208]: 1=559
[ INFO] [1473761251.294635295]: 2=300

[ INFO] [1473761251.314467278]: 1=559
[ INFO] [1473761251.314507783]: 2=65535

[ INFO] [1473761251.334477456]: 1=559
[ INFO] [1473761251.334546297]: 2=300

[ INFO] [1473761251.354603917]: 1=559
[ INFO] [1473761251.354650028]: 2=65535

[ INFO] [1473761251.374588057]: 1=559
[ INFO] [1473761251.374633864]: 2=300

[ INFO] [1473761251.394576031]: 1=559
[ INFO] [1473761251.394620455]: 2=300

[ INFO] [1473761251.414601759]: 1=559
[ INFO] [1473761251.414647350]: 2=300

[ INFO] [1473761251.434592444]: 1=559
[ INFO] [1473761251.434632395]: 2=65535

[ INFO] [1473761251.454596015]: 1=559
[ INFO] [1473761251.454638298]: 2=300

[ INFO] [1473761251.474575276]: 1=559
[ INFO] [1473761251.474634469]: 2=65535

[ INFO] [1473761251.494566517]: 1=559
[ INFO] [1473761251.494618563]: 2=300

[ INFO] [1473761251.514566383]: 1=559
[ INFO] [1473761251.514618284]: 2=65535

[ INFO] [1473761251.534442431]: 1=559
[ INFO] [1473761251.534496357]: 2=301

[ INFO] [1473761251.554566425]: 1=559
[ INFO] [1473761251.554617983]: 2=65535

[ INFO] [1473761251.574567989]: 1=559
[ INFO] [1473761251.574622302]: 2=300

[ INFO] [1473761251.594581237]: 1=559
[ INFO] [1473761251.594637699]: 2=65535

[ INFO] [1473761251.614568112]: 1=559
[ INFO] [1473761251.614619575]: 2=300

[ INFO] [1473761251.634567871]: 1=559
[ INFO] [1473761251.634619959]: 2=65535

[ INFO] [1473761251.654570137]: 1=559
[ INFO] [1473761251.654623414]: 2=300

[ INFO] [1473761251.674563754]: 1=559
[ INFO] [1473761251.674613520]: 2=65535

[ INFO] [1473761251.694447221]: 1=559
[ INFO] [1473761251.694503734]: 2=300

[ INFO] [1473761251.714566023]: 1=559
[ INFO] [1473761251.714616845]: 2=65535

COMM_RXCORRUPT: Incorrect status packet!

[ INFO] [1473761251.754587500]: 1=559
[ INFO] [1473761251.754662450]: 2=65535

COMM_RXCORRUPT: Incorrect status packet!

[ INFO] [1473761251.794586438]: 1=559
[ INFO] [1473761251.794654394]: 2=65535

^CCOMM_RXCORRUPT: Incorrect status packet!

[ INFO] [1473761251.834603526]: 1=559
[ INFO] [1473761251.834656415]: 2=65535

COMM_RXCORRUPT: Incorrect status packet!

[wiigo_active_camera-1] killing on exit
[ INFO] [1473761251.874591459]: 1=559
[ INFO] [1473761251.874650561]: 2=300

COMM_RXCORRUPT: Incorrect status packet!

The code I'm using:

dxl_sync_read_start( PRESENT_POSITION_L, 2 );
dxl_sync_read_push_id( 1 );
dxl_sync_read_push_id( 2 );
dxl_sync_read_send();

CommStatus = dxl_get_result();
if( CommStatus == COMM_RXSUCCESS )
{
   ROS_INFO("%d=%d ", 1 , dxl_sync_read_pop_word());
   ROS_INFO("%d=%d ", 2 , dxl_sync_read_pop_word());
 }
 else
 {
   PrintCommStatus(CommStatus);
 }

If I read only one sensor like this:

ROS_INFO("%d=%d ", 1 , dxl_read_word(1,PRESENT_POSITION_L) );

it works ok.

Any idea?

My setup:
image

@Xevel
Copy link
Owner

Xevel commented Sep 13, 2016

Hmm, not sure, but have you set Return Delay Time to zero on all servos? the timeout in the sync_read code is pretty short, could have something to do with it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants