Close

moteus C++ bindings

A project log for moteus brushless controller

Open source, compact, high performance, FOC based BLDC motor control

josh-pieperJosh Pieper 09/19/2023 at 13:110 Comments

moteus has had python bindings for a long time, and had a half-completed CAN parser library in the pi3hat repo, but there has never been great support for developing in C++.  No longer!

Now, in the mjbots/moteus repository, there are C++ bindings that can be used for applications that allows full control over all of the capabilities of any moteus controller using a fdcanusb, socketcan, (or the pi3hat).  It is modeled after the python library, so simple cases look about the same:

#include "moteus.h"

// ....

mjbots::moteus::Controller c;

mjbots::moteus::PositionMode::Command command;
command.position = 0.5;
const auto maybe_result = c.SetPosition(command);
std::cout << "Position: " << (maybe_result ? maybe_result->values.position : 0.0) << "\n";

 I've got two videos showing first how to use it in a 1 controller example, and second in an example with 2 controllers at the same time:

Discussions