Motor Controller Interface
The motor_controller component holds the shared interface used by the dual-channel motor-controller drivers that model the same MCP236 / MCP266 hardware over different transports:
espp::MotorAxis, theM1/M2channel selector, andthe
espp::MotorControllerconcept — the common command / read surface (drive_duty/drive_speedby axis,read_encoder/read_speed,reset_estop,read_main_battery_voltage,read_temperature).
Keeping the contract in a small, dependency-light component lets the two drivers
share it without depending on each other: Basicmicro (MCP / RoboClaw) Motor Controller Component (packet serial) and
MCP266 CANopen Motor Controller Component (CANopen) each static_assert that they satisfy
MotorController, so generic code can command either transport by axis.
The component also holds espp::detail::BasicmicroCommand
(basicmicro_commands.hpp) — the packet-serial command-number table. Both
drivers use it as the single source of truth: the serial driver sends the command
byte directly, while the MCP266 CANopen firmware mirrors the same command set into
its manufacturer object dictionary at 0x2000 + command, so mcp266 derives
those object indices from this table rather than from magic numbers that could
drift out of sync.
// works for either espp::Basicmicro or espp::Mcp266
bool ramp(espp::MotorController auto &mc, std::error_code &ec) {
return mc.drive_duty(espp::MotorAxis::M1, 4096, ec);
}