Skip to main content

A Python Driver for MIT Mini-Cheetah Actuator which uses SocketCAN for communication.

Project description

Downloads

Python Motor Driver for Mini Cheetah-type Actuators from T-Motor/CubeMars

This driver was developed at the Underactuated Lab in Robotics Innovation Center at DFKI GmbH, Bremen.

It assumes the use of a CAN to USB adapter (such as PEAK System's PCAN-USB or ESD's CAN-USB/2) connected to a linux (tested on Ubuntu) computer. The SocketCAN interface is used, thus allowing the use of Python Socket library.

Initial tests show communication (send-reply) frequencies of ~800Hz using PCAN-USB and ~1500Hz using ESD CAN-USB/2 with a single motor connected.

Dependencies:

  • bitstring

Install via:

pip3 install bitstring

Documentation

Pre-requisites:

  • Setting up the CAN interface:

    • Run this command and make sure that can0 (or any other can interface depending on the system)shows up as an interface after connecting the USB cable to your laptop: ip link show

    • Configure the can0 interface to have a 1 Mbaud communication frequency: sudo ip link set can0 type can bitrate 1000000

    • To bring up the can0 interface, run: sudo ip link set up can0

  • To change motor parameters such as CAN ID or to calibrate the encoder, a serial connection is used. The serial terminal used on linux for this purpose is screen. Example usage:

sudo apt-get install screen
screen /dev/ttyUSB0 921600

Usage:

Import: from motor_driver.canmotorlib import CanMotorController if installed via pip. Otherwise, adjust import statement based on system's PYTHONPATH (e.g. when cloned from GitHub).

Example Motor Initialization: motor = CanMotorController(can_socket='can0', motor_id=0x01, motor_type='AK80_6_V2', socket_timeout=0.5)

Available Functions:

  • enable_motor()
  • disable_motor()
  • set_zero_position()
  • send_deg_command(position_in_degrees, velocity_in_degrees, Kp, Kd, tau_ff):
  • send_rad_command(position_in_radians, velocity_in_radians, Kp, Kd, tau_ff):
  • change_motor_constants(P_MIN_NEW, P_MAX_NEW, V_MIN_NEW, V_MAX_NEW, KP_MIN_NEW, KP_MAX_NEW, KD_MIN_NEW, KD_MAX_NEW, T_MIN_NEW, T_MAX_NEW)

All motor communication functions return current position, velocity, torque in SI units except for send_deg_command. change_motor_constants does not return anything.

Supported Motor Configurations:

  • AK80-6 (From Cubemars, Firmware versions V1, V1.1, and V2): motor_type='AK80_6_V1', motor_type='AK80_6_V1p1' and motor_type='AK80_6_V2'
  • AK80-9 (From Cubemars, Firmware version V1.1 and V2): motor_type='AK80_9_V1p1' and motor_type='AK80_9_V2'
  • AK70-10 (From Cubemars, Firmware version V1.1): motor_type='AK70_10_V1p1'
  • AK10-9 (From Cubemars, Firmware version V1.1): motor_type='AK10_9_V1p1'. TODO: The temperature and error codes are received but not yet decoded for the new firmware for this motor.
# Working parameters for AK80-6 V1.0 firmware
AK80_6_V1_PARAMS = {
                "P_MIN" : -95.5,
                "P_MAX" : 95.5,
                "V_MIN" : -45.0,
                "V_MAX" : 45.0,
                "KP_MIN" : 0.0,
                "KP_MAX" : 500,
                "KD_MIN" : 0.0,
                "KD_MAX" : 5.0,
                "T_MIN" : -18.0,
                "T_MAX" : 18.0,
                "AXIS_DIRECTION" : -1
                }

# Working parameters for AK80-6 V1.1 firmware
AK80_6_V1p1_PARAMS = {
                "P_MIN" : -12.5,
                "P_MAX" : 12.5,
                "V_MIN" : -22.5,
                "V_MAX" : 22.5,
                "KP_MIN" : 0.0,
                "KP_MAX" : 500,
                "KD_MIN" : 0.0,
                "KD_MAX" : 5.0,
                "T_MIN" : -12.0,
                "T_MAX" : 12.0,
                "AXIS_DIRECTION" : -1
                }

