![]() |
Dynamixel
2.9.5
RoadNarrows Robotics Dynamixel Package
|
Background Thread Virtual Servo Class. More...
#include <DynaBgThread.h>
Public Types | |
enum | VServoState { StateIdle, StateBegin, StateControl } |
Servo dynamics position control state. More... | |
Public Member Functions | |
DynaVServo () | |
Default constructor. | |
DynaVServo (const DynaVServo &src) | |
Copy constructor. More... | |
~DynaVServo () | |
Destructor. | |
DynaVServo | operator= (const DynaVServo &rhs) |
Assignment operator. More... | |
void | setToleranceInTicks (DynaServo *pServo, double fTolerance) |
Set position tolerance in encoder ticks. More... | |
double | filterTorques (int nServoLoad) |
Apply a low-pass band filter on the sensed torques (loads). More... | |
int | getGoalDir (DynaServo *pServo) |
Get the current goal rotation direction. More... | |
void | lock () |
Lock the virtual servo. More... | |
void | unlock () |
Unlock the virtual servo. More... | |
Public Attributes | |
VServoState | m_eState |
virtual servo state | |
DynaPidPos | m_pidPos |
servo position PID | |
int | m_nTolerance |
position ± tolerance (ticks) | |
int | m_nOdGoalPos |
current goal position | |
int | m_nGoalSpeed |
current goal speed | |
bool | m_bOverTorqueCond |
is [not] in torque overload condition | |
bool | m_bOverTorqueCtl |
[not] in torque overload control | |
double | m_fTorqueOut |
low-pass filtered torque | |
std::deque< double > | m_histTorqueIn |
recent history of joint torques | |
Static Public Attributes | |
static const size_t | TORQUE_WIN_SIZE = 10 |
Torque sliding window size for low-pass band filtering of input torques. | |
static const int | GOAL_SPEED_DFT = 100 |
default virutal goal speed | |
Protected Attributes | |
pthread_mutex_t | m_mutexSync |
synchonization mutex | |
Background Thread Virtual Servo Class.
Definition at line 87 of file DynaBgThread.h.
Servo dynamics position control state.
Enumerator | |
---|---|
StateIdle |
no active position control |
StateBegin |
start position control |
StateControl |
in poistion control |
Definition at line 101 of file DynaBgThread.h.
DynaVServo::DynaVServo | ( | const DynaVServo & | src | ) |
Copy constructor.
src | Source object. |
Definition at line 205 of file DynaBgThread.cxx.
References m_bOverTorqueCond, m_bOverTorqueCtl, m_eState, m_fTorqueOut, m_histTorqueIn, m_mutexSync, m_nGoalSpeed, m_nOdGoalPos, m_nTolerance, and m_pidPos.
double DynaVServo::filterTorques | ( | int | nServoLoad | ) |
Apply a low-pass band filter on the sensed torques (loads).
The torques are interpreted from the unitless load values read from the servo (and probably non-linear).
A simple moving average (SMA) of load values with a window size of TORQUE_WIN_SIZE is used as the filter.
nServoLoad | New servo load value (raw unitless). |
Definition at line 261 of file DynaBgThread.cxx.
References DynaBgThread::HZ_EXEC_DFT, DynaBgThread::HZ_EXEC_MIN, m_fTorqueOut, m_histTorqueIn, DynaBgThread::T_EXEC_MIN, DynaBgThread::TOLERANCE_DFT, and TORQUE_WIN_SIZE.
Referenced by DynaBgThread::monitorDynamics().
|
inline |
Get the current goal rotation direction.
The direct is deterimed by the difference of current odometer value and the goal position.
Normally counter-clockwise is positive, clockwise is negative, but the sence can be reversed in the odometer configuration.
pServer | Pointer to servo. |
Definition at line 186 of file DynaBgThread.h.
References DynaServo::GetOdometer(), and DynaServo::IsOdometerReversed().
Referenced by DynaBgThread::execDynamics().
|
inline |
Lock the virtual servo.
The calling thread will block while waiting for the mutex to become available. Once locked, the background thread will block when accessing this vitural servo.
The lock()/unlock() primitives provide a safe mechanism to modify the registered vServo data.
Definition at line 206 of file DynaBgThread.h.
Referenced by DynaBgThread::execDynamics(), DynaBgThread::readyWait(), DynaBgThread::timeWait(), and DynaBgThread::WriteGoalPos().
DynaVServo DynaVServo::operator= | ( | const DynaVServo & | rhs | ) |
Assignment operator.
rhs | Right hand side object. |
Definition at line 220 of file DynaBgThread.cxx.
References m_bOverTorqueCond, m_bOverTorqueCtl, m_eState, m_fTorqueOut, m_histTorqueIn, m_nGoalSpeed, m_nOdGoalPos, m_nTolerance, and m_pidPos.
void DynaVServo::setToleranceInTicks | ( | DynaServo * | pServo, |
double | fTolerance | ||
) |
Set position tolerance in encoder ticks.
pServo | Pointer to servo. |
fTolerance | Tolerance (degrees). |
Definition at line 235 of file DynaBgThread.cxx.
References DYNA_MODE_CONTINUOUS, DynaServo::GetServoMode(), DynaServo::GetSpecification(), DynaServoSpec_T::m_fAngleMax, DynaServoSpec_T::m_fAngleMin, m_nTolerance, and DynaServoSpec_T::m_uRawPosModulo.
Referenced by DynaBgThread::RegisterChainAgent(), and DynaBgThread::RegisterServoAgent().
|
inline |
Unlock the virtual servo.
The background thread will be available to run when accessing this vitural servo.
Definition at line 220 of file DynaBgThread.h.
Referenced by DynaBgThread::execDynamics(), DynaBgThread::readyWait(), DynaBgThread::timeWait(), and DynaBgThread::WriteGoalPos().