Skip to content

t413/multimotor

Repository files navigation

MultiMotor: C++ Library for motor control

Top Language Lines of Code GitHub Repo stars Tests Last commit License Users Total Users Online Motors: Multi

Used by my rover controller OmniCtrl and Dug the robot

Features:

  • Supports different CanBus motors on the same CAN bus
    • ODrive and odrive-compatible motors
    • Xiaomi CyberGear motors
    • Robstride motors: in development
  • Environment independent CAN support
    • Arduino, PlatformIO, ESP-IDF, linux, etc.
    • Includes support for ESP32's native TWAI CanBus library

Roadmap / future plans:

  • Add additional CAN motor drivers
  • Add RS-485 and UART motor support
    • Hiwonder/LewanSoul bus servos (like the LX-16A)
    • Feetech bus servos (like the STS3215)
  • Python wrapper

Join my 3D Design Discord and say hi and talk shop!

Users Total Users Online

Usage

  • Include the library in your project (see below)
  • Create a CanInterface object, for example the CanEsp32Twai class that's included:
    CanEsp32Twai interface;
    interface.setup(PIN_CAN_RX, PIN_CAN_TX, 250000, &Serial);
  • Create a driver object (on stack, heap, etc)
    ODriveDriver omotor(ID1, &interface);
    CyberGearDriver cmotor(ID2, &interface);
  • Handle incoming messages in your loop:
    void loop() {
      // (other loop code)
    
      while (interface.available()) {
          CanMessage message = interface.readOne();
          bool handled = false;
          for (int i = 0; i < NUM_DRIVES; i++) {
              if (drives_[i]->handleIncoming(message.id, message.data, message.len, now))
                  handled = true;
          }
      }
    }

Installation

  • If you use PlatformIO, add the following to your platformio.ini:
    lib_deps = https://github.com/t413/multimotor.git
  • Or use via submodule:
    git submodule add https://github.com/t413/multimotor.git

About

C++ library for controlling robot motor actuator drives!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages