User Tools

Site Tools


dynamixel:sw_prelim

Dynamixel Motors: Matlab API


Here, we walk through set up and example scripts to communicate with connected Dynamixel motors, using Matlab.

Prerequisite: This assumes instructions in hardware setup have been completed.

Clone Repositories

Clone the **dynamixel** repository maintained on Georgia Tech GitHub Enterprise: git@github.gatech.edu:ivabots/dynamixel.git

Note: Walk-through instructions to set up and clone Git repositories can be found here .

Dynamixel Matlab API

Within the repository, a Dynamixel_IO Matlab class has been created to facilitate convenient communication with and operation of the motors: code/matlab/Dynamixel_IO/Dynamixel_IO.m

Take some time to explore the class definition and high-level methods available.

Disclaimer(s):

  1. The Dynamixel_IO Matlab class only supports Dynamixel motors using 10-bit encoders (e.g. AX and RX line of motors). A variant (not yet committed to the repository) has been created to support most functions associated to motors that use 12-bit encoders (e.g. MX line of motors) and is available upon request.
  2. The Dynamixel_IO class relies on pre-compiled lower-level libraries to communicate with the motors. It presumes the libraries are located in a specific relative path. If you clone the dynamixel repo and use the Dynamixel_IO class from the repository location, there should be no problem. If you move the Dynamixel_IO.m file out of the cloned repository location and use it elsewhere, however, it may not be able to find dependency libraries expected to reside within in the repository.
  3. Pre-compiled libraries are available only for Linux (32- & 64-bit) and Windows (32- and 64-bit). This API doesn't currently support Mac OSX. Additionally, if run on Windows 64-bit, the user may be required to install a compiler that Matlab supports (e.g. for running MEX compilations)
  4. This API will eventually be updated to use ROBOTIS' latest software interface.

Test Script and Exercise

Within the dynamixel repo, navigate to: code/matlab/Dynamixel_IO/test_cases.

Open and view the following test script which will command a (user-specified) motor ID to a desired position : test_case_command_single_motor.m

Some notes:

  1. Find your port number: A serial-to-USB device (e.g. ROBOTIS U2D2 or a red FTDI breakout board) should be connected to the PC via USB. On Linux, you should find a device file for it within '/dev'. Use the terminal command ls /dev/ttyUSB* to view a list of device files that may correspond to this device. The number after 'ttyUSB' is your port number. Use that as the 1st argument to dxl.connect( … ); in the test script.
  2. Motor ID: You will need to know the ID of the motor you'd like to command using this script. Enter that value in the line, motor_id = 17;, replacing 17 with your motor's ID.
  3. Command a position: In the line, dest_pos = pi/6;, replace pi/6 with a motor position (radians) you'd like the motor to travel to. Each Dynamixel motor product line has a set of specifications that document the minimum/maximum range of motion. As an example, the AX-12 specifications can be found on its e-manual page . Every motor model has its own e-manual (Google the motor model name + “Dynamixel e-manual”).
  4. Run the script: Once you're done, hit the 'Play' button and follow any instructions in the prompt. If everything works out, you should see the desired motor move to the specified position.

Exercise(s):

  1. You've commanded a single motor to a single angular position. Can you now modify the Matlab script to command the motor to smoothly travel a sinusoidal trajectory (eg. with user-adjustable frequency, amplitude and phase offset) over time? Demonstrate this trajectory (with your choice of frequency, amplitude, phase, etc.) over 5 sine periods.
  2. Now that you've commanded a time-varying trajectory for a single motor. Command 2 different trajectories for 2 motors! Make sure that both motors are following different sinusoidal trajectories - eg. they both can execute a sinusoidal trajectory over time, but each one should follow a sine wave defined by different parameters (eg. different frequency, amplitude and/or phase offset).

Previous: Hardware Setup Main (Dynamixel) Next: ROS

dynamixel/sw_prelim.txt · Last modified: 2024/09/23 13:33 by typos