ROBOTIS-GIT / DynamixelSDK

ROBOTIS Dynamixel SDK (Protocol1.0/2.0)
http://emanual.robotis.com/docs/en/software/dynamixel/dynamixel_sdk/overview/
Apache License 2.0
464 stars 410 forks source link

Question about Current Control #533

Closed EceChaik closed 2 years ago

EceChaik commented 3 years ago

ISSUE TEMPLATE ver. 1.2.0

Please fill this template for more accurate and prompt support.

  1. Which DYNAMIXEL SDK version do you use?

    • ex) 3.7.51
  2. Which programming language/tool do you use?

    • ex) ROS
  3. Which operating system do you use?

    • ex) Ubuntu 16.04
  4. Which USB serial converter do you use?

    • ex) U2D2
  5. Which DYNAMIXEL do you use?

    • ex) XM430-W350
  6. Have you searched the issue from the closed issue threads? Yes

  7. Please describe the issue in detail Hi, I am trying to use ROS to implement current control on the dynamixels. My problem is that all the "write" functions only accept uint types, whereas the current can be positive or negative. Indeed, I have managed to successfully send positive current commands to the dynamixel, but I don't know how to use the SDK to send negative integers and none of the example codes treat this. Could I get some help on how to achieve this? Thanks

  8. How can we reproduce the issue?

ROBOTIS-Will commented 3 years ago

Hi @EceChaik I'm sorry about the delayed response. DYNAMIXEL takes 2's complement for the negative values. https://emanual.robotis.com/docs/en/dxl/x/xm430-w350/#control-table-data-address

For example, if you want to send a negative value of -100 to 2byte Goal Current address, you can simply (uint16_t) converted signed value. 2byte unsigned representation for -100 is 0xFF 0x9C, and since DYNAMIXEL use little endian, the actual data you should send to the Goal Current address will be 0x9C 0xFF. Thank you.