Skip to content

Repository files navigation

CubeMars Servo CAN

A simplified, robust, and modern Python library for controlling CubeMars AK-series and AKA-series actuators (for example AK40-10 and AKA60-6) via CAN bus in Servo Mode.


Key Features

  • Refactor: Modular codebase with strict type hinting, linting, and solid architecture.
  • Zero Bloat: Focused 100% on reliable Servo CAN operation.
  • Modern Packaging: Built with uv and pyproject.toml for fast, reliable dependency management.
  • Advanced Configuration: Safe defaults for AK-series motors with the ability to safely override parameters or define custom motors.
  • Built-in Motor Presets: AK10-9, AK80-9, AK40-10, and AKA60-6.
  • Quality Gates: Mock-based test suite with full source coverage (src/cubemars_servo_can/*).

Hardware Setup

You need a CAN link to use this library.

We highly recommend the Waveshare RS485 CAN HAT for Raspberry Pi.

For motor wiring and initial configuration (setting the servo mode and CAN ID) please refer to the official tutorial PDF included in this repository.

Raspberry Pi + Waveshare RS485 CAN HAT

Keep hardware bring-up details in one place:

  • Full Raspberry/Waveshare setup and single recommended runtime flow (boot-time interface bring-up for can0, can1, etc.): Usage Guide

Quick Start

1. Install

Install directly from the repository using uv or pip:

# Add as a dependency to your project (uv)
uv add git+https://github.com/sam0rr/cubemars_servo_can.git

# Install into the current Python environment (pip)
pip install git+https://github.com/sam0rr/cubemars_servo_can.git

2. Run

Use the usage guide for mode-by-mode examples:


3. Upgrade

Update to the latest repository version:

# If managed in a uv project dependency:
uv add --upgrade git+https://github.com/sam0rr/cubemars_servo_can.git

# If installed with pip:
pip install --upgrade git+https://github.com/sam0rr/cubemars_servo_can.git

Documentation

  • Usage Guide: Detailed usage of Duty, Current, Velocity, and Position modes.
  • Configuration Guide: How to change gear ratios, limits, or add custom motors.

Included Vendor Files


Development

To contribute to this project:

  1. Clone the repository:
git clone https://github.com/sam0rr/cubemars_servo_can.git
cd cubemars_servo_can
  1. Install dependencies:
uv sync
  1. Run linting and formatting:
uv run ruff check . --fix
uv run ruff format .
  1. Run type check:
uv run mypy
  1. Run dead code check:
uv run vulture
  1. Run tests:
uv run pytest

About

A simplified, robust, and modern Python library for controlling CubeMars AK-series and AKA-series actuators via CAN bus in Servo Mode.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages