Skip to main content

Motor Control Software for Soft Exoskeleton

Coverage Status Docker Image CI

Motor control for the CubeMars AK60-6 actuator module used in Aries soft-exosuit development.

Current Status

  • Primary interface: CAN on Jetson Orin Nano via Linux SocketCAN
  • Current maintained CAN path: MIT-only control
  • Supported high-level helpers: set_position(), set_velocity(), set_current(), stop()
  • UART support remains available for compatibility and earlier bring-up workflows

This repository is the motor-module codebase, not a full exosuit application. Its current focus is a modular actuator-control layer plus the bench-side scripts used to validate it.

Key Features

  • Transport-independent motor abstraction through BaseMotor
  • Maintained SocketCAN backend for the CubeMars AK60-6
  • MIT-only CAN control path with one consistent command model
  • Background command refresh, feedback decoding, cached state handling, and staged recovery
  • Bench-validation scripts for MIT mode, position stepping, velocity verification, and plotting

Installation

For normal development, testing, and analysis:

uv sync --all-groups
source .venv/bin/activate

If you only want to install the package itself:

uv pip install -e .

CAN Setup on Jetson Orin Nano

Install the tracked can0.service once so can0 comes up automatically on boot:

sudo cp can0.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable can0.service
sudo systemctl start can0.service

This brings can0 up at 1 Mbps with bus-off auto-recovery.

Useful checks:

systemctl status can0.service
sudo systemctl restart can0.service
ip -details link show can0

Manual setup

If you do not want to use the service, configure the interface manually:

sudo ./setup_can.sh

Important Hardware Note

If the R-Link / UART cable is connected to the motor, CAN commands may be silently ignored even though feedback frames are still visible on the bus. For CAN operation, disconnect the UART cable and then reset the CAN interface.

1. Confirm MIT/CAN communication

sudo ./setup_can.sh
.venv/bin/python scripts/mit_mode_test.py --motor-id 0x03

2. Validate sustained velocity behavior

.venv/bin/python scripts/verify_set_velocity.py --motor-id 0x03 --velocity-erpm 3000

3. Run repeated MIT position stepping

.venv/bin/python scripts/mit_position_steps.py --motor-id 0x03 --duration 180 --angle-deg 50 --velocity-deg-s 100

4. Generate comparison plots from recorded CSV files

.venv/bin/python scripts/plot_graph.py velocity --data-root CSV --out-dir CSV/plots
.venv/bin/python scripts/plot_graph.py position --data-root CSV --out-dir CSV/plots

Python API

The default convenience alias is the CAN motor class:

from motor_python import Motor

with Motor(motor_can_id=0x03) as motor:
    motor.enable_mit_mode()
    motor.set_velocity(3000)
    motor.set_position(90.0)
    motor.stop()

For direct access to the specific implementations:

from motor_python.cube_mars_motor_can import CubeMarsAK606v3CAN
from motor_python.cube_mars_motor import CubeMarsAK606v3

Main CAN lifecycle methods

Method Purpose
enable_mit_mode() Enter MIT mode
disable_mit_mode() Exit MIT mode
check_communication() Verify that the motor responds on the bus
get_status() Return the latest cached MotorState
close() Stop and close transport resources

Main CAN control methods

Method Purpose
set_position(position_degrees) MIT-backed position command
set_velocity(velocity_erpm) MIT-backed velocity command. Zero releases the motor via stop()
set_current(current_amps) Interpreted as MIT torque feedforward
set_mit_mode(pos_rad, vel_rad_s, kp, kd, torque_ff_nm) Direct MIT command
stop() Neutral MIT command, disable MIT mode, release the motor

Useful Bench Scripts

These are the maintained scripts that matter most for the current implementation:

Script Purpose
scripts/mit_mode_test.py Focused MIT/CAN protocol validation
scripts/verify_set_velocity.py Bench verification of set_velocity()
scripts/mit_position_steps.py Long-run MIT position stepping for bench tests
scripts/plot_graph.py Chapter-4-style overlay and summary plots from recorded CSV files
scripts/diagnose_can.py CAN bus diagnostics and recovery support
scripts/scan_ids.py CAN ID discovery
scripts/reset_degree.py Practical MIT recentering helper

Additional exploratory and legacy scripts remain under scripts/, but they are not the primary maintained validation path.

Testing

Run unit tests:

make test

Run CAN hardware tests:

make test-hardware-can

Run all hardware tests:

make test-hardware-all

Project Structure

can0.service                    systemd unit for automatic can0 startup
setup_can.sh                    manual CAN setup and reset helper
src/motor_python/               package source
scripts/                        bench and validation scripts
tests/                          unit and hardware-oriented tests
data/csv_logs/.gitkeep          placeholder for locally generated CSV logs
Test Rig CAD files/             CAD assets for the bench rig

Notes on Scope

  • The current CAN implementation is MIT-only.
  • Legacy servo transport modes are intentionally not part of the maintained CAN path.
  • The repository includes bench-validation tooling, but not thesis-only notes, temporary files, or local analysis artifacts.

Run the Package Entry Point

uv run python -m motor_python

Metadata

Release files for motor-python 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for motor-python 0.0.10
File Size Uploaded
motor_python-0.0.10.tar.gz 60.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for motor-python 0.0.10
File Interpreter ABI Platform
motor_python-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 124.5 kB

Release files / motor_python-0.0.10.tar.gz

Download URL motor_python-0.0.10.tar.gz
Size 60.8 kB
Tags Source
SHA-256 checksum
How to use checksums
510f7b0e75644bb52d585b353997060fd55543893392e26b41cb57064035dd14
BLAKE2b-256 checksum
How to use checksums
3a247e445aa45f1264cb587a1a348b1814d955eca2fe3d16af4e06f931e27125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / motor_python-0.0.10-py3-none-any.whl

Download URL motor_python-0.0.10-py3-none-any.whl
Size 63.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4001d60fed911695797afe9c7069919eb34ebce0edc224c2006d85cafca0ae7
BLAKE2b-256 checksum
How to use checksums
6967fb315ed483f06db21111827d21de4e97740613f37f0824c8d0ad976ce896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.0.11

2 release files

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page