Tuesday, August 14, 2018

How to use AX12 (Robotis Dynamixel) with Python by using Dynamixel SDK (in Windows)

Robotis Dynamixel is not a normal servo motor. In order to control them, we need to send proper packet through serial communication. This is a kind of barrier for the beginners to make a code because there is something to study. You will need to calculate a checksum byte, find instruction code in the manual and so on. But, don't worry, there is a well-made SDK which is given by Robotis. The only one problem is that the documentation is written by professional. So, I am going to share the way as detailed as possible. If you just follow a few steps, Dynamixel would say "hello world"

1. Install Python



installation is very straightforward. 

2. Download SDK files 



Click "Clone or Donwload"  and "Download ZIP"

3. Install SDK 

Extract the zip file we downloaded




open the python folder




Copy (Control + C) the path  (the path may different to yours)



Open "Command Prompt" (in start menu, type 'cmd' and this icon will be appeared)

 


type cd and paste the path, press enter



type  "python setup.py install" and done!






4. Check Your Com Port


Plug your "USB2Dynamixel" to your PC



Open "Device Manager" to check your Com Port





In my case, it was COM4

5. Modify Com Port in the source code (.\python\tests\protocol1_0\ping.py)


# Default setting
DXL_ID                  = 1
BAUDRATE                = 1000000
DEVICENAME              = 'COM4'




6. Test (ping.py)




7. Run motor "read_write.py"


As the drawing, if you get ping Succeeded, then everything is ready to use. Let's move the AX12. In order to run AX12, we need to use read_write.py file. I just changed Com Port and Baud rate but there was some problem. The motor didn't react at all. I fount the problem in the instruction table. we need to change code like this


We also need to change here because AX12 returns only 2 Bytes.



Because the control table address was different. So, we need to change address.
Let's play with this code!




Conclusion

Personally, I hope there is more detailed information for the series. Robotis has a lot of Dynamixel series. I have to make a instruction table for AX12 in order to use every features of AX12. Next time, I will share you some more code for AX12.

No comments:

Post a Comment

URDF Link origin test