upkie 9.0.0
Open-source wheeled biped robots
Loading...
Searching...
No Matches
upkie::cpp::interfaces::moteus Namespace Reference

Interface to moteus controllers used in pi3hat spines. More...

Classes

struct  CanFrame
 CAN frame data structure for the moteus protocol. More...
 
struct  Data
 Data for one control cycle. More...
 
class  MultiplexParser
 Parser for multiplex data in the moteus protocol. More...
 
struct  Output
 Output information forwarded to an interface's callback function. More...
 
struct  PositionCommand
 Position command. More...
 
struct  PositionResolution
 Resolution settings for position control commands. More...
 
struct  QueryCommand
 Resolution settings for query commands. More...
 
struct  QueryResult
 Result data from moteus query commands. More...
 
struct  ServoCommand
 Command sent to a servo. More...
 
struct  ServoReply
 Reply from servo. More...
 
class  Span
 Fixed-size array with runtime size information. More...
 
class  WriteCanFrame
 Writer for CAN frame data in the moteus protocol. More...
 
class  WriteCombiner
 Groups registers when encoding them to minimize the required bytes. More...
 

Enumerations

enum class  Mode {
  kStopped = 0 , kFault = 1 , kEnabling = 2 , kCalibrating = 3 ,
  kCalibrationComplete = 4 , kPwm = 5 , kVoltage = 6 , kVoltageFoc = 7 ,
  kVoltageDq = 8 , kCurrent = 9 , kPosition = 10 , kPositionTimeout = 11 ,
  kZeroVelocity = 12 , kNumModes
}
 Control mode.
 
enum  { kCurrentRegisterMapVersion = 4 }
 
enum  Multiplex : uint32_t {
  kWriteBase = 0x00 , kWriteInt8 = 0x00 , kWriteInt16 = 0x04 , kWriteInt32 = 0x08 ,
  kWriteFloat = 0x0c , kReadBase = 0x10 , kReadInt8 = 0x10 , kReadInt16 = 0x14 ,
  kReadInt32 = 0x18 , kReadFloat = 0x1c , kReplyBase = 0x20 , kReplyInt8 = 0x20 ,
  kReplyInt16 = 0x24 , kReplyInt32 = 0x28 , kReplyFloat = 0x2c , kWriteError = 0x30 ,
  kReadError = 0x31 , kClientToServer = 0x40 , kServerToClient = 0x41 , kClientPollServer = 0x42 ,
  kNop = 0x50
}
 Multiplex register types in the moteus protocol.
 
enum  Register : uint32_t {
  kMode = 0x000 , kPosition = 0x001 , kVelocity = 0x002 , kTorque = 0x003 ,
  kQCurrent = 0x004 , kDCurrent = 0x005 , kRezeroState = 0x00c , kVoltage = 0x00d ,
  kTemperature = 0x00e , kFault = 0x00f , kPwmPhaseA = 0x010 , kPwmPhaseB = 0x011 ,
  kPwmPhaseC = 0x012 , kVoltagePhaseA = 0x014 , kVoltagePhaseB = 0x015 , kVoltagePhaseC = 0x016 ,
  kVFocTheta = 0x018 , kVFocVoltage = 0x019 , kVoltageDqD = 0x01a , kVoltageDqQ = 0x01b ,
  kCommandQCurrent = 0x01c , kCommandDCurrent = 0x01d , kCommandPosition = 0x020 , kCommandVelocity = 0x021 ,
  kCommandFeedforwardTorque = 0x022 , kCommandKpScale = 0x023 , kCommandKdScale = 0x024 , kCommandPositionMaxTorque = 0x025 ,
  kCommandStopPosition = 0x026 , kCommandTimeout = 0x027 , kPositionKp = 0x030 , kPositionKi = 0x031 ,
  kPositionKd = 0x032 , kPositionFeedforward = 0x033 , kPositionCommand = 0x034 , kRegisterMapVersion = 0x102 ,
  kSerialNumber = 0x120 , kSerialNumber1 = 0x120 , kSerialNumber2 = 0x121 , kSerialNumber3 = 0x122 ,
  kRezero = 0x130
}
 Register addresses for moteus servo control and monitoring.
 
enum class  Resolution {
  kInt8 , kInt16 , kInt32 , kFloat ,
  kIgnore
}
 Data resolution types in the moteus protocol.
 

Functions

template<typename T >
Saturate (double value, double scale)
 Saturate a double value to fit within the range of type T after scaling.
 
void EmitStopCommand (WriteCanFrame *frame)
 Emit a stop command to set the moteus servo to stopped mode. More...
 
void EmitPositionCommand (WriteCanFrame *frame, const PositionCommand &command, const PositionResolution &resolution)
 Emit position command to control the servo position. More...
 
void EmitQueryCommand (WriteCanFrame *frame, const QueryCommand &command)
 Emit a query command to request data from moteus servos. More...
 
QueryResult ParseQueryResult (const uint8_t *data, size_t size)
 Parse query result data received from moteus servo into structured format.
 

Detailed Description

Interface to moteus controllers used in pi3hat spines.