...
POST No. 2407614
CPP groupSyncWrite/Read: does example have error?
2019-10-04 02:29:15 colinator

I'm confused about something in the example of how to do group sync read/write:


http://emanual.robotis.com/docs/en/software/dynamixel/dynamixel_sdk/sample_code/cpp_indirect_address_protocol_2_0/#cpp-indirect-address-protocol-20


In the example there, to prepare for sync reading, it does this:


packetHandler->write2ByteTxRx(portHandler, DXL_ID, ADDR_PRO_INDIRECTADDRESS_FOR_READ + 0, ADDR_PRO_PRESENT_POSITION + 0, &dxl_error); 

packetHandler->write2ByteTxRx(portHandler, DXL_ID, ADDR_PRO_INDIRECTADDRESS_FOR_READ + 2, ADDR_PRO_PRESENT_POSITION + 1, &dxl_error); 

packetHandler->write2ByteTxRx(portHandler, DXL_ID, ADDR_PRO_INDIRECTADDRESS_FOR_READ + 4, ADDR_PRO_PRESENT_POSITION + 2, &dxl_error); 

packetHandler->write2ByteTxRx(portHandler, DXL_ID, ADDR_PRO_INDIRECTADDRESS_FOR_READ + 6, ADDR_PRO_PRESENT_POSITION + 3, &dxl_error); 

packetHandler->write2ByteTxRx(portHandler, DXL_ID, ADDR_PRO_INDIRECTADDRESS_FOR_READ + 8, ADDR_PRO_MOVING, &dxl_error);



(NOTE the +0, +2, +4, etc)


but then, when it actually performs the read, it does this:


dxl_present_position = groupSyncRead.getData(DXL_ID, ADDR_PRO_INDIRECTDATA_FOR_READ, LEN_PRO_PRESENT_POSITION);
dxl_moving = groupSyncRead.getData(DXL_ID, ADDR_PRO_INDIRECTDATA_FOR_READ + LEN_PRO_PRESENT_POSITION, LEN_PRO_MOVING);


where LEN_PRO_MOVING is 4.


Why does it not read dxl_moving from  ADDR_PRO_INDIRECTDATA_FOR_READ + 8?



2019-10-04 02:29:15
colinator
2019-10-11 17:16:44 Will Son

Hi,


Sync Read is only available for the data in continuous address.

In the default example, it is trying to read / write multiple data from discontinuous address, so it uses indirect address and data to link them to a sequential address.

Please refer to Indirect Address / Data section and Sync Read instruction.


Thank you.

2019-10-11 17:16:44
willson
Reply
웹에디터 시작 웹 에디터 끝