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, allow_low_speed=False) MIT-backed velocity command
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 and disable

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.8

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.8
File Size Uploaded
motor_python-0.0.8.tar.gz 59.7 kB Details

Built distribution (wheel)

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

Total release size: 122.3 kB

Release files / motor_python-0.0.8.tar.gz

Download URL motor_python-0.0.8.tar.gz
Size 59.7 kB
Tags Source
SHA-256 checksum
How to use checksums
48bff4a5ba29d570a7cbe5184138dfe9ba3e163484e1024eda8690c9bff95232
BLAKE2b-256 checksum
How to use checksums
584ddf5e48b4d7e416e1e99b650fecda970de9296604c2010a058b26aa73a342
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 17, 2026.

Transparency log

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

Download URL motor_python-0.0.8-py3-none-any.whl
Size 62.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32eb20530684ed9615c35e10f073f1fad3ca97729bd8a33a640bda3bb415ea5d
BLAKE2b-256 checksum
How to use checksums
f986d1a6020b6fc851374e87b73a1448972201cbe649daefc39a1fb4e0f4cb87
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 17, 2026.

Transparency log

Release history Release notifications | RSS feed

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

This release

0.0.8 This release

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