85 const
char* i2c_device_path = "/dev/i2c-1",
86 std::uint8_t device_address = 0x40,
87 float pwm_frequency_hz = 50.0f,
150 bool configurePca9685(
float pwm_frequency_hz) noexcept;
152 bool writeChannelPulse(std::uint8_t channel, std::uint16_t pulse_ticks) noexcept;
153 bool writeRegister(std::uint8_t reg, std::uint8_t value) noexcept;
154 bool writeRegisters(std::uint8_t start_reg,
155 const std::uint8_t* values,
156 std::uint8_t value_count) noexcept;
157 bool setAllOutputsEnabled(
bool enabled) noexcept;
158 bool hasValidChannelMap(const
MotionChannelMap& channel_map) const noexcept;
MotionControllerError
Error codes reported by MotionController operations.
@ NOT_INITIALISED
Controller is not initialised.
@ DEVICE_SELECT_FAILED
Failed to select I2C slave address.
@ DEVICE_IO_FAILED
I/O transaction failed.
@ DEVICE_OPEN_FAILED
Failed to open I2C device.
@ INVALID_ARGUMENT
Invalid input argument.
MotionOutputState
High-level state of motion output availability.
@ UNINITIALISED
Hardware not initialised.
@ DISABLED
Initialised but outputs disabled.
@ FAULT
Fault state; output path blocked until reset/re-init.
@ ENABLED
Outputs enabled and can accept target writes.
Low-level motion output driver for the PCA9685 servo board.
MotionControllerError lastError() const noexcept
Get last controller error code.
static constexpr std::uint8_t kServoCount
Number of logical servos controlled.
MotionController() noexcept
Construct motion controller in uninitialised state.
void freeze() noexcept
Freeze/disable motion output immediately.
bool isEnabled() const noexcept
Check whether motion output is currently enabled.
const char * lastErrorString() const noexcept
Get human-readable last error string.
bool initialise(const char *i2c_device_path="/dev/i2c-1", std::uint8_t device_address=0x40, float pwm_frequency_hz=50.0f, MotionChannelMap channel_map={}) noexcept
Initialise PCA9685 output path.
bool isFrozen() const noexcept
Check whether output is currently frozen.
static constexpr std::uint8_t kPca9685ChannelCount
PCA9685 total channels.
bool isInitialised() const noexcept
Check whether controller was successfully initialised.
bool setTargets(const MeArmJointTargets &targets) noexcept
Write joint targets to hardware when motion is enabled.
void shutdown() noexcept
Disable outputs and close hardware resources.
static constexpr std::uint16_t kMaxPulseTicks
Maximum 12-bit pulse value.
MotionOutputState outputState() const noexcept
Get current output state.
bool enable() noexcept
Enable motion output after successful initialisation.
Raw PWM tick targets for each MeArm joint.
std::uint16_t upper_ticks
Upper target pulse ticks.
std::uint16_t lower_ticks
Lower target pulse ticks.
std::uint16_t base_ticks
Base target pulse ticks.
std::uint16_t gripper_ticks
Gripper target pulse ticks.
Mapping of logical MeArm joints to PCA9685 channels.
std::uint8_t upper
Upper joint PWM channel.
std::uint8_t gripper
Gripper joint PWM channel.
std::uint8_t lower
Lower joint PWM channel.
std::uint8_t base
Base joint PWM channel.