Warning

This documention is in the process of being updated for ODrive Pro

odrivetool

The odrivetool is the accompanying PC program for the ODrive. It’s main purpose is to provide an interactive shell to control the device manually, as well as some supporting functions like firmware update.

Installation

Refer to the Getting Started guide.

Type odrivetool --help to see what features are available.

Multiple ODrives

By default, odrivetool will connect to any ODrive it finds. If this is not what you want, you can select a specific ODrive.

To find the serial number of your ODrive, run odrivetool, connect exactly one ODrive and power it up. You should see this:

Connected to ODrive 306A396A3235 as odrv0
In [1]:

306A396A3235 is the serial number of this particular ODrive. If you want odrivetool to ignore all other devices you would close it and then run:

odrivetool --serial-number 306A396A3235

Commands and Objects

The ODrive Tool console provides aliases and wrappers for various entities in the odrive Python package. These are optimized for interactive use. When you write your own Python script that does import odrive, these wrappers are not available.

shell.odrv0: ODrive

First ODrive that is connected. The next ODrive is called odrv1 etc…

shell.dump_errors(odrv: ODrive)

Alias for odrive.utils.dump_errors()

shell.start_liveplotter(*args)

Alias for odrive.utils.start_liveplotter()

shell.status(config: odrive.config.MachineConfig)

Wrapper for config.show_status(odrives)

shell.apply(config: odrive.config.MachineConfig)

Wrapper for config.apply(odrives)

shell.calibrate(config: odrive.config.MachineConfig)

Wrapper for config.calibrate(odrives)

shell.odrives

Dictionary of all currently connected ODrives

Liveplotter

Liveplotter is used for the graphical plotting of odrive parameters (i.e. position) in real time. To start liveplotter, close any other instances of liveplotter and run

odrivetool liveplotter

from a new anaconda prompt window. By default two parameters are plotted on startup; the encoder position of axis 1 and axis 2. In the below example the motors are running in closed_loop_control while they are being forced off position by hand.

_images/liveplotter-pos-estimate.png

To change what parameters are plotted open odrivetool (located in Anaconda3\Scripts or ODrive-master\tools) with a text editor and modify the liveplotter function:

# If you want to plot different values, change them here.
# You can plot any number of values concurrently.
cancellation_token = start_liveplotter(lambda: [
    odrv0.encoder_estimator0.pos_estimate,
    odrv0.encoder_estimator0.pos_estimate,
])

For example, to plot the approximate motor torque [Nm] and the velocity [RPM] of axis0, you would modify the function to read:

# If you want to plot different values, change them here.
# You can plot any number of values concurrently.
cancellation_token = start_liveplotter(lambda: [
    ((odrv0.encoder_estimator0.vel_estimate*60), # turns/s to rpm
    ((odrv0.axis0.motor.current_control.Iq_setpoint * my_odrive.axis0.motor.config.torque_constant), # Torque [Nm]
])

In the example below the motor is forced off axis by hand and held there. In response the motor controller increases the torque (orange line) to counteract this disturbance up to a peak of 500 N.cm at which point the motor current limit is reached. When the motor is released it returns back to its commanded position very quickly as can be seen by the spike in the motor velocity (blue line).

_images/liveplotter-iq-omega.png

Liveplotter Torque Velocity Plot

To change the scale and sample rate of the plot modify the following parameters located at the beginning of utils.py (located in Anaconda3\Lib\site-packages\odrive):

data_rate = 100
plot_rate = 10
num_samples = 1000

For more examples on how to interact with the plotting functionality refer to these Matplotlib examples.

Liveplotter from Interactive odrivetool Instance

You can also run start_liveplotter(...) directly from the interactive odrivetool prompt. This is useful if you want to issue commands or otherwise keep interacting with the odrive while plotting.

For example you can type the following directly into the interactive prompt:

start_liveplotter(lambda: [odrv0.encoder_estimator0.pos_estimate])

Just like the examples above, you can list several parameters to plot separated by comma in the square brackets. In general, you can plot any variable that you are able to read like normal in odrivetool.