====== How To Modify Dynamixel SDK code ====== **Author:** Yunki hong(05/2019), Myong Geon Kim(07/2019), Brandon Seo(Current) Email: hyunduck1024@gmail.com \\ **Date:** Last modified on <06/20/19> \\ **Keywords:** Tutorial, how to, step-by-step, dynamixel-sdk \\ {{ mgkim:ds_1.jpg?200 |}} \\ This tutorial is an exercise session which means not only reading this session, please trying to write your own code. \\ \\ ===== Motivation and Audience ===== \\ \\ Readers of this tutorial assumes the reader has the following background and interests: \\ \\ \\ * Basic background of CPP * Full understanding of dynamixel set up : [[dynamixel_set_up|Dynamixel Set Up]] \\ \\ The rest of this tutorial is presented as follows: * [[dynamixel_modification#wheel_mode|Wheel mode]] * [[dynamixel_modification#actuationg_time|Control actuating time]] * [[dynamixel_modification#direction_change|Direction Change]] * Final Words \\ \\ ==== Wheel mode ==== \\ \\ Default setting of dynamixel has CCW angle limitation. \\ If we want to actuate dynamixel both CW and CCW, we need to unlock that limitation. \\ We call it "Wheel mode". \\ For unlock CCW limitation, We will use \\ \\ dxl_comm_result = packetHandler->write1ByteTxRx(portHandler, DXL1_ID, ADDR_CCW_LIMIT_ANGLE, 0, &dxl_error); \\ \\ function. \\ {{ mgkim:ds_13.jpg?400 |}}{{ mgkim:ds_14.jpg?400 |}} \\ Here we can find an address for CCW Limit angle. \\ \\ \\ ======================================================================================================= \\ \\ Exercise. Make the code for two Dynamixels to actuate in wheel mode on the same speed via Input speed. \\ \\ Here is an {{https://drive.google.com/file/d/1Lh8SF3xtb9EvSjx5d_uSam0nXvXJ-Hkg/view?usp=sharing|answer}} \\ \\ ======================================================================================================= \\{{youtube>PdrjzqILxCc?medium}} \\ \\ ==== Control actuating time ==== \\ \\ For controlling actuating time, we will use "sleep" function in "window.h" header file. \\ Search on Google if you have no idea about sleep function. \\ function is \\ \\ Sleep(time) \\ \\ In this function, Time is millisecond(1/1000 second). \\ \\ ======================================================================================================= \\ \\ Exercise. Modify previous code for Dynamixels to actuate during input time \\ Here is {{https://drive.google.com/file/d/1_BO2PKD7thJg1jXfoisZ7NxwpFquCt0c/view?usp=sharing|answer}} \\ \\ ======================================================================================================= \\{{youtube>0GZz-wDg9FM?medium}} \\ \\ ==== Direction Change ==== \\ \\ Know how to change the direction of rotation is important for controlling Dynamixel. \\ Dynamixel speed has its own speed scale. \\ Read e-manual http://emanual.robotis.com/docs/en/dxl/mx/mx-28/#control-table-data-address \\ {{ mgkim:ds_15.jpg?600 |}} \\ As you can see, \\ \\ CW speed + 1024 = CCW speed \\ \\ Now you know how to change direction. \\ \\ ======================================================================================================= \\ \\ Exercise. Modify previous code for two Dynamixels to rotate on different direction. \\ \\ Answer : \\ dxl_comm_result = packetHandler->write2ByteTxRx(portHandler, DXL1_ID, ADDR_MOVING_SPEED, spd, &dxl_error); \\ dxl_comm_result = packetHandler->write2ByteTxRx(portHandler, DXL2_ID, ADDR_MOVING_SPEED, spd + 1024, &dxl_error); \\ \\ ======================================================================================================= \\ \\ ===== Multiple Dynamixel Control ===== when you understand all above of the code, you can finally control each dynamixel. {{youtube>T0dDO6DWILY?medium}} \\ Here is the{{https://drive.google.com/file/d/13vAPs-_guWaK6iAprfK9gJNgOi7UekHC/view?usp=sharing=sharing|answer}} Now you know how to move gantry. \\ ==== Final Words ==== For questions, clarifications, etc, Email: m.geon.kim@gmail.com