A.R.G.U.S 2.1.0
Adaptive Real-Time Guardian for Unsafe Situations
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
MotionController Class Reference

Low-level motion output driver for the PCA9685 servo board. More...

#include <MotionController.hpp>

Public Member Functions

 MotionController () noexcept
 Construct motion controller in uninitialised state.
 
 ~MotionController () noexcept
 Destroy motion controller and release resources.
 
 MotionController (const MotionController &)=delete
 
MotionControlleroperator= (const MotionController &)=delete
 
 MotionController (MotionController &&)=delete
 
MotionControlleroperator= (MotionController &&)=delete
 
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 setTargets (const MeArmJointTargets &targets) noexcept
 Write joint targets to hardware when motion is enabled.
 
void freeze () noexcept
 Freeze/disable motion output immediately.
 
bool enable () noexcept
 Enable motion output after successful initialisation.
 
void shutdown () noexcept
 Disable outputs and close hardware resources.
 
bool isInitialised () const noexcept
 Check whether controller was successfully initialised.
 
bool isEnabled () const noexcept
 Check whether motion output is currently enabled.
 
bool isFrozen () const noexcept
 Check whether output is currently frozen.
 
MotionOutputState outputState () const noexcept
 Get current output state.
 
MotionControllerError lastError () const noexcept
 Get last controller error code.
 
const char * lastErrorString () const noexcept
 Get human-readable last error string.
 

Static Public Attributes

static constexpr std::uint8_t kServoCount = 4
 Number of logical servos controlled.
 
static constexpr std::uint8_t kPca9685ChannelCount = 16
 PCA9685 total channels.
 
static constexpr std::uint16_t kMaxPulseTicks = 4095
 Maximum 12-bit pulse value.
 

Detailed Description

Definition at line 55 of file MotionController.hpp.

Constructor & Destructor Documentation

◆ MotionController() [1/3]

MotionController::MotionController ( )
noexcept

Definition at line 68 of file MotionController.cpp.

◆ ~MotionController()

MotionController::~MotionController ( )
noexcept

Definition at line 76 of file MotionController.cpp.

References shutdown().

◆ MotionController() [2/3]

MotionController::MotionController ( const MotionController )
delete

◆ MotionController() [3/3]

MotionController::MotionController ( MotionController &&  )
delete

Member Function Documentation

◆ enable()

bool MotionController::enable ( )
noexcept

◆ freeze()

void MotionController::freeze ( )
noexcept

Definition at line 172 of file MotionController.cpp.

References DEVICE_IO_FAILED, DISABLED, FAULT, and NONE.

◆ initialise()

bool MotionController::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
Parameters
i2c_device_pathI2C device path (for example /dev/i2c-1).
device_addressI2C slave address of the PCA9685.
pwm_frequency_hzPWM frequency in Hz.
channel_mapLogical joint-to-channel mapping.
Returns
true on success, otherwise false and lastError() set.

Definition at line 80 of file MotionController.cpp.

References DEVICE_IO_FAILED, DEVICE_OPEN_FAILED, DEVICE_SELECT_FAILED, DISABLED, FAULT, INVALID_ARGUMENT, and NONE.

Referenced by AppController::runInteractiveServoConsole(), AppController::runLiveMarkerTest(), AppController::runMotionHomePose(), AppController::runMotionSmokeTest(), and AppController::runServoCalibration().

◆ isEnabled()

bool MotionController::isEnabled ( ) const
noexcept
Returns
true if enabled, otherwise false.

Definition at line 229 of file MotionController.cpp.

References ENABLED.

◆ isFrozen()

bool MotionController::isFrozen ( ) const
noexcept
Returns
true if frozen, otherwise false.

Definition at line 233 of file MotionController.cpp.

◆ isInitialised()

bool MotionController::isInitialised ( ) const
noexcept
Returns
true if initialised, otherwise false.

Definition at line 224 of file MotionController.cpp.

References FAULT, and UNINITIALISED.

◆ lastError()

MotionControllerError MotionController::lastError ( ) const
noexcept
Returns
Error code.

Definition at line 241 of file MotionController.cpp.

◆ lastErrorString()

const char * MotionController::lastErrorString ( ) const
noexcept

◆ operator=() [1/2]

MotionController & MotionController::operator= ( const MotionController )
delete

◆ operator=() [2/2]

MotionController & MotionController::operator= ( MotionController &&  )
delete

◆ outputState()

MotionOutputState MotionController::outputState ( ) const
noexcept
Returns
Output state enum.

Definition at line 237 of file MotionController.cpp.

◆ setTargets()

bool MotionController::setTargets ( const MeArmJointTargets targets)
noexcept

◆ shutdown()

void MotionController::shutdown ( )
noexcept

Member Data Documentation

◆ kMaxPulseTicks

constexpr std::uint16_t MotionController::kMaxPulseTicks = 4095
staticconstexpr

Definition at line 59 of file MotionController.hpp.

◆ kPca9685ChannelCount

constexpr std::uint8_t MotionController::kPca9685ChannelCount = 16
staticconstexpr

Definition at line 58 of file MotionController.hpp.

◆ kServoCount

constexpr std::uint8_t MotionController::kServoCount = 4
staticconstexpr

Definition at line 57 of file MotionController.hpp.


The documentation for this class was generated from the following files: