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.'s 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 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:

  1. The Dynamixel_IO Matlab class currently only supports Dynamixel motors using 10-bit encoders (ie. AX and RX line of motors). However, a variant (not yet committed to the repository) has been created to support most functions associated with motors using 12-bit encoders (eg. 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 residing only in the repository.
  3. Pre-compiled libraries are available only for Linux (32- & 64-bit) and Windows (32- and 64-bit). Hence, this API does not currently support use on Mac OSX. Additionally, if run on Windows 64-bit, the user will be required to install a compiler that Matlab supports (eg. for running MEX files)
  4. This API will soon 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 motor, specified by the user, to a position (also specified by the user): test_case_command_single_motor.m

Some notes:

  1. Find your port number: The red FTDI breakout board is connected to the PC via USB. On Linux, you should find a device file for it in '/dev'. Type ls /dev/ttyUSB* to see 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 (in radians) you'd like the motor to travel to. Remember, each line of motors has a set of specifications that document the minimum/maximum range of motion.
  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 you motor move to the specified position.

Exercise(s):

  1. You have 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: 2023/03/06 10:31 by 127.0.0.1