# Working parameters for AK80-6 V2.0 firmware
AK80_6_V2_PARAMS = {
                "P_MIN" : -12.5,
                "P_MAX" : 12.5,
                "V_MIN" : -38.2,
                "V_MAX" : 38.2,
                "KP_MIN" : 0.0,
                "KP_MAX" : 500.0,
                "KD_MIN" : 0.0,
                "KD_MAX" : 5.0,
                "T_MIN" : -12.0,
                "T_MAX" : 12.0,
                "AXIS_DIRECTION" : 1
                }

# Working parameters for AK80-9 V1.1 firmware
AK80_9_V1p1_PARAMS = {
                "P_MIN" : -12.5,
                "P_MAX" : 12.5,
                "V_MIN" : -22.5,
                "V_MAX" : 22.5,
                "KP_MIN" : 0.0,
                "KP_MAX" : 500,
                "KD_MIN" : 0.0,
                "KD_MAX" : 5.0,
                "T_MIN" : -18.0,
                "T_MAX" : 18.0,
                "AXIS_DIRECTION" : 1
                }

# Working parameters for AK80-9 V2.0 firmware
AK80_9_V2_PARAMS = {
                    "P_MIN" : -12.5,
                    "P_MAX" : 12.5,
                    "V_MIN" : -25.64,
                    "V_MAX" : 25.64,
                    "KP_MIN" : 0.0,
                    "KP_MAX" : 500.0,
                    "KD_MIN" : 0.0,
                    "KD_MAX" : 5.0,
                    "T_MIN" : -18.0,
                    "T_MAX" : 18.0,
                    "AXIS_DIRECTION" : 1
                    }

// Working parameters for AK70-10 V1.1 firmware
AK70_10_V1p1_params = {
                      "P_MIN" :  -12.5,
                      "P_MAX" :  12.5,
                      "V_MIN" :  -50,
                      "V_MAX" :  50,
                      "KP_MIN" :  0,
                      "KP_MAX" :  500,
                      "KD_MIN" :  0,
                      "KD_MAX" :  5,
                      "T_MIN" :  -24.0,
                      "T_MAX" :  24.0,
                      "AXIS_DIRECTION" :  1
                    }

# Working parameters for AK10-9 V1.1 firmware
AK10_9_V1p1_PARAMS = {
                "P_MIN" : -12.5,
                "P_MAX" : 12.5,
                "V_MIN" : -50.0,
                "V_MAX" : 50.0,
                "KP_MIN" : 0.0,
                "KP_MAX" : 500,
                "KD_MIN" : 0.0,
                "KD_MAX" : 5.0,
                "T_MIN" : -65.0,
                "T_MAX" : 65.0,
                "AXIS_DIRECTION" : -1
                }

To add a new constants configuration use the change_motor_constants function or create an issue with the constants and motor information on the GitHub page to be added to the driver.

Known Issues

Issue Fixed: When having 2 motors on the CAN bus with either PCAN CAN-USB or ESD CAN-USB/2, sometimes the motors experience an initial short kick/impulse at when they are enabled again after being disabled. This was fixed.

As this is experimental software, there might be other unknown issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file mini-cheetah-motor-driver-socketcan-0.3.4.tar.gz.

File metadata

File hashes

Hashes for mini-cheetah-motor-driver-socketcan-0.3.4.tar.gz
Algorithm Hash digest
SHA256 5828a0c963bc75b25b78c1e9b1d27f71e895c226556b4574f1bf0ee04947d218
MD5 00860f4d0568f428252d8147d467eb98
BLAKE2b-256 2e1be39618314f58c96b647cc3a90760d7c9a8feb17e9958cb64c5260f88e9ca

See more details on using hashes here.

File details

Details for the file mini_cheetah_motor_driver_socketcan-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mini_cheetah_motor_driver_socketcan-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e3b32ff65b9b3c811f0ecb0bf8d11cdd956503ee7487fc06797632f93e1525c4
MD5 2c40fa5b85ded70298ce45bbc240332d
BLAKE2b-256 9adfe42266e022f2cda41a673564b01ad21a7ee51624608c15f3dfa9d94a62f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page