Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaServoGeneric Class Reference

Generic Dynamixel Servo Base Class. More...

#include <DynaServoGeneric.h>

Inheritance diagram for DynaServoGeneric:
DynaServo DynaServoAX12 DynaServoEX106P DynaServoMX106 DynaServoMX12W DynaServoMX28 DynaServoMX64 DynaServoRX10 DynaServoRX24F DynaServoRX28 DynaServoRX64

Public Member Functions

 DynaServoGeneric (DynaComm &comm)
 Bare-bones initialization constructor. More...
 
 DynaServoGeneric (DynaComm &comm, int nServoId, uint_t uModelNum=DYNA_MODEL_NUM, uint_t uFwVer=DYNA_FWVER_NA)
 Initialization constructor. More...
 
virtual ~DynaServoGeneric ()
 Destructor.
 
virtual float CvtRawTempToC (uint uTemp)
 Convert raw temperature coding to degrees Celsius. More...
 
virtual float CvtRawVoltToVolts (uint uVolts)
 Convert raw volts coding to volts. More...
 
virtual int AgentWriteGoalPos (int nGoalOdPos)
 Agent write to the servo state memory to set the new goal position. More...
 
virtual int AgentWriteGoalSpeed (int nGoalSpeed)
 Agent write to the servo state memory to set the new goal speed. More...
 
virtual int AgentWriteGoalSpeedPos (int nGoalSpeed, int nGoalOdPos)
 Agent write to the servo state memory to set the new goal position and speed. More...
 
virtual int MoveTo (int nGoalOdPos)
 Move to the goal postition. More...
 
virtual int MoveAtSpeedTo (int nGoalSpeed, int nGoalOdPos)
 Move at speed to the goal postition. More...
 
virtual int MoveAtSpeed (int nGoalSpeed)
 Move at speed. More...
 
virtual int EStop ()
 Emergency stop servo. More...
 
virtual int Stop ()
 Stop servo. More...
 
virtual int Freeze ()
 Freeze servo at current position. More...
 
virtual int Release ()
 Release servo from any applied torque. More...
 
virtual int CfgReadRotationLimits (uint_t *pCwLim, uint_t *pCcwLim)
 Read from the servo configuration EEPROM the current rotation limits. More...
 
virtual int CfgWriteRotationLimits (uint_t uCwLim, uint_t uCcwLim)
 Write to the servo configuration EEPROM the new rotation limits. More...
 
virtual int CfgReadTemperatureLimit (uint_t *pTempLim)
 Read from the servo configuration EEPROM the current maximum temperature limit. More...
 
virtual int CfgWriteTemperatureLimit (uint_t uTempLim)
 Write to the servo configuration EEPROM the new maximum temperature limit. More...
 
virtual int CfgReadVoltageLimits (uint_t *pMinVoltLim, uint_t *pMaxVoltLim)
 Read from the servo configuration EEPROM the current voltage limits. More...
 
virtual int CfgWriteVoltageLimits (uint_t uMinVoltLim, uint_t uMaxVoltLim)
 Write to the servo configuration EEPROM the new voltage limits. More...
 
virtual int CfgReadMaxTorqueLimit (uint_t *pMaxTorqueLim)
 Read from the servo configuration EEPROM the current on power-up maximum torque limit. More...
 
virtual int CfgWriteMaxTorqueLimit (uint_t uMaxTorqueLim)
 Write to the servo configuration EEPROM the new on power-up maximum torque limit. More...
 
virtual int CfgReadAlarmShutdownMask (uint_t *pAlarmMask)
 Read from the servo configuration EEPROM the current servo shutdown on alarms mask. More...
 
virtual int CfgWriteAlarmShutdownMask (uint_t uAlarmMask)
 Write to the servo configuration EEPROM the new servo shutdown on alarms mask. More...
 
virtual int CfgReadServoMode (uint_t *pServoMode)
 Read from the servo configuration EEPROM to determine the servo operational mode. More...
 
virtual int CfgWriteServoMode (uint_t uCwLim, uint_t uCcwLim)
 Write to the servo configuration EEPROM to set the servo operational mode. More...
 
virtual int CfgWriteServoModeContinuous ()
 Write to the servo configuration EEPROM to set the servo operational mode to the full/continuous mode. More...
 
virtual int ReadTorqueEnable (bool *pState)
 Read from the servo state memory the current torque enable value. More...
 
virtual int WriteTorqueEnable (bool bState)
 Write to the servo state memory to set the new torque enable value. More...
 
virtual int ReadLed (bool *pState)
 Read from the servo state memory the current LED on/off value. More...
 
virtual int WriteLed (bool bState)
 Write to the servo state memory to turn on or off the servo LED. More...
 
virtual int ReadControlMethod (DynaServoCtlMethod_T *pCtlMethod)
 Read from the servo state memory the current control method parameters. More...
 
virtual int WriteControlMethod (DynaServoCtlMethod_T &ctlMethod)
 Write to the servo state memory the new control method parameters. More...
 
virtual int ReadGoalPos (int *pGoalPos)
 Read from the servo state memory the current goal position. More...
 
virtual int WriteGoalPos (int nGoalOdPos)
 Write to the servo state memory to set the new goal position. More...
 
virtual int ReadGoalSpeed (int *pGoalSpeed)
 Read from the servo state memory the current goal speed and direction. More...
 
virtual int WriteGoalSpeed (int nGoalSpeed)
 Write to the servo state memory the new goal speed and direction. More...
 
virtual int ReadMaxTorqueLimit (uint_t *pMaxTorqueLim)
 Read from the servo state memory the current maximum torque limit. More...
 
virtual int WriteMaxTorqueLimit (uint_t uMaxTorqueLim)
 Write to the servo state memory to set the new maximum torque limit. More...
 
virtual int ReloadMaxTorqueLimit ()
 Reload the maximum torque limit from the configuration. More...
 
virtual int ReadCurPos (int *pCurOdPos)
 Read from the servo state memory the current servo position. More...
 
virtual int ReadCurSpeed (int *pCurSpeed)
 Read from the servo state memory the current speed and direction. More...
 
virtual int ReadCurLoad (int *pCurLoad)
 Read from the servo state memory the current load. More...
 
virtual int ReadDynamics (int *pCurPos, int *pCurSpeed, int *pCurLoad)
 Read from the servo state memory the current servo dynamics. More...
 
virtual int ReadHealth (uint_t *pAlarms, int *pCurLoad, uint_t *pCurVolt, uint_t *pCurTemp)
 Read from the servo state memory the current servo health. More...
 
virtual int ReadIsMoving (bool *pState)
 Read from the servo state memory to test if the servo is currently moving. More...
 
virtual int Read (uint_t uAddr, uint_t *pVal)
 
virtual int Write (uint_t uAddr, uint_t uVal)
 
virtual bool Ping ()
 Ping this servo. More...
 
virtual int Reset ()
 Reset this servo back to default values. More...
 
virtual int SyncData ()
 Synchronize the shadowed configuration and state data to the servo control table. More...
 
virtual int SyncCfg ()
 Synchronize the shadowed configuration to the servo control table EEPROM configuration. More...
 
virtual int SyncState ()
 Synchronize the shadowed state data to the servo control table RAM state. More...
 
virtual void Dump ()
 Dump contents of the servo EEPROM and RAM control tables.
 
- Public Member Functions inherited from DynaServo
 DynaServo (DynaComm &comm, int nServoId, uint_t uModelNum, uint_t uFwVer)
 Default initialization constructor. More...
 
virtual ~DynaServo ()
 Destructor.
 
virtual uint_t GetModelNumber () const
 Get servo model number. More...
 
virtual uint_t GetFirmwareVersion () const
 Get servo firmware version. More...
 
virtual const char * GetModelName () const
 Get servo model name string. More...
 
virtual uint_t GetServoId () const
 Get servo id. More...
 
virtual uint_t GetServoMode () const
 Get the servo operational mode. More...
 
virtual uint_t Has360PosInfo () const
 Test if servo has 360 ° positioning information. More...
 
virtual const DynaServoSpec_TGetSpecification () const
 Get servo specification. More...
 
virtual const DynaServoCfg_TGetConfiguration () const
 Get servo configuration. More...
 
virtual const DynaServoState_TGetState () const
 Get servo state. More...
 
bool IsMaster () const
 Test if this servo is a master. More...
 
bool IsLinkedMaster () const
 Test if this servo is a linked master. More...
 
bool IsUnlinked () const
 Test if this servo is unlinked. More...
 
virtual const DynaServoLink_T GetLinkInfo () const
 Get linked information. More...
 
virtual void Link (uint_t uLinkType, DynaServo *pServoMate, bool bRotReversed)
 Link this servo to another. More...
 
virtual void Unlink ()
 Unlink this servo.
 
int GetOdometer ()
 Get the current virtual odometer value. More...
 
int IsOdometerEnabled ()
 Test if virtual odometer mapping is enabled. More...
 
int GetOdometerZeroPt ()
 Get the virtual odometer zero point. More...
 
bool IsOdometerReversed ()
 Test if the virtual odometer is reversed. More...
 
int CalcOdometerAtEncMin ()
 Calculate the odometer value at the minimum (zero) encoder value. More...
 
int CalcOdometerAtEncMax ()
 Calculate the odometer value at the maximum encoder value. More...
 
int OdometerToEncoder (int nOdPos)
 Convert virtual odometer units to servo encoder units. More...
 
int CalcSpeedDir (int nOdGoalPos)
 Calculate serve direction to goal odometer position. More...
 
virtual int ResetOdometer (int nEncZeroPt, bool bIsReverse)
 Reset the servo's virtual odometer. More...
 
virtual int UpdateOdometer (int nEncCurPos)
 Update the odometer from the current servo position and rotation direction. More...
 
virtual void DisableOdometer ()
 Disable odometer mapping. More...
 
virtual uint_t GetAlarms () const
 Get the current servo alarms. More...
 
virtual uint_t GetCurPos () const
 Get the current servo position. More...
 
virtual int GetCurSpeed () const
 Get the current servo speed. More...
 
virtual int GetGoalSpeed () const
 Get the goal servo speed. More...
 
virtual int GetCurLoad () const
 Get the current servo load. More...
 
virtual uint_t GetCurTemp () const
 Get the current temperature. More...
 
virtual uint_t GetCurVolt () const
 Get the current voltage. More...
 
virtual void SetSoftTorqueThresholds (uint_t uOverTorqueTh, uint_t uClearTorqueTh)
 Set soft torque thresholds. More...
 
virtual void GetSoftTorqueThresholds (uint_t &uOverTorqueTh, uint_t &uClearTorqueTh)
 Get soft torque thresholds. More...
 
virtual void SetSoftTorqueOverCond (bool bNewCond)
 Set or clear servo in soft over torque condition. More...
 
virtual bool HasSoftTorqueOverCond ()
 Test if servo is in a soft over torque condition. More...
 
virtual void RegisterAgent (DynaAgent_T *pAgent, void *pAgentArg)
 Register servo proxy agent. More...
 
virtual void UnregisterAgent ()
 Unregister servo proxy agent.
 
virtual bool HasAgent ()
 Tests if servo has a registered agent. More...
 

Static Public Attributes

static const int DYNA_MODEL_NUM = DYNA_MODEL_NUM_GENERIC
 

Protected Member Functions

void Init ()
 Initialize servo class instance.
 
void InitSpec ()
 Initialize servo fixed specification data.
 
void InitCfg ()
 Initialize servo configuration data.
 
void InitState ()
 Initialize servo state data.
 
virtual void CheckData ()
 Check data for consitencies. More...
 
void SetServoMode ()
 Set the servo mode given the servo capabilites and the current rotation limits. More...
 
virtual int CalcMatesGoalPos (int nGoalOdPos, int *pGoalOdPosMate)
 Calculate the linked mate's goal position given this servo's goal position. More...
 
virtual int CalcMatesGoalSpeed (int nGoalSpeed)
 Calculate the linked mate's speed speed given this servo's goal speed. More...
 
virtual int ReadCtlMethodCompliance (DynaServoCtlMethod_T *pCtlMethod)
 Read from the servo state memory the current compliance control method parameters. More...
 
virtual int WriteCtlMethodCompliance (DynaServoCtlMethod_T &ctlMethod)
 Write to the servo state memory the new compliance control method parameters. More...
 
virtual int ReadCtlMethodPid (DynaServoCtlMethod_T *pCtlMethod)
 Read from the servo state memory the current PID control method parameters. More...
 
virtual int WriteCtlMethodPid (DynaServoCtlMethod_T &ctlMethod)
 Write to the servo state memory the new PID control method parameters. More...
 
virtual bool ChkComplianceSlope (uint_t uVal)
 Check validity of compliance slope discrete values. More...
 
virtual uint_t PackGoalSpeed (int nGoalSpeed)
 Pack the goal speed into the control table value. More...
 
virtual int UnpackGoalSpeed (uint_t uVal)
 Unpack goal speed from the control table value. More...
 
virtual int UnpackCurSpeed (uint_t uVal)
 Unpack current speed from the control table value. More...
 
virtual int UnpackCurLoad (uint_t uVal)
 Unpack current load estimate from the control table value. More...
 
- Protected Member Functions inherited from DynaServo
void Init (int nServoId, uint_t uModelNum, uint_t uFwVer)
 Initialize servo class instance. More...
 
void DumpCtlTbl (const char *sTblName, const DynaCtlTblEntry_T tblInfo[], size_t uSize)
 Dump the servo control tabl values to stdout. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DynaServo
static DynaServoNew (DynaComm &comm, int nServoId)
 Archetype constructor to create a new Dynamixel servo instance. More...
 
static int ReadModelNumber (DynaComm &comm, int nServoId, uint_t *pModelNum)
 Read the servo model number from the servo's EEPROM. More...
 
static int ReadFirmwareVersion (DynaComm &comm, int nServoId, uint_t *pFwVer)
 Read the servo's firmware version from the servo's EEPROM. More...
 
static int ReadServoId (DynaComm &comm, int nServoId, int *pServoId)
 Read the servo's id from the servo's EEPROM. More...
 
static int WriteServoId (DynaComm &comm, int nServoId, int nNewServoId)
 Write the new servo id to the servo's EEPROM. More...
 
static int ReadBaudRate (DynaComm &comm, int nServoId, int *pBaudRate)
 Read the servo's baud rate from the servo's EEPROM. More...
 
static int WriteBaudRate (DynaComm &comm, int nServoId, int nNewBaudRate)
 Write the new baud rate to the servo's EEPROM. More...
 
static bool Ping (DynaComm &comm, int nServoId)
 Ping the given servo. More...
 
static int Reset (DynaComm &comm, int nServoId)
 Reset the given servo back to default values. More...
 
- Protected Attributes inherited from DynaServo
DynaCommm_comm
 attached Dynamixel bus comm. object
 
int m_nServoId
 servo id
 
DynaServoSpec_T m_spec
 servo specification
 
DynaServoCfg_T m_cfg
 servo shadowed EEPROM configuration
 
DynaServoState_T m_state
 servo shadowed RAM state
 
CrossLink_T m_link
 servo cross linkage
 
DynaAgent_Tm_pAgent
 servo agent
 
void * m_pAgentArg
 servo agent callback argument
 
int m_nErrorCode
 class instance errored state
 

Detailed Description

Generic Dynamixel Servo Base Class.

The DynaServo base class provides the most commonly used interface functions for the various Dynamixel series servos.

Definition at line 75 of file DynaServoGeneric.h.

Constructor & Destructor Documentation

DynaServoGeneric::DynaServoGeneric ( DynaComm comm)
inline

Bare-bones initialization constructor.

May be used be derived classes to avoid undue communication and initializaton overhead.

Parameters
commDynamixel bus communication instance.

Definition at line 90 of file DynaServoGeneric.h.

References DYNA_FWVER_NA, and ~DynaServoGeneric().

90  :
92  {
93  }
DynaServo(DynaComm &comm, int nServoId, uint_t uModelNum, uint_t uFwVer)
Default initialization constructor.
Definition: DynaServo.h:89
static const int DYNA_MODEL_NUM
#define DYNA_FWVER_NA
firmware version not available
Definition: Dynamixel.h:136
#define DYNA_ID_NONE
no servo id
Definition: Dynamixel.h:145
DynaServoGeneric::DynaServoGeneric ( DynaComm comm,
int  nServoId,
uint_t  uModelNum = DYNA_MODEL_NUM,
uint_t  uFwVer = DYNA_FWVER_NA 
)

Initialization constructor.

Parameters
commDynamixel bus communication instance.
nServoIdServo Id.
uModelNumServo model number.
uFwVerServo firmware version.

Definition at line 134 of file DynaServoGeneric.cxx.

References CheckData(), Init(), and SyncData().

137  :
138  DynaServo(comm, nServoId, uModelNum, uFwVer)
139 {
140  Init();
141  SyncData();
142  CheckData();
143 }
DynaServo(DynaComm &comm, int nServoId, uint_t uModelNum, uint_t uFwVer)
Default initialization constructor.
Definition: DynaServo.h:89
void Init()
Initialize servo class instance.
virtual void CheckData()
Check data for consitencies.
virtual int SyncData()
Synchronize the shadowed configuration and state data to the servo control table. ...

Member Function Documentation

int DynaServoGeneric::AgentWriteGoalPos ( int  nGoalOdPos)
virtual

Agent write to the servo state memory to set the new goal position.

If the operation requires a servo proxy agent, then a call is made to the registered agent, if any. Otherwise a direct write to the servo is made.

Control Table:
RAM Goal Position.
Dynamixel Position Common Values.
Parameters
nGoalPosGoal position (odometer ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 155 of file DynaServoGeneric.cxx.

References DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_AGENT, DYNA_TRY_SERVO_HAS_POS_CTL, DynaServo::m_comm, DynaAgent_T::m_fnWriteGoalPos, DynaServoOdometer_T::m_nOdGoalPos, DynaServo::m_nServoId, DynaServoState_T::m_od, DynaServo::m_pAgent, DynaServo::m_pAgentArg, and DynaServo::m_state.

Referenced by CvtRawVoltToVolts(), and MoveTo().

156 {
157  int rc;
158 
160  DYNA_TRY_IS_MASTER(this);
163 
164  m_state.m_od.m_nOdGoalPos = nGoalOdPos;
165  rc = m_pAgent->m_fnWriteGoalPos(m_nServoId, nGoalOdPos, m_pAgentArg);
166 
167  return rc;
168 }
int m_nOdGoalPos
odometer goal position
Definition: DynaTypes.h:183
DynaAgent_T * m_pAgent
servo agent
Definition: DynaServo.h:841
int(* m_fnWriteGoalPos)(int nServoId, int nGoalPos, void *pUsrArg)
Definition: DynaTypes.h:233
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
void * m_pAgentArg
servo agent callback argument
Definition: DynaServo.h:842
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_TRY_SERVO_HAS_AGENT(pservo)
Test if the servo has a proxy agent.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::AgentWriteGoalSpeed ( int  nGoalSpeed)
virtual

Agent write to the servo state memory to set the new goal speed.

If the operation requires a servo proxy agent, then a call is made to the registered agent, if any. Otherwise a direct write to the servo is made.

Control Table:
RAM Goal Speed and Direction.
Dynamixel Angular Speed Common Values.
Parameters
nGoalSpeedGoal speed (raw).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 170 of file DynaServoGeneric.cxx.

References DYNA_ECODE_BAD_VAL, DYNA_SPEED_MAX_RAW, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_AGENT, DYNA_TRY_SERVO_HAS_POS_CTL, iabs(), DynaServo::m_comm, DynaAgent_T::m_fnWriteGoalSpeed, DynaServo::m_nServoId, DynaServo::m_pAgent, and DynaServo::m_pAgentArg.

Referenced by CvtRawVoltToVolts(), and Stop().

171 {
172  int rc;
173 
175  DYNA_TRY_IS_MASTER(this);
178 
179  DYNA_TRY_EXPR( (iabs(nGoalSpeed) <= DYNA_SPEED_MAX_RAW),
181  "Goal speed %d: Out of range.", nGoalSpeed);
182 
184 
185  return rc;
186 }
DynaAgent_T * m_pAgent
servo agent
Definition: DynaServo.h:841
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
INLINE_IN_H int iabs(int a)
Return absolute value of a.
Definition: DynaOlio.h:91
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
void * m_pAgentArg
servo agent callback argument
Definition: DynaServo.h:842
int(* m_fnWriteGoalSpeed)(int nServoId, int nGoalSpeed, void *pUsrArg)
Definition: DynaTypes.h:236
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_SERVO_HAS_AGENT(pservo)
Test if the servo has a proxy agent.
#define DYNA_SPEED_MAX_RAW
maximum raw value
Definition: Dynamixel.h:266
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::AgentWriteGoalSpeedPos ( int  nGoalSpeed,
int  nGoalOdPos 
)
virtual

Agent write to the servo state memory to set the new goal position and speed.

If the operation requires a servo proxy agent, then a call is made to the registered agent, if any. Otherwise a direct write to the servo is made.

Control Table:
RAM Goal Position.
Dynamixel Position Common Values. RAM Goal Speed and Direction.
Dynamixel Angular Speed Common Values.
Parameters
nGoalOdPosGoal position (odometer ticks).
nGoalSpeedGoal speed (raw).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 188 of file DynaServoGeneric.cxx.

References DYNA_ECODE_BAD_VAL, DYNA_SPEED_MAX_RAW, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_AGENT, DYNA_TRY_SERVO_HAS_POS_CTL, iabs(), DynaServo::m_comm, DynaAgent_T::m_fnWriteGoalSpeedPos, DynaServoOdometer_T::m_nOdGoalPos, DynaServo::m_nServoId, DynaServoState_T::m_od, DynaServo::m_pAgent, DynaServo::m_pAgentArg, and DynaServo::m_state.

Referenced by CvtRawVoltToVolts(), and MoveAtSpeedTo().

189 {
190  int rc;
191 
193  DYNA_TRY_IS_MASTER(this);
196 
197  DYNA_TRY_EXPR( (iabs(nGoalSpeed) <= DYNA_SPEED_MAX_RAW),
199  "Goal speed %d: Out of range.", nGoalSpeed);
200 
201  m_state.m_od.m_nOdGoalPos = nGoalOdPos;
202 
204  nGoalSpeed, nGoalOdPos,
205  m_pAgentArg);
206 
207  return rc;
208 }
int m_nOdGoalPos
odometer goal position
Definition: DynaTypes.h:183
DynaAgent_T * m_pAgent
servo agent
Definition: DynaServo.h:841
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
INLINE_IN_H int iabs(int a)
Return absolute value of a.
Definition: DynaOlio.h:91
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
int(* m_fnWriteGoalSpeedPos)(int nServoId, int nGoalSpeed, int nGoalPos, void *pUsrArg)
Definition: DynaTypes.h:239
void * m_pAgentArg
servo agent callback argument
Definition: DynaServo.h:842
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_TRY_SERVO_HAS_AGENT(pservo)
Test if the servo has a proxy agent.
#define DYNA_SPEED_MAX_RAW
maximum raw value
Definition: Dynamixel.h:266
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CalcMatesGoalPos ( int  nGoalOdPos,
int *  pGoalOdPosMate 
)
protectedvirtual

Calculate the linked mate's goal position given this servo's goal position.

Parameters
nGoalOdPosGoal position (odometer ticks).
[out]pGoalOdPosMateMate's calculated goal position (odometer ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1725 of file DynaServoGeneric.cxx.

References DYNA_ECODE_BAD_VAL, DYNA_OK, DYNA_TRY_EXPR, DYNA_TRY_RC, DynaServo::GetOdometer(), DynaServo::CrossLink_T::m_bRotReversed, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServoSpec_T::m_uRawPosMax, DynaServoSpec_T::m_uRawPosMin, DynaServo::OdometerToEncoder(), and ReadCurPos().

Referenced by CvtRawVoltToVolts(), and WriteGoalPos().

1726 {
1727  DynaServo *pServoMate;
1728  int nEncPos;
1729  int nGoalOdPosMate;
1730  uint_t uVal;
1731  int nVal;
1732  int delta;
1733  int rc;
1734 
1735  // linked mate
1736  pServoMate = m_link.m_pServoMate;
1737 
1738  // read latest current positions for master and mate
1739  rc = ReadCurPos(&nVal);
1740 
1741  DYNA_TRY_RC(rc, "Servo %d: Failed.", m_nServoId);
1742 
1743  // mates rotate in reverse directions to each other
1744  if( m_link.m_bRotReversed )
1745  {
1746  delta = GetOdometer() - nGoalOdPos;
1747 
1748  nGoalOdPosMate = pServoMate->GetOdometer() + delta;
1749 
1750  nEncPos = OdometerToEncoder(nGoalOdPosMate);
1751 
1752  DYNA_TRY_EXPR(((nEncPos >= m_spec.m_uRawPosMin) &&
1753  (nEncPos <= m_spec.m_uRawPosMax)),
1755  "Mate servo %d: Goal odometer position %d (encoder=%d): Out of range.",
1756  m_nServoId, nGoalOdPosMate, nEncPos);
1757  }
1758 
1759  // same rotation direction
1760  else
1761  {
1762  nGoalOdPosMate = nGoalOdPos;
1763  }
1764 
1765  if( rc == DYNA_OK )
1766  {
1767  *pGoalOdPosMate = nGoalOdPosMate;
1768  }
1769 
1770  return rc;
1771 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
uint_t m_uRawPosMin
minimum raw position value (servo mode)
Definition: DynaTypes.h:101
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
virtual int ReadCurPos(int *pCurOdPos)
Read from the servo state memory the current servo position.
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
int OdometerToEncoder(int nOdPos)
Convert virtual odometer units to servo encoder units.
Definition: DynaServo.h:367
uint_t m_uRawPosMax
maximum raw position value (servo mode)
Definition: DynaTypes.h:102
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_RC(rc, fmt,...)
Test if Dynamixel return code is not an error.
int GetOdometer()
Get the current virtual odometer value.
Definition: DynaServo.h:304
virtual int DynaServoGeneric::CalcMatesGoalSpeed ( int  nGoalSpeed)
inlineprotectedvirtual

Calculate the linked mate's speed speed given this servo's goal speed.

Returns
Mate's goal speed.

Implements DynaServo.

Definition at line 1043 of file DynaServoGeneric.h.

References ChkComplianceSlope(), DynaServo::CrossLink_T::m_bRotReversed, DynaServo::m_link, PackGoalSpeed(), ReadCtlMethodCompliance(), ReadCtlMethodPid(), UnpackCurLoad(), UnpackCurSpeed(), UnpackGoalSpeed(), WriteCtlMethodCompliance(), and WriteCtlMethodPid().

Referenced by WriteGoalSpeed().

1044  {
1045  return m_link.m_bRotReversed? -nGoalSpeed: nGoalSpeed;
1046  }
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int DynaServoGeneric::CfgReadAlarmShutdownMask ( uint_t *  pAlarmMask)
virtual

Read from the servo configuration EEPROM the current servo shutdown on alarms mask.

If this servo is the master in a linked pair of servos, both servos' configuration data are read.

Control Table:
EEPROM Alarm Shutdown.
Parameters
[out]pAlarmMaskShutdown alarm mask.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 702 of file DynaServoGeneric.cxx.

References DYNA_ADDR_ALARM_SHUTDOWN, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServoCfg_T::m_uAlarmShutdown, and DynaComm::Read8().

Referenced by CvtRawVoltToVolts(), and SyncCfg().

703 {
704  uint_t uVal; // working value
705  int rc; // return code
706 
708 
709  rc = m_comm.Read8(m_nServoId, DYNA_ADDR_ALARM_SHUTDOWN, pAlarmMask);
710 
711  if( rc == DYNA_OK )
712  {
713  m_cfg.m_uAlarmShutdown = *pAlarmMask;
714 
715  if( IsLinkedMaster() )
716  {
717  rc = m_link.m_pServoMate->CfgReadAlarmShutdownMask(&uVal);
718  }
719  }
720 
721  return rc;
722 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_ALARM_SHUTDOWN
alarm shutdown (RW)
Definition: Dynamixel.h:642
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
uint_t m_uAlarmShutdown
alarm shutdown mask enable causes
Definition: DynaTypes.h:135
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgReadMaxTorqueLimit ( uint_t *  pMaxTorqueLim)
virtual

Read from the servo configuration EEPROM the current on power-up maximum torque limit.

If this servo is the master in a linked pair of servos, both servos' configuration data are read.

Control Table:
EEPROM On Power-Up Maximum Torque Limit.
Dynamixel Torque Common Values.
Parameters
[out]pMaxTorqueLimMaximum torque limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 634 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_TORQUE_MAX_ON_LSB, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServoCfg_T::m_uLimTorqueMax, and DynaComm::Read16().

Referenced by CvtRawVoltToVolts(), and SyncCfg().

635 {
636  uint_t uVal; // working value
637  int rc; // return code
638 
640 
642  pMaxTorqueLim);
643 
644  if( rc == DYNA_OK )
645  {
646  m_cfg.m_uLimTorqueMax = *pMaxTorqueLim;
647 
648  if( IsLinkedMaster() )
649  {
650  rc = m_link.m_pServoMate->CfgReadMaxTorqueLimit(&uVal);
651  }
652  }
653 
654  return rc;
655 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
uint_t m_uLimTorqueMax
on power-up maximum torque limit
Definition: DynaTypes.h:132
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
#define DYNA_ADDR_LIM_TORQUE_MAX_ON_LSB
maximum torque lsb (RW)
Definition: Dynamixel.h:589
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgReadRotationLimits ( uint_t *  pCwLim,
uint_t *  pCcwLim 
)
virtual

Read from the servo configuration EEPROM the current rotation limits.

If this servo is the master in a linked pair of servos, both servos' configuration data are read.

Control Table:
EEPROM Clockwise Angle Limit.
EEPROM Counterclockwise Angle Limit.
Dynamixel Position Common Values.
Parameters
[out]pCwLimClockwise limit.
[out]pCcwLimCounterclockwise limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 361 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_CCW_LSB, DYNA_ADDR_LIM_CW_LSB, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServoCfg_T::m_uLimCcw, DynaServoCfg_T::m_uLimCw, DynaComm::Read16(), and SetServoMode().

Referenced by CfgReadServoMode(), CvtRawVoltToVolts(), and SyncCfg().

362 {
363  uint_t uVal1, uVal2; // working values
364  int rc; // return code
365 
367 
368  // Clockwise limit
370 
371  // Counter-clockwise limit
372  if( rc == DYNA_OK )
373  {
375  }
376 
377  // Update configuration and state.
378  if( rc == DYNA_OK )
379  {
380  m_cfg.m_uLimCw = *pCwLim;
381  m_cfg.m_uLimCcw = *pCcwLim;
382 
383  SetServoMode();
384 
385  if( IsLinkedMaster() )
386  {
387  rc = m_link.m_pServoMate->CfgReadRotationLimits(&uVal1, &uVal2);
388  }
389  }
390 
391  return rc;
392 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_LIM_CW_LSB
clockwise angle limit lsb (RW)
Definition: Dynamixel.h:464
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
void SetServoMode()
Set the servo mode given the servo capabilites and the current rotation limits.
uint_t m_uLimCcw
counterclockwise angle limit
Definition: DynaTypes.h:128
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
#define DYNA_ADDR_LIM_CCW_LSB
counterclockwise angle limit lsb (RW)
Definition: Dynamixel.h:483
uint_t m_uLimCw
clockwise angle limit (deg
Definition: DynaTypes.h:127
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgReadServoMode ( uint_t *  pServoMode)
virtual

Read from the servo configuration EEPROM to determine the servo operational mode.

If this servo is the master in a linked pair of servos, both servos' configuration data are read.

Control Table:
Dynamixel Operational Modes.
EEPROM Clockwise Angle Limit.
EEPROM Counterclockwise Angle Limit.
Parameters
[out]pServoModeServo mode.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 765 of file DynaServoGeneric.cxx.

References CfgReadRotationLimits(), DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::CrossLink_T::m_pServoMate, and DynaServoCfg_T::m_uServoMode.

Referenced by CvtRawVoltToVolts().

766 {
767  uint_t uCwLim; // clockwise limit
768  uint_t uCcwLim; // counterclockwise limit
769  int rc; // return limit
770 
772 
773  // mode set here
774  rc = CfgReadRotationLimits(&uCwLim, &uCcwLim);
775 
776  *pServoMode = m_cfg.m_uServoMode;
777 
778  if( rc == DYNA_OK )
779  {
780  if( IsLinkedMaster() )
781  {
782  rc = m_link.m_pServoMate->CfgReadRotationLimits(&uCwLim, &uCcwLim);
783  }
784  }
785 
786  return rc;
787 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
virtual int CfgReadRotationLimits(uint_t *pCwLim, uint_t *pCcwLim)
Read from the servo configuration EEPROM the current rotation limits.
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
uint_t m_uServoMode
servo mode Dynamixel Operational Modes
Definition: DynaTypes.h:136
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgReadTemperatureLimit ( uint_t *  pTempLim)
virtual

Read from the servo configuration EEPROM the current maximum temperature limit.

If this servo is the master in a linked pair of servos, both servos' configuration data are read.

Control Table:
EEPROM Temperature Limit.
Parameters
[out]pTempLimTemperature limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 469 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_TEMP_MAX, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServoCfg_T::m_uLimTemp, and DynaComm::Read8().

Referenced by CvtRawVoltToVolts(), and SyncCfg().

470 {
471  uint_t uVal; // working value
472  int rc; // return code
473 
475 
477 
478  if( rc == DYNA_OK )
479  {
480  m_cfg.m_uLimTemp = *pTempLim;
481 
482  if( IsLinkedMaster() )
483  {
484  rc = m_link.m_pServoMate->CfgReadTemperatureLimit(&uVal);
485  }
486  }
487 
488  return rc;
489 }
uint_t m_uLimTemp
maximum temperature limit
Definition: DynaTypes.h:129
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_ADDR_LIM_TEMP_MAX
maximum temperature limit (RW)
Definition: Dynamixel.h:503
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgReadVoltageLimits ( uint_t *  pMinVoltLim,
uint_t *  pMaxVoltLim 
)
virtual

Read from the servo configuration EEPROM the current voltage limits.

If this servo is the master in a linked pair of servos, both servos' configuration data are read.

Control Table:
EEPROM Minimum Voltage Limit.
EEPROM Maximum Voltage Limit.
Parameters
[out]pMinVoltLimMinimum voltage limit.
[out]pMaxVoltLimMaximum voltage limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 535 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_VOLT_MAX, DYNA_ADDR_LIM_VOLT_MIN, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServoCfg_T::m_uLimVoltMax, DynaServoCfg_T::m_uLimVoltMin, and DynaComm::Read8().

Referenced by CvtRawVoltToVolts(), and SyncCfg().

537 {
538  uint_t uVal1, uVal2; // working values
539  int rc; // return code
540 
542 
543  rc = m_comm.Read8(m_nServoId, DYNA_ADDR_LIM_VOLT_MIN, pMinVoltLim);
544 
545  if( rc == DYNA_OK )
546  {
547  rc = m_comm.Read8(m_nServoId, DYNA_ADDR_LIM_VOLT_MAX, pMaxVoltLim);
548  }
549 
550  if( rc == DYNA_OK )
551  {
552  m_cfg.m_uLimVoltMin = *pMinVoltLim;
553  m_cfg.m_uLimVoltMax = *pMaxVoltLim;
554 
555  if( IsLinkedMaster() )
556  {
557  rc = m_link.m_pServoMate->CfgReadVoltageLimits(&uVal1, &uVal2);
558  }
559  }
560 
561  return rc;
562 }
uint_t m_uLimVoltMin
minimum voltage limit
Definition: DynaTypes.h:130
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
#define DYNA_ADDR_LIM_VOLT_MIN
lowest voltage limit (RW)
Definition: Dynamixel.h:524
uint_t m_uLimVoltMax
maximum voltage limit
Definition: DynaTypes.h:131
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_ADDR_LIM_VOLT_MAX
highest voltage limit (RW)
Definition: Dynamixel.h:555
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgWriteAlarmShutdownMask ( uint_t  uAlarmMask)
virtual

Write to the servo configuration EEPROM the new servo shutdown on alarms mask.

Control Table:
EEPROM Alarm Shutdown.
Parameters
uAlarmMaskShutdown alarm mask.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 724 of file DynaServoGeneric.cxx.

References DYNA_ADDR_ALARM_SHUTDOWN, DYNA_ADDR_ALARM_SHUTDOWN_MASK, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServoCfg_T::m_uAlarmShutdown, DynaComm::vSyncWrite(), and DynaComm::Write8().

Referenced by CvtRawVoltToVolts().

725 {
726  int rc; // return code
727 
729  DYNA_TRY_IS_MASTER(this);
730 
731  uAlarmMask &= DYNA_ADDR_ALARM_SHUTDOWN_MASK;
732 
733  //
734  // Linked pair
735  //
736  if( IsLinkedMaster() )
737  {
739  m_nServoId, uAlarmMask,
740  m_link.m_pServoMate->GetServoId(), uAlarmMask);
741 
742  if( rc == DYNA_OK )
743  {
744  m_cfg.m_uAlarmShutdown = uAlarmMask;
746  }
747  }
748 
749  //
750  // Solitary servo
751  //
752  else
753  {
755 
756  if( rc == DYNA_OK )
757  {
758  m_cfg.m_uAlarmShutdown = uAlarmMask;
759  }
760  }
761 
762  return rc;
763 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_ALARM_SHUTDOWN
alarm shutdown (RW)
Definition: Dynamixel.h:642
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
uint_t m_uAlarmShutdown
alarm shutdown mask enable causes
Definition: DynaTypes.h:135
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
#define DYNA_ADDR_ALARM_SHUTDOWN_MASK
valid data mask
Definition: Dynamixel.h:644
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgWriteMaxTorqueLimit ( uint_t  uMaxTorqueLim)
virtual

Write to the servo configuration EEPROM the new on power-up maximum torque limit.

If this servo is the master in a linked pair of servos, both servos' configuration data are written.

Control Table:
EEPROM On Power-Up Maximum Torque Limit.
Dynamixel Torque Common Values.
Parameters
uMaxTorqueLimMaximum torque limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 657 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_TORQUE_MAX_ON_LSB, DYNA_ECODE_BAD_VAL, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServoCfg_T::m_uLimTorqueMax, DynaServoSpec_T::m_uRawTorqueMax, DynaServoSpec_T::m_uRawTorqueMin, DynaComm::vSyncWrite(), and DynaComm::Write16().

Referenced by CvtRawVoltToVolts().

658 {
659  int rc; // return code
660 
662  DYNA_TRY_IS_MASTER(this);
663 
664  DYNA_TRY_EXPR(((uMaxTorqueLim >= m_spec.m_uRawTorqueMin) &&
665  (uMaxTorqueLim <= m_spec.m_uRawTorqueMax)),
667  "Maximum torque limit %u: Out of range.", uMaxTorqueLim);
668 
669  //
670  // Linked pair
671  //
672  if( IsLinkedMaster() )
673  {
675  m_nServoId, uMaxTorqueLim,
676  m_link.m_pServoMate->GetServoId(), uMaxTorqueLim);
677 
678  if( rc == DYNA_OK )
679  {
680  m_cfg.m_uLimTorqueMax = uMaxTorqueLim;
681  m_link.m_pServoMate->m_cfg.m_uLimTorqueMax = uMaxTorqueLim;
682  }
683  }
684 
685  //
686  // Solitary servo
687  //
688  else
689  {
691  uMaxTorqueLim);
692 
693  if( rc == DYNA_OK )
694  {
695  m_cfg.m_uLimTorqueMax = uMaxTorqueLim;
696  }
697  }
698 
699  return rc;
700 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
uint_t m_uLimTorqueMax
on power-up maximum torque limit
Definition: DynaTypes.h:132
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int Write16(int nServoId, uint_t uAddr, ushort_t uhVal)=0
Write a 16-bit value to Dynamixel servo control table.
uint_t m_uRawTorqueMin
minimum raw torque value
Definition: DynaTypes.h:106
uint_t m_uRawTorqueMax
maximum raw torque value
Definition: DynaTypes.h:107
#define DYNA_ADDR_LIM_TORQUE_MAX_ON_LSB
maximum torque lsb (RW)
Definition: Dynamixel.h:589
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgWriteRotationLimits ( uint_t  uCwLim,
uint_t  uCcwLim 
)
virtual

Write to the servo configuration EEPROM the new rotation limits.

If this servo is the master in a linked pair of servos, both servos' configuration data are written.

Control Table:
EEPROM Clockwise Angle Limit. EEPROM Counterclockwise Angle Limit.
Dynamixel Position Common Values.
Parameters
uCwLimClockwise limit.
uCcwLimCounterclockwise limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 394 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_CCW_LSB, DYNA_ADDR_LIM_CW_LSB, DYNA_ECODE_BAD_VAL, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServoCfg_T::m_uLimCcw, DynaServoCfg_T::m_uLimCw, DynaServoSpec_T::m_uRawPosMax, DynaServoSpec_T::m_uRawPosMin, SetServoMode(), DynaComm::vSyncWrite(), and DynaComm::Write16().

Referenced by CfgWriteServoMode(), CfgWriteServoModeContinuous(), and CvtRawVoltToVolts().

395 {
396  int rc; // return code
397 
399  DYNA_TRY_IS_MASTER(this);
400 
401  DYNA_TRY_EXPR(((uCwLim >= m_spec.m_uRawPosMin) &&
402  (uCwLim <= m_spec.m_uRawPosMax)),
404  "Clockwise limit %u: Out of range.", uCwLim);
405 
406  DYNA_TRY_EXPR(((uCcwLim >= m_spec.m_uRawPosMin) &&
407  (uCcwLim <= m_spec.m_uRawPosMax)),
409  "Counterclockwise limit %u: Out of range.", uCcwLim);
410 
411  DYNA_TRY_EXPR((uCcwLim >= uCwLim), DYNA_ECODE_BAD_VAL,
412  "Counterclockwise limit %u: Smaller than clockwise limit %u.",
413  uCcwLim, uCwLim);
414 
415  //
416  // Linked pair
417  //
418  if( IsLinkedMaster() )
419  {
420  // Clockwise limit
422  m_nServoId, uCwLim,
423  m_link.m_pServoMate->GetServoId(), uCwLim);
424 
425  // Counter-clockwise limit
426  if( rc == DYNA_OK )
427  {
428  m_cfg.m_uLimCw = uCwLim;
429  m_link.m_pServoMate->m_cfg.m_uLimCw = uCwLim;
430 
432  m_nServoId, uCcwLim,
433  m_link.m_pServoMate->GetServoId(), uCcwLim);
434 
435  if( rc == DYNA_OK )
436  {
437  m_cfg.m_uLimCcw = uCcwLim;
438  m_link.m_pServoMate->m_cfg.m_uLimCcw = uCcwLim;
439  }
440  }
441  }
442 
443  //
444  // Solitary servo
445  //
446  else
447  {
448  // Clockwise limit
450 
451  // Counter-clockwise limit
452  if( rc == DYNA_OK )
453  {
454  m_cfg.m_uLimCw = uCwLim;
456  }
457 
458  // Update configuration and state.
459  if( rc == DYNA_OK )
460  {
461  m_cfg.m_uLimCcw = uCcwLim;
462  SetServoMode();
463  }
464  }
465 
466  return rc;
467 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_LIM_CW_LSB
clockwise angle limit lsb (RW)
Definition: Dynamixel.h:464
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
uint_t m_uRawPosMin
minimum raw position value (servo mode)
Definition: DynaTypes.h:101
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int Write16(int nServoId, uint_t uAddr, ushort_t uhVal)=0
Write a 16-bit value to Dynamixel servo control table.
void SetServoMode()
Set the servo mode given the servo capabilites and the current rotation limits.
uint_t m_uLimCcw
counterclockwise angle limit
Definition: DynaTypes.h:128
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
#define DYNA_ADDR_LIM_CCW_LSB
counterclockwise angle limit lsb (RW)
Definition: Dynamixel.h:483
uint_t m_uLimCw
clockwise angle limit (deg
Definition: DynaTypes.h:127
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
uint_t m_uRawPosMax
maximum raw position value (servo mode)
Definition: DynaTypes.h:102
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgWriteServoMode ( uint_t  uCwLim,
uint_t  uCcwLim 
)
virtual

Write to the servo configuration EEPROM to set the servo operational mode.

If this servo is the master in a linked pair of servos, both servos' configuration data are written.

Control Table:
Dynamixel Operational Modes.
EEPROM Clockwise Angle Limit.
EEPROM Counterclockwise Angle Limit.
Parameters
uCwLimClockwise limit.
uCcwLimCounterclockwise limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 789 of file DynaServoGeneric.cxx.

References CfgWriteRotationLimits(), DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, and DynaServo::m_comm.

Referenced by CvtRawVoltToVolts().

790 {
792  DYNA_TRY_IS_MASTER(this);
793 
794  return CfgWriteRotationLimits(uCwLim, uCcwLim);
795 }
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
virtual int CfgWriteRotationLimits(uint_t uCwLim, uint_t uCcwLim)
Write to the servo configuration EEPROM the new rotation limits.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgWriteServoModeContinuous ( )
virtual

Write to the servo configuration EEPROM to set the servo operational mode to the full/continuous mode.

If this servo is the master in a linked pair of servos, both servos' configuration data are written.

Control Table:
Dynamixel Operational Modes.
EEPROM Clockwise Angle Limit.
EEPROM Counterclockwise Angle Limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 797 of file DynaServoGeneric.cxx.

References CfgWriteRotationLimits(), DYNA_CCW_POS_CONT_MODE, DYNA_CW_POS_CONT_MODE, DYNA_MODE_CONTINUOUS, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_MODE, and DynaServo::m_comm.

Referenced by CvtRawVoltToVolts().

798 {
800  DYNA_TRY_IS_MASTER(this);
802 
804 }
#define DYNA_CCW_POS_CONT_MODE
continuous mode (with cw limit)
Definition: Dynamixel.h:488
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_TRY_SERVO_HAS_MODE(pservo, mode)
Test if the servo has one of the required modes exception macro.
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_CW_POS_CONT_MODE
continuous mode (with ccw limit)
Definition: Dynamixel.h:469
virtual int CfgWriteRotationLimits(uint_t uCwLim, uint_t uCcwLim)
Write to the servo configuration EEPROM the new rotation limits.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgWriteTemperatureLimit ( uint_t  uTempLim)
virtual

Write to the servo configuration EEPROM the new maximum temperature limit.

Control Table:
EEPROM Temperature Limit.
Parameters
uTempLimTemperature limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 491 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_TEMP_MAX, DYNA_ECODE_BAD_VAL, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServoCfg_T::m_uLimTemp, DynaServoSpec_T::m_uRawTempMax, DynaServoSpec_T::m_uRawTempMin, DynaComm::vSyncWrite(), and DynaComm::Write8().

Referenced by CvtRawVoltToVolts().

492 {
493  int rc; // return code
494 
496  DYNA_TRY_IS_MASTER(this);
497 
498  DYNA_TRY_EXPR(((uTempLim >= m_spec.m_uRawTempMin) &&
499  (uTempLim <= m_spec.m_uRawTempMax)),
501  "Temperature limit %u: Out of range.", uTempLim);
502 
503  //
504  // Linked pair
505  //
506  if( IsLinkedMaster() )
507  {
509  m_nServoId, uTempLim,
510  m_link.m_pServoMate->GetServoId(), uTempLim);
511 
512  if( rc == DYNA_OK )
513  {
514  m_cfg.m_uLimTemp = uTempLim;
515  m_link.m_pServoMate->m_cfg.m_uLimTemp = uTempLim;
516  }
517  }
518 
519  //
520  // Solitary servo
521  //
522  else
523  {
525 
526  if( rc == DYNA_OK )
527  {
528  m_cfg.m_uLimTemp = uTempLim;
529  }
530  }
531 
532  return rc;
533 }
uint_t m_uLimTemp
maximum temperature limit
Definition: DynaTypes.h:129
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
uint_t m_uRawTempMin
minimum raw temperature value
Definition: DynaTypes.h:108
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_ADDR_LIM_TEMP_MAX
maximum temperature limit (RW)
Definition: Dynamixel.h:503
uint_t m_uRawTempMax
maximum raw temperature value
Definition: DynaTypes.h:109
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::CfgWriteVoltageLimits ( uint_t  uMinVoltLim,
uint_t  uMaxVoltLim 
)
virtual

Write to the servo configuration EEPROM the new voltage limits.

If this servo is the master in a linked pair of servos, both servos' configuration data are written.

Control Table:
EEPROM Minimum Voltage Limit.
EEPROM Maximum Voltage Limit.
Parameters
uMinVoltLimMinimum voltage limit.
uMaxVoltLimMaximum voltage limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 564 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_VOLT_MAX, DYNA_ADDR_LIM_VOLT_MIN, DYNA_ECODE_BAD_VAL, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServoCfg_T::m_uLimVoltMax, DynaServoCfg_T::m_uLimVoltMin, DynaServoSpec_T::m_uRawVoltMax, DynaServoSpec_T::m_uRawVoltMin, DynaComm::vSyncWrite(), and DynaComm::Write8().

Referenced by CvtRawVoltToVolts().

566 {
567  int rc; // return code
568 
570  DYNA_TRY_IS_MASTER(this);
571 
572  DYNA_TRY_EXPR(((uMinVoltLim >= m_spec.m_uRawVoltMin) &&
573  (uMinVoltLim <= m_spec.m_uRawVoltMax)),
575  "Minimum voltage limit %u: Out of range.", uMinVoltLim);
576 
577  DYNA_TRY_EXPR(((uMaxVoltLim >= m_spec.m_uRawVoltMin) &&
578  (uMaxVoltLim <= m_spec.m_uRawVoltMax)),
580  "Maximum voltage limit %u: Out of range.", uMaxVoltLim);
581 
582  DYNA_TRY_EXPR((uMinVoltLim <= uMaxVoltLim), DYNA_ECODE_BAD_VAL,
583  "Maximum voltage limit %u: Smaller than minimum voltage limit %u.",
584  uMaxVoltLim, uMinVoltLim);
585 
586  //
587  // Linked pair
588  //
589  if( IsLinkedMaster() )
590  {
592  m_nServoId, uMinVoltLim,
593  m_link.m_pServoMate->GetServoId(), uMinVoltLim);
594 
595  if( rc == DYNA_OK )
596  {
597  m_cfg.m_uLimVoltMin = uMinVoltLim;
598  m_link.m_pServoMate->m_cfg.m_uLimVoltMin = uMinVoltLim;
599 
601  m_nServoId, uMaxVoltLim,
602  m_link.m_pServoMate->GetServoId(), uMaxVoltLim);
603  }
604 
605  if( rc == DYNA_OK )
606  {
607  m_cfg.m_uLimVoltMax = uMaxVoltLim;
608  m_link.m_pServoMate->m_cfg.m_uLimVoltMax = uMaxVoltLim;
609  }
610  }
611 
612  //
613  // Solitary servo
614  //
615  else
616  {
617  rc = m_comm.Write8(m_nServoId, DYNA_ADDR_LIM_VOLT_MIN, uMinVoltLim);
618 
619  if( rc == DYNA_OK )
620  {
621  m_cfg.m_uLimVoltMin = uMinVoltLim;
622  rc = m_comm.Write8(m_nServoId, DYNA_ADDR_LIM_VOLT_MAX, uMaxVoltLim);
623  }
624 
625  if( rc == DYNA_OK )
626  {
627  m_cfg.m_uLimVoltMax = uMaxVoltLim;
628  }
629  }
630 
631  return rc;
632 }
uint_t m_uLimVoltMin
minimum voltage limit
Definition: DynaTypes.h:130
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
uint_t m_uRawVoltMin
minimum raw voltage value
Definition: DynaTypes.h:110
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
#define DYNA_ADDR_LIM_VOLT_MIN
lowest voltage limit (RW)
Definition: Dynamixel.h:524
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
uint_t m_uLimVoltMax
maximum voltage limit
Definition: DynaTypes.h:131
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_ADDR_LIM_VOLT_MAX
highest voltage limit (RW)
Definition: Dynamixel.h:555
uint_t m_uRawVoltMax
maximum raw voltage value
Definition: DynaTypes.h:111
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
void DynaServoGeneric::CheckData ( )
protectedvirtual
bool DynaServoGeneric::ChkComplianceSlope ( uint_t  uVal)
protectedvirtual

Check validity of compliance slope discrete values.

Parameters
uValSlope value.
Returns
Returns true if value is valid, false otherwise.

Definition at line 2074 of file DynaServoGeneric.cxx.

References DYNA_COMP_SLOPE_TORQUE_1, DYNA_COMP_SLOPE_TORQUE_2, DYNA_COMP_SLOPE_TORQUE_3, DYNA_COMP_SLOPE_TORQUE_4, DYNA_COMP_SLOPE_TORQUE_5, DYNA_COMP_SLOPE_TORQUE_6, and DYNA_COMP_SLOPE_TORQUE_7.

Referenced by CalcMatesGoalSpeed(), and WriteCtlMethodCompliance().

2075 {
2076  switch( uVal )
2077  {
2085  return true;
2086  default:
2087  return false;
2088  }
2089 }
#define DYNA_COMP_SLOPE_TORQUE_2
compliance torque level 2
Definition: Dynamixel.h:786
#define DYNA_COMP_SLOPE_TORQUE_6
compliance torque level 6
Definition: Dynamixel.h:790
#define DYNA_COMP_SLOPE_TORQUE_4
compliance torque level 4
Definition: Dynamixel.h:788
#define DYNA_COMP_SLOPE_TORQUE_1
compliance torque level 1
Definition: Dynamixel.h:785
#define DYNA_COMP_SLOPE_TORQUE_3
compliance torque level 3
Definition: Dynamixel.h:787
#define DYNA_COMP_SLOPE_TORQUE_7
compliance torque level 7
Definition: Dynamixel.h:791
#define DYNA_COMP_SLOPE_TORQUE_5
compliance torque level 5
Definition: Dynamixel.h:789
virtual float DynaServoGeneric::CvtRawTempToC ( uint  uTemp)
inlinevirtual

Convert raw temperature coding to degrees Celsius.

Parameters
uTempRaw temperature value.
Returns
Celsius.

Implements DynaServo.

Definition at line 127 of file DynaServoGeneric.h.

128  {
129  return (float)uTemp; // 1-1 mapping
130  }
int DynaServoGeneric::EStop ( )
virtual

Emergency stop servo.

All torque is removed.

If this servo is the master in a linked pair of servos, both servos will be emergency stopped.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 264 of file DynaServoGeneric.cxx.

References DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::m_comm, Stop(), and WriteTorqueEnable().

Referenced by CvtRawVoltToVolts().

265 {
266  int nMaxTries = 3;
267  int nTries;
268  int rc;
269 
271  DYNA_TRY_IS_MASTER(this);
272 
273  Stop();
274 
275  for(nTries=0; nTries<nMaxTries; ++nTries)
276  {
277  if( (rc = WriteTorqueEnable(false)) == DYNA_OK )
278  {
279  break;
280  }
281  }
282  return rc;
283 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int WriteTorqueEnable(bool bState)
Write to the servo state memory to set the new torque enable value.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
virtual int Stop()
Stop servo.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::Freeze ( )
virtual

Freeze servo at current position.

Torque is applied.

If this servo is the master in a linked pair of servos, both servos will be frozen.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 326 of file DynaServoGeneric.cxx.

References DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::m_comm, Stop(), and WriteTorqueEnable().

Referenced by CvtRawVoltToVolts().

327 {
328  int rc_tmp; // temporary return code
329  int rc; // return code
330 
332  DYNA_TRY_IS_MASTER(this);
333 
334  rc = WriteTorqueEnable(true);
335 
336  rc_tmp = Stop();
337 
338  if( rc == DYNA_OK )
339  {
340  rc = rc_tmp;
341  }
342 
343  return rc;
344 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int WriteTorqueEnable(bool bState)
Write to the servo state memory to set the new torque enable value.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
virtual int Stop()
Stop servo.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::MoveAtSpeed ( int  nGoalSpeed)
virtual

Move at speed.

Speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify goal rotation in the clockwise direction, stop, or goal rotation in the counterclockwise direction, respectively.

If this servo is the master in a linked pair of servos, both servos will move synchronously.

Operational Modes:
Continuous mode (DYNA_MODE_CONTINUOUS).
Parameters
nGoalSpeedGoal speed (raw).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 255 of file DynaServoGeneric.cxx.

References DYNA_MODE_CONTINUOUS, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_IN_MODE, DynaServo::m_comm, and WriteGoalSpeed().

Referenced by CvtRawVoltToVolts().

256 {
258  DYNA_TRY_IS_MASTER(this);
260 
261  return WriteGoalSpeed(nGoalSpeed);
262 }
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int WriteGoalSpeed(int nGoalSpeed)
Write to the servo state memory the new goal speed and direction.
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_SERVO_IN_MODE(pservo, mode)
Test if the servo is in the given mode.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::MoveAtSpeedTo ( int  nGoalSpeed,
int  nGoalOdPos 
)
virtual

Move at speed to the goal postition.

For servos in continuous mode, speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify goal rotation in the clockwise direction, stop, or goal rotation in the counterclockwise direction, respectively.

For servos in servo mode, the goal direction is not applicable, and therefore, the speeds are in the range [0,max]. The special value 0 is equivalent to the maximum rpm speed without servo speed control. The absolute value of the goal speed is used.

If the servo is in continuous mode, but supports 360 ° positioning data, a registered external user control function is required.

If this servo is the master in a linked pair of servos, both servos will move synchronously.

Operational Modes:
Servo mode (DYNA_MODE_SERVO). The direction will be ignored.
Continuous mode (DYNA_MODE_CONTINUOUS) with 360 ° position data.
Parameters
nGoalSpeedGoal speed (raw).
nGoalOdPosGoal position (odometer ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 235 of file DynaServoGeneric.cxx.

References AgentWriteGoalSpeedPos(), DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_POS_CTL, DynaServo::HasAgent(), DynaServo::m_comm, WriteGoalPos(), and WriteGoalSpeed().

Referenced by CvtRawVoltToVolts().

236 {
237  int rc; // return code
238 
240  DYNA_TRY_IS_MASTER(this);
242 
243  if( HasAgent() )
244  {
245  rc = AgentWriteGoalSpeedPos(nGoalSpeed, nGoalOdPos);
246  }
247  else if( (rc = WriteGoalSpeed(nGoalSpeed)) == DYNA_OK )
248  {
249  rc = WriteGoalPos(nGoalOdPos);
250  }
251 
252  return rc;
253 }
virtual int WriteGoalPos(int nGoalOdPos)
Write to the servo state memory to set the new goal position.
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual bool HasAgent()
Tests if servo has a registered agent.
Definition: DynaServo.h:604
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int WriteGoalSpeed(int nGoalSpeed)
Write to the servo state memory the new goal speed and direction.
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
virtual int AgentWriteGoalSpeedPos(int nGoalSpeed, int nGoalOdPos)
Agent write to the servo state memory to set the new goal position and speed.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::MoveTo ( int  nGoalOdPos)
virtual

Move to the goal postition.

The move will proceed at the current goal speed. If the servo is in continuous mode, but supports 360 ° positioning data, then a registered external user control function is required.

If this servo is the master in a linked pair of servos, both servos will move synchronously.

Operational Modes:
Servo mode (DYNA_MODE_SERVO).
Continuous mode (DYNA_MODE_CONTINUOUS) with 360 ° position data.
Parameters
nGoalOdPosGoal position (odometer ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 215 of file DynaServoGeneric.cxx.

References AgentWriteGoalPos(), DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DYNA_TRY_SERVO_HAS_POS_CTL, DynaServo::HasAgent(), DynaServo::m_comm, and WriteGoalPos().

Referenced by CvtRawVoltToVolts().

216 {
217  int rc;
218 
220  DYNA_TRY_IS_MASTER(this);
222 
223  if( HasAgent() )
224  {
225  rc = AgentWriteGoalPos(nGoalOdPos);
226  }
227  else
228  {
229  rc = WriteGoalPos(nGoalOdPos);
230  }
231 
232  return rc;
233 }
virtual int WriteGoalPos(int nGoalOdPos)
Write to the servo state memory to set the new goal position.
virtual bool HasAgent()
Tests if servo has a registered agent.
Definition: DynaServo.h:604
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int AgentWriteGoalPos(int nGoalOdPos)
Agent write to the servo state memory to set the new goal position.
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
uint_t DynaServoGeneric::PackGoalSpeed ( int  nGoalSpeed)
protectedvirtual

Pack the goal speed into the control table value.

For servos in continuous mode, speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify rotation in the clockwise direction, stop, or rotation in the counterclockwise direction, respectively.

For servos in servo mode, the goal direction is not applicable, and therefore, the speeds are in the range [0,max]. The special value 0 is equivalent to the maximum rpm speed without servo speed control.

Parameters
nGoalSpeedGoal speed.
Returns
Returns packed value.

Implements DynaServo.

Definition at line 2091 of file DynaServoGeneric.cxx.

References DYNA_GOAL_SPEED_DIR_CCW, DYNA_GOAL_SPEED_DIR_CW, DYNA_GOAL_SPEED_MAG_MASK, DYNA_MODE_CONTINUOUS, iabs(), DynaServo::m_cfg, and DynaServoCfg_T::m_uServoMode.

Referenced by CalcMatesGoalSpeed(), and WriteGoalSpeed().

2092 {
2094  {
2095  return (uint_t)( (iabs(nGoalSpeed) & DYNA_GOAL_SPEED_MAG_MASK) |
2097  }
2098  else
2099  {
2100  return (uint_t)iabs(nGoalSpeed);
2101  }
2102 }
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
INLINE_IN_H int iabs(int a)
Return absolute value of a.
Definition: DynaOlio.h:91
#define DYNA_GOAL_SPEED_MAG_MASK
speed magnitude field mask
Definition: Dynamixel.h:945
#define DYNA_GOAL_SPEED_DIR_CW
clockwise direction
Definition: Dynamixel.h:951
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
#define DYNA_GOAL_SPEED_DIR_CCW
counterclockwise direction
Definition: Dynamixel.h:950
uint_t m_uServoMode
servo mode Dynamixel Operational Modes
Definition: DynaTypes.h:136
bool DynaServoGeneric::Ping ( )
virtual

Ping this servo.

Returns
Returns true if the servo responded, else false.

Implements DynaServo.

Definition at line 1493 of file DynaServoGeneric.cxx.

References DYNA_TRY_COMM, DynaServo::m_comm, DynaServo::m_nServoId, and DynaComm::Ping().

Referenced by CvtRawVoltToVolts().

1494 {
1496  return m_comm.Ping(m_nServoId);
1497 }
virtual bool Ping(int nServoId)=0
Ping the servo.
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::Read ( uint_t  uAddr,
uint_t *  pVal 
)
virtual

Read a raw value from the servo EEPROM/RAM control table.

Warning
The shadowed configuration and state data are not update.
Linked servos are not kept in sync.
Parameters
uAddrControl table address.
[out]pValRead raw value.

doc_return_std

Implements DynaServo.

Reimplemented in DynaServoEX106P.

Definition at line 1401 of file DynaServoGeneric.cxx.

References DYNA_ADDR_ALARM_LED, DYNA_ADDR_ALARM_SHUTDOWN, DYNA_ADDR_BAUD_RATE, DYNA_ADDR_CCW_COMP_MARGIN, DYNA_ADDR_CCW_COMP_SLOPE, DYNA_ADDR_CUR_LOAD_LSB, DYNA_ADDR_CUR_POS_LSB, DYNA_ADDR_CUR_SPEED_LSB, DYNA_ADDR_CUR_TEMP_C, DYNA_ADDR_CUR_VOLT, DYNA_ADDR_CW_COMP_MARGIN, DYNA_ADDR_CW_COMP_SLOPE, DYNA_ADDR_EEPROM_LOCK, DYNA_ADDR_FWVER, DYNA_ADDR_GOAL_POS_LSB, DYNA_ADDR_GOAL_SPEED_LSB, DYNA_ADDR_ID, DYNA_ADDR_IS_MOVING, DYNA_ADDR_LED, DYNA_ADDR_LIM_CCW_LSB, DYNA_ADDR_LIM_CW_LSB, DYNA_ADDR_LIM_TEMP_MAX, DYNA_ADDR_LIM_TORQUE_MAX_LSB, DYNA_ADDR_LIM_TORQUE_MAX_ON_LSB, DYNA_ADDR_LIM_VOLT_MAX, DYNA_ADDR_LIM_VOLT_MIN, DYNA_ADDR_MODEL_NUM_LSB, DYNA_ADDR_PUNCH_LSB, DYNA_ADDR_REG_INSTR, DYNA_ADDR_SRL, DYNA_ADDR_T_RET_DELAY, DYNA_ADDR_TORQUE_EN, DYNA_TRY_ADDR, DYNA_TRY_COMM, DynaServo::m_comm, DynaServo::m_nServoId, DynaComm::Read16(), and DynaComm::Read8().

Referenced by CvtRawVoltToVolts(), and DynaServoEX106P::Read().

1402 {
1404  DYNA_TRY_ADDR(uAddr);
1405 
1406  switch( uAddr )
1407  {
1409  case DYNA_ADDR_LIM_CW_LSB:
1410  case DYNA_ADDR_LIM_CCW_LSB:
1415  case DYNA_ADDR_CUR_POS_LSB:
1418  return m_comm.Read16(m_nServoId, uAddr, pVal);
1419 
1420  case DYNA_ADDR_FWVER:
1421  case DYNA_ADDR_ID:
1422  case DYNA_ADDR_BAUD_RATE:
1423  case DYNA_ADDR_T_RET_DELAY:
1427  case DYNA_ADDR_SRL:
1428  case DYNA_ADDR_ALARM_LED:
1430  case DYNA_ADDR_TORQUE_EN:
1431  case DYNA_ADDR_LED:
1436  case DYNA_ADDR_CUR_VOLT:
1437  case DYNA_ADDR_CUR_TEMP_C:
1438  case DYNA_ADDR_REG_INSTR:
1439  case DYNA_ADDR_IS_MOVING:
1440  case DYNA_ADDR_EEPROM_LOCK:
1441  case DYNA_ADDR_PUNCH_LSB:
1442  default:
1443  return m_comm.Read8(m_nServoId, uAddr, pVal);
1444  }
1445 }
#define DYNA_ADDR_ALARM_LED
alarm LED (RW)
Definition: Dynamixel.h:627
#define DYNA_ADDR_CUR_POS_LSB
current position lsb (R)
Definition: Dynamixel.h:985
#define DYNA_ADDR_ALARM_SHUTDOWN
alarm shutdown (RW)
Definition: Dynamixel.h:642
#define DYNA_ADDR_CW_COMP_SLOPE
clockwise compliance slope
Definition: Dynamixel.h:781
#define DYNA_ADDR_GOAL_SPEED_LSB
goal speed lsb (RW)
Definition: Dynamixel.h:940
#define DYNA_ADDR_MODEL_NUM_LSB
model number lsb (R)
Definition: Dynamixel.h:353
#define DYNA_ADDR_LIM_CW_LSB
clockwise angle limit lsb (RW)
Definition: Dynamixel.h:464
#define DYNA_ADDR_EEPROM_LOCK
lock the EEPROM (RW)
Definition: Dynamixel.h:1128
#define DYNA_ADDR_CW_COMP_MARGIN
clockwise compliance margin (RW)
Definition: Dynamixel.h:733
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
#define DYNA_TRY_ADDR(addr)
Test if servo address is valid.
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
#define DYNA_ADDR_LIM_VOLT_MIN
lowest voltage limit (RW)
Definition: Dynamixel.h:524
#define DYNA_ADDR_CUR_SPEED_LSB
current speed lsb (R)
Definition: Dynamixel.h:1009
#define DYNA_ADDR_CUR_TEMP_C
current temperature C (R)
Definition: Dynamixel.h:1076
#define DYNA_ADDR_LIM_TORQUE_MAX_LSB
current torque limit lsb (RW)
Definition: Dynamixel.h:965
#define DYNA_ADDR_IS_MOVING
is [not] moving (to goal position)
Definition: Dynamixel.h:1110
#define DYNA_ADDR_LIM_TORQUE_MAX_ON_LSB
maximum torque lsb (RW)
Definition: Dynamixel.h:589
#define DYNA_ADDR_CUR_VOLT
current voltage (R)
Definition: Dynamixel.h:1061
#define DYNA_ADDR_LED
LED on/off (RW)
Definition: Dynamixel.h:689
#define DYNA_ADDR_BAUD_RATE
baud rate enumeration (RW)
Definition: Dynamixel.h:396
int m_nServoId
servo id
Definition: DynaServo.h:836
#define DYNA_ADDR_ID
dynamixel id (RW)
Definition: Dynamixel.h:380
#define DYNA_ADDR_LIM_CCW_LSB
counterclockwise angle limit lsb (RW)
Definition: Dynamixel.h:483
#define DYNA_ADDR_SRL
status return level (RW)
Definition: Dynamixel.h:606
#define DYNA_ADDR_PUNCH_LSB
punch lsb (not used)
Definition: Dynamixel.h:1147
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_ADDR_T_RET_DELAY
return delay time (RW)
Definition: Dynamixel.h:434
#define DYNA_ADDR_LIM_TEMP_MAX
maximum temperature limit (RW)
Definition: Dynamixel.h:503
#define DYNA_ADDR_CUR_LOAD_LSB
current load lsb (R)
Definition: Dynamixel.h:1032
#define DYNA_ADDR_GOAL_POS_LSB
goal position lsb (RW)
Definition: Dynamixel.h:909
#define DYNA_ADDR_TORQUE_EN
torque enable (RW)
Definition: Dynamixel.h:672
#define DYNA_ADDR_REG_INSTR
registered instruction (RW)
Definition: Dynamixel.h:1092
#define DYNA_ADDR_LIM_VOLT_MAX
highest voltage limit (RW)
Definition: Dynamixel.h:555
#define DYNA_ADDR_FWVER
firmware version (R)
Definition: Dynamixel.h:367
#define DYNA_ADDR_CCW_COMP_MARGIN
counterclockwise compliance margin
Definition: Dynamixel.h:766
#define DYNA_ADDR_CCW_COMP_SLOPE
counterclockwise compliance slope
Definition: Dynamixel.h:810
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadControlMethod ( DynaServoCtlMethod_T pCtlMethod)
virtual

Read from the servo state memory the current control method parameters.

The control method used is determined by the servo's specification.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
Dynamixel Internal Position Control Methods.
RAM Clockwise Compliance Margin.
RAM Counterclockwise Compliance Margin.
RAM Clockwise Compliance Slope.
RAM Counterclockwise Compliance Slope.
RAM PID P Gain.
RAM PID I Gain.
RAM PID D Gain.
Parameters
[out]pCtlMethodControl method parameters.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 940 of file DynaServoGeneric.cxx.

References DYNA_CTL_METHOD_COMPLIANCE, DYNA_CTL_METHOD_PID, DYNA_ECODE_INTERNAL, DYNA_LOG_ERROR, DYNA_TRY_COMM, DynaServo::m_comm, DynaServo::m_nServoId, DynaServo::m_spec, DynaServoSpec_T::m_uCtlMethodUsed, ReadCtlMethodCompliance(), and ReadCtlMethodPid().

Referenced by CvtRawVoltToVolts(), and SyncState().

941 {
942  int rc; // return code
943 
945 
946  switch( m_spec.m_uCtlMethodUsed )
947  {
949  return ReadCtlMethodCompliance(pCtlMethod);
950  case DYNA_CTL_METHOD_PID:
951  return ReadCtlMethodPid(pCtlMethod);
952  default:
953  rc = -DYNA_ECODE_INTERNAL;
954  DYNA_LOG_ERROR(rc, "Servo %d: Unknown control method %u.",
956  return rc;
957  }
958 }
#define DYNA_CTL_METHOD_COMPLIANCE
compliance control method
Definition: Dynamixel.h:216
uint_t m_uCtlMethodUsed
Dynamixel Internal Position Control Methods
Definition: DynaTypes.h:100
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
virtual int ReadCtlMethodPid(DynaServoCtlMethod_T *pCtlMethod)
Read from the servo state memory the current PID control method parameters.
#define DYNA_CTL_METHOD_PID
pid control method
Definition: Dynamixel.h:217
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual int ReadCtlMethodCompliance(DynaServoCtlMethod_T *pCtlMethod)
Read from the servo state memory the current compliance control method parameters.
#define DYNA_ECODE_INTERNAL
internal error (bug)
Definition: Dynamixel.h:82
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadCtlMethodCompliance ( DynaServoCtlMethod_T pCtlMethod)
protectedvirtual

Read from the servo state memory the current compliance control method parameters.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
Dynamixel Internal Position Control Methods.
RAM Clockwise Compliance Margin.
RAM Counterclockwise Compliance Margin.
RAM Clockwise Compliance Slope.
RAM Counterclockwise Compliance Slope.
Parameters
[out]pCtlMethodControl method parameters.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 1773 of file DynaServoGeneric.cxx.

References DYNA_ADDR_CCW_COMP_MARGIN, DYNA_ADDR_CCW_COMP_SLOPE, DYNA_ADDR_CW_COMP_MARGIN, DYNA_ADDR_CW_COMP_SLOPE, DYNA_CTL_METHOD_COMPLIANCE, DYNA_OK, DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServoCtlMethod_T::m_comp, DynaServoState_T::m_ctlMethod, DynaServo::m_link, DynaServo::m_nServoId, DynaServoCtlMethod_T::m_params, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaServoCtlMethod_T::m_uCtlMethod, and DynaComm::Read8().

Referenced by CalcMatesGoalSpeed(), and ReadControlMethod().

1774 {
1775  DynaServoCtlMethod_T *pVal; // working value
1776  int rc; // return code
1777 
1779 
1781  &(pCtlMethod->m_params.m_comp.m_uCwMargin));
1782 
1783  if( rc == DYNA_OK )
1784  {
1786  &(pCtlMethod->m_params.m_comp.m_uCcwMargin));
1787  }
1788 
1789  if( rc == DYNA_OK )
1790  {
1792  &(pCtlMethod->m_params.m_comp.m_uCwSlope));
1793  }
1794 
1795  if( rc == DYNA_OK )
1796  {
1798  &(pCtlMethod->m_params.m_comp.m_uCcwSlope));
1799  }
1800 
1801  if( rc == DYNA_OK )
1802  {
1803  m_state.m_ctlMethod = *pCtlMethod;
1804 
1805  if( IsLinkedMaster() )
1806  {
1807  rc = m_link.m_pServoMate->ReadControlMethod(pVal);
1808  }
1809  }
1810 
1811  return rc;
1812 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_CTL_METHOD_COMPLIANCE
compliance control method
Definition: Dynamixel.h:216
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_CW_COMP_SLOPE
clockwise compliance slope
Definition: Dynamixel.h:781
#define DYNA_ADDR_CW_COMP_MARGIN
clockwise compliance margin (RW)
Definition: Dynamixel.h:733
uint_t m_uCtlMethod
Dynamixel Internal Position Control Methods
Definition: DynaTypes.h:148
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
Dynamixel Control Method Structure.
Definition: DynaTypes.h:146
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
union DynaServoCtlMethod_T::@2 m_params
parameters to control methods
struct DynaServoCtlMethod_T::@2::@3 m_comp
compliance control method parameters
DynaServoCtlMethod_T m_ctlMethod
position control method
Definition: DynaTypes.h:199
#define DYNA_ADDR_CCW_COMP_MARGIN
counterclockwise compliance margin
Definition: Dynamixel.h:766
#define DYNA_ADDR_CCW_COMP_SLOPE
counterclockwise compliance slope
Definition: Dynamixel.h:810
int DynaServoGeneric::ReadCtlMethodPid ( DynaServoCtlMethod_T pCtlMethod)
protectedvirtual

Read from the servo state memory the current PID control method parameters.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
Dynamixel Internal Position Control Methods.
RAM PID P Gain.
RAM PID I Gain.
RAM PID D Gain.
Parameters
[out]pCtlMethodControl method parameters.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 1939 of file DynaServoGeneric.cxx.

References DYNA_ADDR_D_GAIN, DYNA_ADDR_I_GAIN, DYNA_ADDR_P_GAIN, DYNA_CTL_METHOD_PID, DYNA_OK, DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServoState_T::m_ctlMethod, DynaServo::m_link, DynaServo::m_nServoId, DynaServoCtlMethod_T::m_params, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaServoCtlMethod_T::m_uCtlMethod, and DynaComm::Read8().

Referenced by CalcMatesGoalSpeed(), and ReadControlMethod().

1940 {
1941  DynaServoCtlMethod_T *pVal; // working value
1942  int rc; // return code
1943 
1944  pCtlMethod->m_uCtlMethod = DYNA_CTL_METHOD_PID;
1945 
1947  &(pCtlMethod->m_params.m_pid.m_uPGain));
1948 
1949  if( rc == DYNA_OK )
1950  {
1952  &(pCtlMethod->m_params.m_pid.m_uIGain));
1953  }
1954 
1955  if( rc == DYNA_OK )
1956  {
1958  &(pCtlMethod->m_params.m_pid.m_uDGain));
1959  }
1960 
1961  if( rc == DYNA_OK )
1962  {
1963  m_state.m_ctlMethod = *pCtlMethod;
1964 
1965  if( IsLinkedMaster() )
1966  {
1967  rc = m_link.m_pServoMate->ReadControlMethod(pVal);
1968  }
1969  }
1970 
1971  return rc;
1972 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
uint_t m_uCtlMethod
Dynamixel Internal Position Control Methods
Definition: DynaTypes.h:148
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
Dynamixel Control Method Structure.
Definition: DynaTypes.h:146
#define DYNA_ADDR_I_GAIN
Igain (RW)
Definition: Dynamixel.h:857
#define DYNA_CTL_METHOD_PID
pid control method
Definition: Dynamixel.h:217
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
union DynaServoCtlMethod_T::@2 m_params
parameters to control methods
#define DYNA_ADDR_D_GAIN
Dgain (RW)
Definition: Dynamixel.h:879
DynaServoCtlMethod_T m_ctlMethod
position control method
Definition: DynaTypes.h:199
#define DYNA_ADDR_P_GAIN
Pgain (RW)
Definition: Dynamixel.h:835
int DynaServoGeneric::ReadCurLoad ( int *  pCurLoad)
virtual

Read from the servo state memory the current load.

Loads are in the range [-max,max] where the values < 0, 0, and > 0 specify torques loads in clockwise direction, no torque load, or torque loads in the counterclockwise direction, respectively. Load is approximately 0.1% of maximum.

Control Table:
RAM Current Load.
Parameters
[out]pCurLoadCurrent load.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1275 of file DynaServoGeneric.cxx.

References DYNA_ADDR_CUR_LOAD_LSB, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServo::m_link, DynaServoState_T::m_nCurLoad, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaComm::Read16(), and UnpackCurLoad().

Referenced by CvtRawVoltToVolts(), ReadDynamics(), and ReadHealth().

1276 {
1277  uint_t uVal; // working value
1278  int nVal; // working value
1279  int rc; // return code
1280 
1282 
1284 
1285  if( rc == DYNA_OK )
1286  {
1288  *pCurLoad = m_state.m_nCurLoad;
1289 
1290  if( IsLinkedMaster() )
1291  {
1292  rc = m_link.m_pServoMate->ReadCurLoad(&nVal);
1293  }
1294  }
1295 
1296  return rc;
1297 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
int m_nCurLoad
current load
Definition: DynaTypes.h:208
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_ADDR_CUR_LOAD_LSB
current load lsb (R)
Definition: Dynamixel.h:1032
virtual int UnpackCurLoad(uint_t uVal)
Unpack current load estimate from the control table value.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadCurPos ( int *  pCurOdPos)
virtual

Read from the servo state memory the current servo position.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Current Position.
Dynamixel Position Common Values.
Parameters
[out]pCurOdPosOdometer current position (ticks).
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1222 of file DynaServoGeneric.cxx.

References DYNA_ADDR_CUR_POS_LSB, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_SERVO_HAS_POS_CTL, DynaServo::GetOdometer(), DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaServoState_T::m_uCurPos, DynaComm::Read16(), and DynaServo::UpdateOdometer().

Referenced by CalcMatesGoalPos(), CvtRawVoltToVolts(), ReadDynamics(), Stop(), and SyncState().

1223 {
1224  uint_t uVal; // working value
1225  int nVal; // working value
1226  int rc; // return code
1227 
1230 
1232 
1233  if( rc == DYNA_OK )
1234  {
1235  m_state.m_uCurPos = uVal;
1236 
1237  UpdateOdometer((int)uVal);
1238 
1239  *pCurOdPos = GetOdometer();
1240 
1241  if( IsLinkedMaster() )
1242  {
1243  rc = m_link.m_pServoMate->ReadCurPos(&nVal);
1244  }
1245  }
1246 
1247  return rc;
1248 }
virtual int UpdateOdometer(int nEncCurPos)
Update the odometer from the current servo position and rotation direction.
Definition: DynaServo.cxx:207
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_ADDR_CUR_POS_LSB
current position lsb (R)
Definition: Dynamixel.h:985
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
uint_t m_uCurPos
current position (encoder ticks)
Definition: DynaTypes.h:206
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
Test if the servo has positiion control.
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
int GetOdometer()
Get the current virtual odometer value.
Definition: DynaServo.h:304
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadCurSpeed ( int *  pCurSpeed)
virtual

Read from the servo state memory the current speed and direction.

Speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify the servo is rotating in the clockwise direction, the servo is stopped, or the servo is rotating in the counterclockwise direction, respectively.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Current Speed and Direction.
Dynamixel Angular Speed Common Values.
Dynamixel Direction Common Values.
Parameters
[out]pCurSpeedCurrent speed.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1250 of file DynaServoGeneric.cxx.

References DYNA_ADDR_CUR_SPEED_LSB, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServo::m_link, DynaServoState_T::m_nCurSpeed, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaComm::Read16(), and UnpackCurSpeed().

Referenced by CvtRawVoltToVolts(), ReadDynamics(), and SyncState().

1251 {
1252  uint_t uVal; // working value
1253  int nVal; // working value
1254  int rc; // return code
1255 
1257 
1259 
1260  if( rc == DYNA_OK )
1261  {
1262 
1264  *pCurSpeed = m_state.m_nCurSpeed;
1265 
1266  if( IsLinkedMaster() )
1267  {
1268  rc = m_link.m_pServoMate->ReadCurSpeed(&nVal);
1269  }
1270  }
1271 
1272  return rc;
1273 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int UnpackCurSpeed(uint_t uVal)
Unpack current speed from the control table value.
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
#define DYNA_ADDR_CUR_SPEED_LSB
current speed lsb (R)
Definition: Dynamixel.h:1009
int m_nCurSpeed
current speed (raw)
Definition: DynaTypes.h:207
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadDynamics ( int *  pCurPos,
int *  pCurSpeed,
int *  pCurLoad 
)
virtual

Read from the servo state memory the current servo dynamics.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Current Position.
RAM Current Speed and Direction.
RAM Current Load.
Parameters
[out]pCurPosCurrent position.
[out]pCurSpeedCurrent speed.
[out]pCurLoadCurrent load.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1299 of file DynaServoGeneric.cxx.

References DYNA_OK, DYNA_TRY_COMM, DynaServo::m_comm, ReadCurLoad(), ReadCurPos(), and ReadCurSpeed().

Referenced by CvtRawVoltToVolts().

1302 {
1303  int rc, rc_tmp; // return codes
1304 
1306 
1307  rc = ReadCurPos(pCurPos);
1308 
1309  rc_tmp = ReadCurSpeed(pCurSpeed);
1310 
1311  if( rc == DYNA_OK )
1312  {
1313  rc = rc_tmp;
1314  }
1315 
1316  rc_tmp = ReadCurLoad(pCurLoad);
1317 
1318  if( rc == DYNA_OK )
1319  {
1320  rc = rc_tmp;
1321  }
1322 
1323  return rc;
1324 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int ReadCurLoad(int *pCurLoad)
Read from the servo state memory the current load.
virtual int ReadCurPos(int *pCurOdPos)
Read from the servo state memory the current servo position.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
virtual int ReadCurSpeed(int *pCurSpeed)
Read from the servo state memory the current speed and direction.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadGoalPos ( int *  pGoalPos)
virtual

Read from the servo state memory the current goal position.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Goal Position.
Dynamixel Position Common Values.
Parameters
[out]pGoalPosServo Mode: Encoder goal position.
Continuous Mode: Odometer goal position.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 981 of file DynaServoGeneric.cxx.

References DYNA_ADDR_GOAL_POS_LSB, DYNA_MODE_CONTINUOUS, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServoOdometer_T::m_nOdGoalPos, DynaServo::m_nServoId, DynaServoState_T::m_od, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaServoState_T::m_uGoalPos, DynaServoCfg_T::m_uServoMode, and DynaComm::Read16().

Referenced by CvtRawVoltToVolts(), and SyncState().

982 {
983  uint_t uVal; // working value
984  int nValMate; // working mate's value
985  int rc; // return code
986 
988 
990  {
991  *pGoalPos = m_state.m_od.m_nOdGoalPos;
992  rc = DYNA_OK;
993  }
994  else
995  {
997 
998  if( rc == DYNA_OK )
999  {
1000  m_state.m_uGoalPos = uVal;
1001  *pGoalPos = uVal;
1002 
1003  if( IsLinkedMaster() )
1004  {
1005  rc = m_link.m_pServoMate->ReadGoalPos(&nValMate);
1006  }
1007  }
1008  }
1009 
1010  return rc;
1011 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
int m_nOdGoalPos
odometer goal position
Definition: DynaTypes.h:183
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
DynaServoOdometer_T m_od
servo virtual odometer
Definition: DynaTypes.h:212
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
uint_t m_uServoMode
servo mode Dynamixel Operational Modes
Definition: DynaTypes.h:136
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
uint_t m_uGoalPos
goal position (encoder ticks)
Definition: DynaTypes.h:200
#define DYNA_ADDR_GOAL_POS_LSB
goal position lsb (RW)
Definition: Dynamixel.h:909
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadGoalSpeed ( int *  pGoalSpeed)
virtual

Read from the servo state memory the current goal speed and direction.

For servos in continuous mode, speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify goal rotation in the clockwise direction, stop, or goal rotation in the counterclockwise direction, respectively.

For servos in servo mode, the goal direction is not applicable, and therefore, the speeds are in the range [0,max]. The special value 0 is equivalent to the maximum rpm speed without servo speed control.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Goal Speed and Direction.
Dynamixel Angular Speed Common Values.
Dynamixel Direction Common Values.
Parameters
[out]pGoalSpeedGoal speed.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1072 of file DynaServoGeneric.cxx.

References DYNA_ADDR_GOAL_SPEED_LSB, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServo::m_link, DynaServoState_T::m_nGoalSpeed, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaComm::Read16(), and UnpackGoalSpeed().

Referenced by CvtRawVoltToVolts(), and SyncState().

1073 {
1074  uint_t uVal; // working value
1075  int nVal; // working value
1076  int rc; // return code
1077 
1079 
1081 
1082  if( rc == DYNA_OK )
1083  {
1085  *pGoalSpeed = m_state.m_nGoalSpeed;
1086 
1087  if( IsLinkedMaster() )
1088  {
1089  rc = m_link.m_pServoMate->ReadGoalSpeed(&nVal);
1090  }
1091  }
1092 
1093  return rc;
1094 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_GOAL_SPEED_LSB
goal speed lsb (RW)
Definition: Dynamixel.h:940
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
int m_nGoalSpeed
goal speed (raw)
Definition: DynaTypes.h:201
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual int UnpackGoalSpeed(uint_t uVal)
Unpack goal speed from the control table value.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadHealth ( uint_t *  pAlarms,
int *  pCurLoad,
uint_t *  pCurVolt,
uint_t *  pCurTemp 
)
virtual

Read from the servo state memory the current servo health.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Current Load.
RAM Current Voltage.
RAM Current Temperature.
Parameters
[out]pAlarmsServo alarms.
[out]pCurLoadCurrent load.
[out]pCurVoltCurrent voltage.
[out]pCurTempCurrent temperature.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1326 of file DynaServoGeneric.cxx.

References DYNA_ADDR_CUR_TEMP_C, DYNA_ADDR_CUR_VOLT, DYNA_OK, DYNA_TRY_COMM, DynaComm::GetAlarms(), DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaServoState_T::m_uAlarms, DynaServoState_T::m_uCurTemp, DynaServoState_T::m_uCurVolt, DynaComm::Read8(), and ReadCurLoad().

Referenced by CvtRawVoltToVolts(), and SyncState().

1330 {
1331  uint_t uVal1; // working value
1332  int nVal2; // woking value
1333  uint_t uVal3, uVal4; // working values
1334  int rc, rc_tmp; // return codes
1335 
1337 
1338  rc = ReadCurLoad(pCurLoad);
1339 
1340  rc_tmp = m_comm.Read8(m_nServoId, DYNA_ADDR_CUR_VOLT, pCurVolt);
1341 
1342  if( rc_tmp == DYNA_OK )
1343  {
1344  m_state.m_uCurVolt = *pCurVolt;
1345  }
1346  else if( rc == DYNA_OK )
1347  {
1348  rc = rc_tmp;
1349  }
1350 
1351  rc_tmp = m_comm.Read8(m_nServoId, DYNA_ADDR_CUR_TEMP_C, pCurTemp);
1352 
1353  if( rc_tmp == DYNA_OK )
1354  {
1355  m_state.m_uCurTemp = *pCurTemp;
1356  }
1357  else if( rc == DYNA_OK )
1358  {
1359  rc = rc_tmp;
1360  }
1361 
1362  if( rc == DYNA_OK )
1363  {
1364  if( IsLinkedMaster() )
1365  {
1366  rc = m_link.m_pServoMate->ReadHealth(&uVal1, &nVal2, &uVal3, &uVal4);
1367  }
1368  }
1369 
1371  *pAlarms = m_state.m_uAlarms;
1372 
1373  return rc;
1374 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int ReadCurLoad(int *pCurLoad)
Read from the servo state memory the current load.
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
#define DYNA_ADDR_CUR_TEMP_C
current temperature C (R)
Definition: Dynamixel.h:1076
uint_t m_uCurVolt
current voltage
Definition: DynaTypes.h:209
virtual uint_t GetAlarms()
Get current alarms.
Definition: DynaComm.h:393
uint_t m_uAlarms
current servo alarms and errors
Definition: DynaTypes.h:196
#define DYNA_ADDR_CUR_VOLT
current voltage (R)
Definition: Dynamixel.h:1061
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
uint_t m_uCurTemp
current temperature
Definition: DynaTypes.h:210
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadIsMoving ( bool *  pState)
virtual

Read from the servo state memory to test if the servo is currently moving.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Servo Is Moving.
Parameters
[out]pStateServo is [not] moving (true/false) state.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1376 of file DynaServoGeneric.cxx.

References DYNA_ADDR_IS_MOVING, DYNA_IS_NOT_MOVING, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServoState_T::m_bIsMoving, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, and DynaComm::Read8().

Referenced by CvtRawVoltToVolts(), and SyncState().

1377 {
1378  uint_t uVal; // working value
1379  bool bVal; // working boolean
1380  int rc; // return code
1381 
1383 
1385 
1386  if( rc == DYNA_OK )
1387  {
1388  *pState = uVal==DYNA_IS_NOT_MOVING? false: true;
1389 
1390  m_state.m_bIsMoving = *pState;
1391 
1392  if( IsLinkedMaster() )
1393  {
1394  rc = m_link.m_pServoMate->ReadIsMoving(&bVal);
1395  }
1396  }
1397 
1398  return rc;
1399 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
#define DYNA_IS_NOT_MOVING
not moving
Definition: Dynamixel.h:1114
#define DYNA_ADDR_IS_MOVING
is [not] moving (to goal position)
Definition: Dynamixel.h:1110
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
bool_t m_bIsMoving
servo is [not] moving
Definition: DynaTypes.h:211
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadLed ( bool *  pState)
virtual

Read from the servo state memory the current LED on/off value.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM LED On/Off.
Parameters
[out]pStateOn (true) or off (false) state.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 873 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LED, DYNA_LED_OFF, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServoState_T::m_bLed, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, and DynaComm::Read8().

Referenced by CvtRawVoltToVolts(), and SyncState().

874 {
875  uint_t uVal; // working value
876  bool bVal; // working boolean
877  int rc; // return code
878 
880 
881  rc = m_comm.Read8(m_nServoId, DYNA_ADDR_LED, &uVal);
882 
883  if( rc == DYNA_OK )
884  {
885  *pState = uVal==DYNA_LED_OFF? false: true;
886 
887  m_state.m_bLed = *pState;
888 
889  if( IsLinkedMaster() )
890  {
891  rc = m_link.m_pServoMate->ReadLed(&bVal);
892  }
893  }
894 
895  return rc;
896 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_LED_OFF
LED off.
Definition: Dynamixel.h:693
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
bool_t m_bLed
led on/off
Definition: DynaTypes.h:198
#define DYNA_ADDR_LED
LED on/off (RW)
Definition: Dynamixel.h:689
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadMaxTorqueLimit ( uint_t *  pMaxTorqueLim)
virtual

Read from the servo state memory the current maximum torque limit.

The servo will initially set this value to the value in the RAM Maximum Torque Limit configuration. The servo will set this value to 0 on an alarm shutdown event.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Maximum Torque Limit.
Dynamixel Torque Common Values.
Parameters
[out]pMaxTorqueLimMaximum torque limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1147 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_TORQUE_MAX_LSB, DYNA_OK, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaServoState_T::m_uLimTorqueMax, and DynaComm::Read16().

Referenced by CvtRawVoltToVolts(), and SyncState().

1148 {
1149  uint_t uVal; // working value
1150  int rc; // return code
1151 
1153 
1154  rc = m_comm.Read16(m_nServoId, DYNA_ADDR_LIM_TORQUE_MAX_LSB, pMaxTorqueLim);
1155 
1156  if( rc == DYNA_OK )
1157  {
1158  m_state.m_uLimTorqueMax = *pMaxTorqueLim;
1159 
1160  if( IsLinkedMaster() )
1161  {
1162  rc = m_link.m_pServoMate->ReadMaxTorqueLimit(&uVal);
1163  }
1164  }
1165 
1166  return rc;
1167 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Read16(int nServoId, uint_t uAddr, ushort_t *pVal)=0
Read a 16-bit value from Dynamixel servo control table.
uint_t m_uLimTorqueMax
maximum torque limit
Definition: DynaTypes.h:202
#define DYNA_ADDR_LIM_TORQUE_MAX_LSB
current torque limit lsb (RW)
Definition: Dynamixel.h:965
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReadTorqueEnable ( bool *  pState)
virtual

Read from the servo state memory the current torque enable value.

If this servo is the master in a linked pair of servos, both servos' state data are read.

Control Table:
RAM Torque Enable.
Parameters
[out]pStateTorque enabled (true) or disabled (off) state.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 806 of file DynaServoGeneric.cxx.

References DYNA_ADDR_TORQUE_EN, DYNA_OK, DYNA_TORQUE_EN_OFF, DYNA_TRY_COMM, DynaServo::IsLinkedMaster(), DynaServoState_T::m_bTorqueEnabled, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, and DynaComm::Read8().

Referenced by CvtRawVoltToVolts(), and SyncState().

807 {
808  uint_t uVal; // working value
809  bool bVal; // working boolean
810  int rc; // return code
811 
813 
815 
816  if( rc == DYNA_OK )
817  {
818  *pState = uVal==DYNA_TORQUE_EN_OFF? false: true;
819 
820  m_state.m_bTorqueEnabled = *pState;
821 
822  if( IsLinkedMaster() )
823  {
824  rc = m_link.m_pServoMate->ReadTorqueEnable(&bVal);
825  }
826  }
827 
828  return rc;
829 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_TORQUE_EN_OFF
disable power drive to the motor
Definition: Dynamixel.h:676
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
bool_t m_bTorqueEnabled
torque [not] enabled
Definition: DynaTypes.h:197
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_ADDR_TORQUE_EN
torque enable (RW)
Definition: Dynamixel.h:672
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::Release ( )
virtual

Release servo from any applied torque.

Servo is free to rotate.

If this servo is the master in a linked pair of servos, both servos will be released.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 346 of file DynaServoGeneric.cxx.

References DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::m_comm, Stop(), and WriteTorqueEnable().

Referenced by CvtRawVoltToVolts().

347 {
349  DYNA_TRY_IS_MASTER(this);
350 
351  Stop();
352 
353  return WriteTorqueEnable(false);
354 }
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int WriteTorqueEnable(bool bState)
Write to the servo state memory to set the new torque enable value.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
virtual int Stop()
Stop servo.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::ReloadMaxTorqueLimit ( )
virtual

Reload the maximum torque limit from the configuration.

If this servo is the master in a linked pair of servos, both servos' state data are reloaded.

Control Table:
EEPROM On Power-Up Maximum Torque Limit.
RAM Maximum Torque Limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1214 of file DynaServoGeneric.cxx.

References DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::m_cfg, DynaServo::m_comm, DynaServoCfg_T::m_uLimTorqueMax, and WriteMaxTorqueLimit().

Referenced by CvtRawVoltToVolts().

1215 {
1217  DYNA_TRY_IS_MASTER(this);
1218 
1220 }
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
uint_t m_uLimTorqueMax
on power-up maximum torque limit
Definition: DynaTypes.h:132
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
virtual int WriteMaxTorqueLimit(uint_t uMaxTorqueLim)
Write to the servo state memory to set the new maximum torque limit.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::Reset ( )
virtual

Reset this servo back to default values.

Warning
All configuration is lost.

Implements DynaServo.

Definition at line 1499 of file DynaServoGeneric.cxx.

References CheckData(), DYNA_OK, DYNA_TRY_COMM, DynaServo::m_comm, DynaServo::m_nServoId, DynaComm::Reset(), and SyncData().

Referenced by CvtRawVoltToVolts().

1500 {
1501  int rc;
1502 
1504 
1505  if( (rc = m_comm.Reset(m_nServoId)) == DYNA_OK )
1506  {
1507  SyncData();
1508  CheckData();
1509  }
1510 }
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int Reset(int nServoId)=0
Reset a servo back to default values.
virtual void CheckData()
Check data for consitencies.
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual int SyncData()
Synchronize the shadowed configuration and state data to the servo control table. ...
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
void DynaServoGeneric::SetServoMode ( )
protected

Set the servo mode given the servo capabilites and the current rotation limits.

See Dynamixel Operational Modes.

Definition at line 2149 of file DynaServoGeneric.cxx.

References DYNA_CCW_POS_CONT_MODE, DYNA_CW_POS_CONT_MODE, DYNA_MODE_CONTINUOUS, DYNA_MODE_SERVO, DynaServo::m_cfg, DynaServo::m_spec, DynaServoCfg_T::m_uLimCcw, DynaServoCfg_T::m_uLimCw, DynaServoCfg_T::m_uServoMode, and DynaServoSpec_T::m_uSupportedModes.

Referenced by CfgReadRotationLimits(), CfgWriteRotationLimits(), and CvtRawVoltToVolts().

2150 {
2154  {
2156  }
2157 
2158  else
2159  {
2161  }
2162 }
#define DYNA_MODE_SERVO
servo mode with limited rotation
Definition: Dynamixel.h:170
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
#define DYNA_CCW_POS_CONT_MODE
continuous mode (with cw limit)
Definition: Dynamixel.h:488
uint_t m_uSupportedModes
Dynamixel Operational Modes
Definition: DynaTypes.h:94
uint_t m_uLimCcw
counterclockwise angle limit
Definition: DynaTypes.h:128
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
uint_t m_uLimCw
clockwise angle limit (deg
Definition: DynaTypes.h:127
uint_t m_uServoMode
servo mode Dynamixel Operational Modes
Definition: DynaTypes.h:136
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_CW_POS_CONT_MODE
continuous mode (with ccw limit)
Definition: Dynamixel.h:469
int DynaServoGeneric::Stop ( )
virtual

Stop servo.

Current torque levels are kept.

If this servo is the master in a linked pair of servos, both servos will be stopped.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 285 of file DynaServoGeneric.cxx.

References AgentWriteGoalSpeed(), DYNA_MODE_CONTINUOUS, DYNA_MODE_SERVO, DYNA_OK, DYNA_SPEED_CONT_STOP, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::GetServoMode(), DynaServo::HasAgent(), DynaServo::m_comm, ReadCurPos(), WriteGoalPos(), and WriteGoalSpeed().

Referenced by CvtRawVoltToVolts(), EStop(), Freeze(), and Release().

286 {
287  int nCurPos; // current position
288  int rc; // return code
289 
291  DYNA_TRY_IS_MASTER(this);
292 
293  if( HasAgent() )
294  {
296  }
297 
298  else
299  {
300  switch( GetServoMode() )
301  {
302  //
303  // In continuous mode: Set the goal speed to zero.
304  //
307  break;
308 
309  //
310  // In servo mode: Set the goal position to the current position (a 0 speed
311  // value sets the speed to the default maximum).
312  //
313  case DYNA_MODE_SERVO:
314  default:
315  if( (rc = ReadCurPos(&nCurPos)) == DYNA_OK )
316  {
317  rc = WriteGoalPos(nCurPos);
318  }
319  break;
320  }
321  }
322 
323  return rc;
324 }
virtual int WriteGoalPos(int nGoalOdPos)
Write to the servo state memory to set the new goal position.
virtual uint_t GetServoMode() const
Get the servo operational mode.
Definition: DynaServo.h:165
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_MODE_SERVO
servo mode with limited rotation
Definition: Dynamixel.h:170
virtual bool HasAgent()
Tests if servo has a registered agent.
Definition: DynaServo.h:604
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int WriteGoalSpeed(int nGoalSpeed)
Write to the servo state memory the new goal speed and direction.
virtual int ReadCurPos(int *pCurOdPos)
Read from the servo state memory the current servo position.
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
virtual int AgentWriteGoalSpeed(int nGoalSpeed)
Agent write to the servo state memory to set the new goal speed.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_SPEED_CONT_STOP
continuous mode: stop
Definition: Dynamixel.h:261
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::SyncCfg ( )
virtual

Synchronize the shadowed configuration to the servo control table EEPROM configuration.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Reimplemented in DynaServoEX106P.

Definition at line 1522 of file DynaServoGeneric.cxx.

References CfgReadAlarmShutdownMask(), CfgReadMaxTorqueLimit(), CfgReadRotationLimits(), CfgReadTemperatureLimit(), CfgReadVoltageLimits(), DYNA_ADDR_ALARM_LED, DYNA_ADDR_SRL, DYNA_ADDR_T_RET_DELAY, DYNA_OK, DYNA_TRY_COMM, DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_nServoId, DynaServoCfg_T::m_uAlarmLed, DynaServoCfg_T::m_uSrl, DynaServoCfg_T::m_uTRetDelay, and DynaComm::Read8().

Referenced by CvtRawVoltToVolts(), DynaServoEX106P::SyncCfg(), and SyncData().

1523 {
1524  uint_t uVal1;
1525  uint_t uVal2;
1526 
1528 
1530  {
1531  m_cfg.m_uTRetDelay = uVal1;
1532  }
1533 
1534  CfgReadRotationLimits(&uVal1, &uVal2);
1535  CfgReadTemperatureLimit(&uVal1);
1536  CfgReadVoltageLimits(&uVal1, &uVal2);
1537  CfgReadMaxTorqueLimit(&uVal1);
1538 
1539  if( m_comm.Read8(m_nServoId, DYNA_ADDR_SRL, &uVal1) == DYNA_OK )
1540  {
1541  m_cfg.m_uSrl = uVal1;
1542  }
1543 
1545  {
1546  m_cfg.m_uAlarmLed = uVal1;
1547  }
1548 
1549  CfgReadAlarmShutdownMask(&uVal1);
1550 
1551  return DYNA_OK;
1552 }
#define DYNA_ADDR_ALARM_LED
alarm LED (RW)
Definition: Dynamixel.h:627
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int CfgReadAlarmShutdownMask(uint_t *pAlarmMask)
Read from the servo configuration EEPROM the current servo shutdown on alarms mask.
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
virtual int Read8(int nServoId, uint_t uAddr, byte_t *pVal)=0
Read an 8-bit value from Dynamixel servo control table.
virtual int CfgReadRotationLimits(uint_t *pCwLim, uint_t *pCcwLim)
Read from the servo configuration EEPROM the current rotation limits.
uint_t m_uTRetDelay
response return delay time (raw or )
Definition: DynaTypes.h:126
virtual int CfgReadTemperatureLimit(uint_t *pTempLim)
Read from the servo configuration EEPROM the current maximum temperature limit.
bool_t m_uAlarmLed
alarm led enable
Definition: DynaTypes.h:134
int m_nServoId
servo id
Definition: DynaServo.h:836
#define DYNA_ADDR_SRL
status return level (RW)
Definition: Dynamixel.h:606
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
virtual int CfgReadMaxTorqueLimit(uint_t *pMaxTorqueLim)
Read from the servo configuration EEPROM the current on power-up maximum torque limit.
#define DYNA_ADDR_T_RET_DELAY
return delay time (RW)
Definition: Dynamixel.h:434
uint_t m_uSrl
status return level
Definition: DynaTypes.h:133
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
virtual int CfgReadVoltageLimits(uint_t *pMinVoltLim, uint_t *pMaxVoltLim)
Read from the servo configuration EEPROM the current voltage limits.
int DynaServoGeneric::SyncData ( )
virtual

Synchronize the shadowed configuration and state data to the servo control table.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1512 of file DynaServoGeneric.cxx.

References SyncCfg(), and SyncState().

Referenced by CvtRawVoltToVolts(), DynaServoAX12::DynaServoAX12(), DynaServoEX106P::DynaServoEX106P(), DynaServoGeneric(), DynaServoMX106::DynaServoMX106(), DynaServoMX12W::DynaServoMX12W(), DynaServoMX28::DynaServoMX28(), DynaServoMX64::DynaServoMX64(), DynaServoRX10::DynaServoRX10(), DynaServoRX24F::DynaServoRX24F(), DynaServoRX28::DynaServoRX28(), DynaServoRX64::DynaServoRX64(), and Reset().

1513 {
1514  int rc;
1515 
1516  rc = SyncCfg();
1517  rc = SyncState();
1518 
1519  return rc;
1520 }
virtual int SyncState()
Synchronize the shadowed state data to the servo control table RAM state.
virtual int SyncCfg()
Synchronize the shadowed configuration to the servo control table EEPROM configuration.
int DynaServoGeneric::SyncState ( )
virtual

Synchronize the shadowed state data to the servo control table RAM state.

Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Reimplemented in DynaServoEX106P.

Definition at line 1554 of file DynaServoGeneric.cxx.

References DYNA_LOG_SERVO_ALARMS, DYNA_OK, DYNA_TRY_COMM, DynaServo::m_comm, DynaServoState_T::m_ctlMethod, DynaServo::m_nServoId, DynaServo::m_state, DynaServoState_T::m_uAlarms, ReadControlMethod(), ReadCurPos(), ReadCurSpeed(), ReadGoalPos(), ReadGoalSpeed(), ReadHealth(), ReadIsMoving(), ReadLed(), ReadMaxTorqueLimit(), ReadTorqueEnable(), and DynaServo::ResetOdometer().

Referenced by CvtRawVoltToVolts(), SyncData(), and DynaServoEX106P::SyncState().

1555 {
1556  bool bState;
1557  uint_t uVal1, uVal3, uVal4, uVal5;
1558  int nVal2;
1559 
1561 
1562  ReadTorqueEnable(&bState);
1563  ReadLed(&bState);
1565  ReadGoalPos(&nVal2);
1566  ReadGoalSpeed(&nVal2);
1567  ReadMaxTorqueLimit(&uVal1);
1568  ReadCurPos(&nVal2);
1569  ReadCurSpeed(&nVal2);
1570  ReadHealth(&uVal1, &nVal2, &uVal3, &uVal4);
1571  ReadIsMoving(&bState);
1572 
1573  // reset odometer to align with encoder (odometer is also enabled)
1574  ResetOdometer(0, false);
1575 
1576  // log any servo alarms
1578 
1579  return DYNA_OK;
1580 }
virtual int ReadHealth(uint_t *pAlarms, int *pCurLoad, uint_t *pCurVolt, uint_t *pCurTemp)
Read from the servo state memory the current servo health.
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int ReadGoalSpeed(int *pGoalSpeed)
Read from the servo state memory the current goal speed and direction.
virtual int ReadGoalPos(int *pGoalPos)
Read from the servo state memory the current goal position.
virtual int ReadCurPos(int *pCurOdPos)
Read from the servo state memory the current servo position.
#define DYNA_LOG_SERVO_ALARMS(id, alarms)
Log servo alarms.
uint_t m_uAlarms
current servo alarms and errors
Definition: DynaTypes.h:196
virtual int ReadIsMoving(bool *pState)
Read from the servo state memory to test if the servo is currently moving.
virtual int ReadMaxTorqueLimit(uint_t *pMaxTorqueLim)
Read from the servo state memory the current maximum torque limit.
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual int ReadTorqueEnable(bool *pState)
Read from the servo state memory the current torque enable value.
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
virtual int ReadLed(bool *pState)
Read from the servo state memory the current LED on/off value.
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
virtual int ResetOdometer(int nEncZeroPt, bool bIsReverse)
Reset the servo&#39;s virtual odometer.
Definition: DynaServo.cxx:188
DynaServoCtlMethod_T m_ctlMethod
position control method
Definition: DynaTypes.h:199
virtual int ReadCurSpeed(int *pCurSpeed)
Read from the servo state memory the current speed and direction.
virtual int ReadControlMethod(DynaServoCtlMethod_T *pCtlMethod)
Read from the servo state memory the current control method parameters.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::UnpackCurLoad ( uint_t  uVal)
protectedvirtual

Unpack current load estimate from the control table value.

Loads are in the range [-max,max] where the values < 0, 0, and > 0 specify torques loads in clockwise direction, no torque load, or torque loads in the counterclockwise direction, respectively.

Parameters
uValPacked field.
Returns
Current load.

Implements DynaServo.

Definition at line 2135 of file DynaServoGeneric.cxx.

References DYNA_CUR_LOAD_DIR_CW, DYNA_CUR_LOAD_DIR_MASK, and DYNA_CUR_LOAD_MAG_MASK.

Referenced by CalcMatesGoalSpeed(), and ReadCurLoad().

2136 {
2137  int nLoad;
2138 
2139  nLoad = (int)(uVal & DYNA_CUR_LOAD_MAG_MASK);
2140 
2142  {
2143  nLoad = -nLoad;
2144  }
2145 
2146  return nLoad;
2147 }
#define DYNA_CUR_LOAD_MAG_MASK
load magnitude field mask
Definition: Dynamixel.h:1037
#define DYNA_CUR_LOAD_DIR_MASK
load direction field mask
Definition: Dynamixel.h:1042
#define DYNA_CUR_LOAD_DIR_CW
clockwise direction
Definition: Dynamixel.h:1045
int DynaServoGeneric::UnpackCurSpeed ( uint_t  uVal)
protectedvirtual

Unpack current speed from the control table value.

Speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify the servo is rotating in the clockwise direction, the servo is stopped, or the servo is rotating in the counterclockwise direction, respectively.

Parameters
uValPacked field.
Returns
Current speed.

Implements DynaServo.

Definition at line 2121 of file DynaServoGeneric.cxx.

References DYNA_CUR_SPEED_DIR_CW, DYNA_CUR_SPEED_DIR_MASK, and DYNA_CUR_SPEED_MAG_MASK.

Referenced by CalcMatesGoalSpeed(), and ReadCurSpeed().

2122 {
2123  int nSpeed;
2124 
2125  nSpeed = (int)(uVal & DYNA_CUR_SPEED_MAG_MASK);
2126 
2128  {
2129  nSpeed = -nSpeed;
2130  }
2131 
2132  return nSpeed;
2133 }
#define DYNA_CUR_SPEED_MAG_MASK
speed magnitude field mask
Definition: Dynamixel.h:1014
#define DYNA_CUR_SPEED_DIR_CW
clockwise direction
Definition: Dynamixel.h:1020
#define DYNA_CUR_SPEED_DIR_MASK
speed direction field mask
Definition: Dynamixel.h:1017
int DynaServoGeneric::UnpackGoalSpeed ( uint_t  uVal)
protectedvirtual

Unpack goal speed from the control table value.

For servos in continuous mode, speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify the servo is rotating in the clockwise direction, the servo is stopped, or the servo is rotating in the counterclockwise direction, respectively.

For servos in servo mode, the goal direction is not applicable, and therefore, the speeds are in the range [0,max]. The special value 0 is equivalent to the maximum rpm speed without servo speed control.

Parameters
uValPacked field.
Returns
Goal speed.

Implements DynaServo.

Definition at line 2104 of file DynaServoGeneric.cxx.

References DYNA_GOAL_SPEED_DIR_CW, DYNA_GOAL_SPEED_DIR_MASK, DYNA_GOAL_SPEED_MAG_MASK, DYNA_MODE_CONTINUOUS, DynaServo::m_cfg, and DynaServoCfg_T::m_uServoMode.

Referenced by CalcMatesGoalSpeed(), and ReadGoalSpeed().

2105 {
2106  int nSpeed;
2107 
2108  nSpeed = (int)(uVal & DYNA_GOAL_SPEED_MAG_MASK);
2109 
2111  {
2113  {
2114  nSpeed = -nSpeed;
2115  }
2116  }
2117 
2118  return nSpeed;
2119 }
#define DYNA_GOAL_SPEED_DIR_MASK
speed direction field mask
Definition: Dynamixel.h:948
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
#define DYNA_GOAL_SPEED_MAG_MASK
speed magnitude field mask
Definition: Dynamixel.h:945
#define DYNA_GOAL_SPEED_DIR_CW
clockwise direction
Definition: Dynamixel.h:951
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
uint_t m_uServoMode
servo mode Dynamixel Operational Modes
Definition: DynaTypes.h:136
int DynaServoGeneric::Write ( uint_t  uAddr,
uint_t  uVal 
)
virtual

Write a raw value to the servo EEPROM/RAM control table.

Warning
The shadowed configuration and state data are not updated and will hence be out of sync.
Any linked master-slave servos may get out of sync and may result in physical damage.
Parameters
uAddrControl table address.
uValRaw value to write.

doc_return_std

Implements DynaServo.

Reimplemented in DynaServoEX106P.

Definition at line 1447 of file DynaServoGeneric.cxx.

References DYNA_ADDR_ALARM_LED, DYNA_ADDR_ALARM_SHUTDOWN, DYNA_ADDR_BAUD_RATE, DYNA_ADDR_CCW_COMP_MARGIN, DYNA_ADDR_CCW_COMP_SLOPE, DYNA_ADDR_CUR_LOAD_LSB, DYNA_ADDR_CUR_POS_LSB, DYNA_ADDR_CUR_SPEED_LSB, DYNA_ADDR_CUR_TEMP_C, DYNA_ADDR_CUR_VOLT, DYNA_ADDR_CW_COMP_MARGIN, DYNA_ADDR_CW_COMP_SLOPE, DYNA_ADDR_EEPROM_LOCK, DYNA_ADDR_FWVER, DYNA_ADDR_GOAL_POS_LSB, DYNA_ADDR_GOAL_SPEED_LSB, DYNA_ADDR_ID, DYNA_ADDR_IS_MOVING, DYNA_ADDR_LED, DYNA_ADDR_LIM_CCW_LSB, DYNA_ADDR_LIM_CW_LSB, DYNA_ADDR_LIM_TEMP_MAX, DYNA_ADDR_LIM_TORQUE_MAX_LSB, DYNA_ADDR_LIM_TORQUE_MAX_ON_LSB, DYNA_ADDR_LIM_VOLT_MAX, DYNA_ADDR_LIM_VOLT_MIN, DYNA_ADDR_MODEL_NUM_LSB, DYNA_ADDR_PUNCH_LSB, DYNA_ADDR_REG_INSTR, DYNA_ADDR_SRL, DYNA_ADDR_T_RET_DELAY, DYNA_ADDR_TORQUE_EN, DYNA_TRY_ADDR, DYNA_TRY_COMM, DynaServo::m_comm, DynaServo::m_nServoId, DynaComm::Write16(), and DynaComm::Write8().

Referenced by CvtRawVoltToVolts(), and DynaServoEX106P::Write().

1448 {
1450  DYNA_TRY_ADDR(uAddr);
1451 
1452  switch( uAddr )
1453  {
1455  case DYNA_ADDR_LIM_CW_LSB:
1456  case DYNA_ADDR_LIM_CCW_LSB:
1461  case DYNA_ADDR_CUR_POS_LSB:
1464  return m_comm.Write16(m_nServoId, uAddr, uVal);
1465 
1466  case DYNA_ADDR_FWVER:
1467  case DYNA_ADDR_ID:
1468  case DYNA_ADDR_BAUD_RATE:
1469  case DYNA_ADDR_T_RET_DELAY:
1473  case DYNA_ADDR_SRL:
1474  case DYNA_ADDR_ALARM_LED:
1476  case DYNA_ADDR_TORQUE_EN:
1477  case DYNA_ADDR_LED:
1482  case DYNA_ADDR_CUR_VOLT:
1483  case DYNA_ADDR_CUR_TEMP_C:
1484  case DYNA_ADDR_REG_INSTR:
1485  case DYNA_ADDR_IS_MOVING:
1486  case DYNA_ADDR_EEPROM_LOCK:
1487  case DYNA_ADDR_PUNCH_LSB:
1488  default:
1489  return m_comm.Write8(m_nServoId, uAddr, uVal);
1490  }
1491 }
#define DYNA_ADDR_ALARM_LED
alarm LED (RW)
Definition: Dynamixel.h:627
#define DYNA_ADDR_CUR_POS_LSB
current position lsb (R)
Definition: Dynamixel.h:985
#define DYNA_ADDR_ALARM_SHUTDOWN
alarm shutdown (RW)
Definition: Dynamixel.h:642
#define DYNA_ADDR_CW_COMP_SLOPE
clockwise compliance slope
Definition: Dynamixel.h:781
#define DYNA_ADDR_GOAL_SPEED_LSB
goal speed lsb (RW)
Definition: Dynamixel.h:940
#define DYNA_ADDR_MODEL_NUM_LSB
model number lsb (R)
Definition: Dynamixel.h:353
#define DYNA_ADDR_LIM_CW_LSB
clockwise angle limit lsb (RW)
Definition: Dynamixel.h:464
#define DYNA_ADDR_EEPROM_LOCK
lock the EEPROM (RW)
Definition: Dynamixel.h:1128
#define DYNA_ADDR_CW_COMP_MARGIN
clockwise compliance margin (RW)
Definition: Dynamixel.h:733
#define DYNA_TRY_ADDR(addr)
Test if servo address is valid.
#define DYNA_ADDR_LIM_VOLT_MIN
lowest voltage limit (RW)
Definition: Dynamixel.h:524
#define DYNA_ADDR_CUR_SPEED_LSB
current speed lsb (R)
Definition: Dynamixel.h:1009
#define DYNA_ADDR_CUR_TEMP_C
current temperature C (R)
Definition: Dynamixel.h:1076
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
virtual int Write16(int nServoId, uint_t uAddr, ushort_t uhVal)=0
Write a 16-bit value to Dynamixel servo control table.
#define DYNA_ADDR_LIM_TORQUE_MAX_LSB
current torque limit lsb (RW)
Definition: Dynamixel.h:965
#define DYNA_ADDR_IS_MOVING
is [not] moving (to goal position)
Definition: Dynamixel.h:1110
#define DYNA_ADDR_LIM_TORQUE_MAX_ON_LSB
maximum torque lsb (RW)
Definition: Dynamixel.h:589
#define DYNA_ADDR_CUR_VOLT
current voltage (R)
Definition: Dynamixel.h:1061
#define DYNA_ADDR_LED
LED on/off (RW)
Definition: Dynamixel.h:689
#define DYNA_ADDR_BAUD_RATE
baud rate enumeration (RW)
Definition: Dynamixel.h:396
int m_nServoId
servo id
Definition: DynaServo.h:836
#define DYNA_ADDR_ID
dynamixel id (RW)
Definition: Dynamixel.h:380
#define DYNA_ADDR_LIM_CCW_LSB
counterclockwise angle limit lsb (RW)
Definition: Dynamixel.h:483
#define DYNA_ADDR_SRL
status return level (RW)
Definition: Dynamixel.h:606
#define DYNA_ADDR_PUNCH_LSB
punch lsb (not used)
Definition: Dynamixel.h:1147
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
#define DYNA_ADDR_T_RET_DELAY
return delay time (RW)
Definition: Dynamixel.h:434
#define DYNA_ADDR_LIM_TEMP_MAX
maximum temperature limit (RW)
Definition: Dynamixel.h:503
#define DYNA_ADDR_CUR_LOAD_LSB
current load lsb (R)
Definition: Dynamixel.h:1032
#define DYNA_ADDR_GOAL_POS_LSB
goal position lsb (RW)
Definition: Dynamixel.h:909
#define DYNA_ADDR_TORQUE_EN
torque enable (RW)
Definition: Dynamixel.h:672
#define DYNA_ADDR_REG_INSTR
registered instruction (RW)
Definition: Dynamixel.h:1092
#define DYNA_ADDR_LIM_VOLT_MAX
highest voltage limit (RW)
Definition: Dynamixel.h:555
#define DYNA_ADDR_FWVER
firmware version (R)
Definition: Dynamixel.h:367
#define DYNA_ADDR_CCW_COMP_MARGIN
counterclockwise compliance margin
Definition: Dynamixel.h:766
#define DYNA_ADDR_CCW_COMP_SLOPE
counterclockwise compliance slope
Definition: Dynamixel.h:810
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::WriteControlMethod ( DynaServoCtlMethod_T ctlMethod)
virtual

Write to the servo state memory the new control method parameters.

The control method used is determined by the servo's specification.

If this servo is the master in a linked pair of servos, both servos' state data are written.

Control Table:
Dynamixel Internal Position Control Methods.
RAM Clockwise Compliance Margin.
RAM Counterclockwise Compliance Margin.
RAM Clockwise Compliance Slope.
RAM Counterclockwise Compliance Slope.
RAM PID P Gain.
RAM PID I Gain.
RAM PID D Gain.
Parameters
ctlMethodControl method parameters.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 960 of file DynaServoGeneric.cxx.

References DYNA_CTL_METHOD_COMPLIANCE, DYNA_CTL_METHOD_PID, DYNA_ECODE_INTERNAL, DYNA_LOG_ERROR, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::m_comm, DynaServo::m_nServoId, DynaServo::m_spec, DynaServoSpec_T::m_uCtlMethodUsed, WriteCtlMethodCompliance(), and WriteCtlMethodPid().

Referenced by CvtRawVoltToVolts().

961 {
962  int rc; // return code
963 
965  DYNA_TRY_IS_MASTER(this);
966 
967  switch( m_spec.m_uCtlMethodUsed )
968  {
970  return WriteCtlMethodCompliance(ctlMethod);
971  case DYNA_CTL_METHOD_PID:
972  return WriteCtlMethodPid(ctlMethod);
973  default:
974  rc = -DYNA_ECODE_INTERNAL;
975  DYNA_LOG_ERROR(rc, "Servo %d: Unknown control method %u.",
977  return rc;
978  }
979 }
#define DYNA_CTL_METHOD_COMPLIANCE
compliance control method
Definition: Dynamixel.h:216
virtual int WriteCtlMethodCompliance(DynaServoCtlMethod_T &ctlMethod)
Write to the servo state memory the new compliance control method parameters.
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
uint_t m_uCtlMethodUsed
Dynamixel Internal Position Control Methods
Definition: DynaTypes.h:100
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_CTL_METHOD_PID
pid control method
Definition: Dynamixel.h:217
int m_nServoId
servo id
Definition: DynaServo.h:836
#define DYNA_ECODE_INTERNAL
internal error (bug)
Definition: Dynamixel.h:82
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
virtual int WriteCtlMethodPid(DynaServoCtlMethod_T &ctlMethod)
Write to the servo state memory the new PID control method parameters.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::WriteCtlMethodCompliance ( DynaServoCtlMethod_T ctlMethod)
protectedvirtual

Write to the servo state memory the new compliance control method parameters.

If this servo is the master in a linked pair of servos, both servos' state data are written.

Control Table:
Dynamixel Internal Position Control Methods.
RAM Clockwise Compliance Margin.
RAM Counterclockwise Compliance Margin.
RAM Clockwise Compliance Slope.
RAM Counterclockwise Compliance Slope.
Parameters
ctlMethodControl method parameters.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 1814 of file DynaServoGeneric.cxx.

References ChkComplianceSlope(), DYNA_ADDR_CCW_COMP_MARGIN, DYNA_ADDR_CCW_COMP_SLOPE, DYNA_ADDR_CW_COMP_MARGIN, DYNA_ADDR_CW_COMP_SLOPE, DYNA_COMP_MARGIN_MAX_RAW, DYNA_COMP_MARGIN_MIN_RAW, DYNA_ECODE_BAD_VAL, DYNA_ECODE_NOT_SUPP, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServoCtlMethod_T::m_comp, DynaServoState_T::m_ctlMethod, DynaServo::m_link, DynaServo::m_nServoId, DynaServoCtlMethod_T::m_params, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServo::m_state, DynaServoCtlMethod_T::m_uCtlMethod, DynaServoSpec_T::m_uCtlMethodUsed, DynaComm::vSyncWrite(), and DynaComm::Write8().

Referenced by CalcMatesGoalSpeed(), and WriteControlMethod().

1815 {
1816  uint_t uCwMargin; // new cw margin
1817  uint_t uCcwMargin; // new ccw margin
1818  uint_t uCwSlope; // new cw slope
1819  uint_t uCcwSlope; // new ccw slope
1820  DynaServo *pServoMate; // servo mate
1821  int rc; // return code
1822 
1824  DYNA_TRY_IS_MASTER(this);
1825 
1826  uCwMargin = ctlMethod.m_params.m_comp.m_uCwMargin;
1827  uCcwMargin = ctlMethod.m_params.m_comp.m_uCcwMargin;
1828  uCwSlope = ctlMethod.m_params.m_comp.m_uCwSlope;
1829  uCcwSlope = ctlMethod.m_params.m_comp.m_uCcwSlope;
1830 
1833  "Control method %u.", ctlMethod.m_uCtlMethod);
1834 
1835  DYNA_TRY_EXPR(((uCwMargin >= DYNA_COMP_MARGIN_MIN_RAW) &&
1836  (uCwMargin <= DYNA_COMP_MARGIN_MAX_RAW)),
1838  "CW compliance margin %u: Out of range.",
1839  uCwMargin);
1840 
1841  DYNA_TRY_EXPR(((uCcwMargin >= DYNA_COMP_MARGIN_MIN_RAW) &&
1842  (uCcwMargin <= DYNA_COMP_MARGIN_MAX_RAW)),
1844  "CCW compliance margin %u: Out of range.",
1845  uCcwMargin);
1846 
1849  "CW compliance slope 0x%02x: Unknown value.",
1850  uCwSlope);
1851 
1852  DYNA_TRY_EXPR(ChkComplianceSlope(uCcwSlope),
1854  "CCW compliance slope 0x%02x: Unknown value.",
1855  uCcwSlope);
1856 
1857  //
1858  // Linked pair
1859  //
1860  if( IsLinkedMaster() )
1861  {
1862  pServoMate = m_link.m_pServoMate;
1863 
1865  m_nServoId, uCwMargin,
1866  m_link.m_pServoMate->GetServoId(), uCwMargin);
1867 
1868  if( rc == DYNA_OK )
1869  {
1870  m_state.m_ctlMethod.m_params.m_comp.m_uCwMargin = uCwMargin;
1871  pServoMate->m_state.m_ctlMethod.m_params.m_comp.m_uCwMargin = uCwMargin;
1872 
1874  m_nServoId, uCcwMargin,
1875  m_link.m_pServoMate->GetServoId(), uCcwMargin);
1876  }
1877 
1878  if( rc == DYNA_OK )
1879  {
1880  m_state.m_ctlMethod.m_params.m_comp.m_uCcwMargin = uCcwMargin;
1881  pServoMate->m_state.m_ctlMethod.m_params.m_comp.m_uCcwMargin = uCcwMargin;
1882 
1884  m_nServoId, uCwSlope,
1885  m_link.m_pServoMate->GetServoId(), uCwSlope);
1886  }
1887 
1888  if( rc == DYNA_OK )
1889  {
1890  m_state.m_ctlMethod.m_params.m_comp.m_uCwSlope = uCwSlope;
1891  pServoMate->m_state.m_ctlMethod.m_params.m_comp.m_uCwSlope = uCwSlope;
1892 
1894  m_nServoId, uCcwSlope,
1895  m_link.m_pServoMate->GetServoId(), uCcwSlope);
1896  }
1897 
1898  if( rc == DYNA_OK )
1899  {
1900  m_state.m_ctlMethod.m_params.m_comp.m_uCcwSlope = uCcwSlope;
1901  pServoMate->m_state.m_ctlMethod.m_params.m_comp.m_uCcwSlope = uCcwSlope;
1902  }
1903  }
1904 
1905  //
1906  // Solitary servo
1907  //
1908  else
1909  {
1911 
1912  if( rc == DYNA_OK )
1913  {
1914  m_state.m_ctlMethod.m_params.m_comp.m_uCwMargin = uCwMargin;
1916  }
1917 
1918  if( rc == DYNA_OK )
1919  {
1920  m_state.m_ctlMethod.m_params.m_comp.m_uCcwMargin = uCcwMargin;
1922  }
1923 
1924  if( rc == DYNA_OK )
1925  {
1926  m_state.m_ctlMethod.m_params.m_comp.m_uCwSlope = uCwSlope;
1928  }
1929 
1930  if( rc == DYNA_OK )
1931  {
1932  m_state.m_ctlMethod.m_params.m_comp.m_uCcwSlope = uCcwSlope;
1933  }
1934  }
1935 
1936  return rc;
1937 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_CW_COMP_SLOPE
clockwise compliance slope
Definition: Dynamixel.h:781
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_ADDR_CW_COMP_MARGIN
clockwise compliance margin (RW)
Definition: Dynamixel.h:733
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
uint_t m_uCtlMethod
Dynamixel Internal Position Control Methods
Definition: DynaTypes.h:148
virtual bool ChkComplianceSlope(uint_t uVal)
Check validity of compliance slope discrete values.
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_ECODE_NOT_SUPP
feature/function not supported
Definition: Dynamixel.h:97
uint_t m_uCtlMethodUsed
Dynamixel Internal Position Control Methods
Definition: DynaTypes.h:100
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
#define DYNA_COMP_MARGIN_MAX_RAW
max position difference (loosest)
Definition: Dynamixel.h:738
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
union DynaServoCtlMethod_T::@2 m_params
parameters to control methods
struct DynaServoCtlMethod_T::@2::@3 m_comp
compliance control method parameters
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
DynaServoCtlMethod_T m_ctlMethod
position control method
Definition: DynaTypes.h:199
#define DYNA_ADDR_CCW_COMP_MARGIN
counterclockwise compliance margin
Definition: Dynamixel.h:766
#define DYNA_COMP_MARGIN_MIN_RAW
min position difference (tightest)
Definition: Dynamixel.h:737
#define DYNA_ADDR_CCW_COMP_SLOPE
counterclockwise compliance slope
Definition: Dynamixel.h:810
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::WriteCtlMethodPid ( DynaServoCtlMethod_T ctlMethod)
protectedvirtual

Write to the servo state memory the new PID control method parameters.

If this servo is the master in a linked pair of servos, both servos' state data are written.

Control Table:
Dynamixel Internal Position Control Methods.
RAM PID P Gain.
RAM PID I Gain.
RAM PID D Gain.
Parameters
ctlMethodControl method parameters.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Definition at line 1974 of file DynaServoGeneric.cxx.

References DYNA_ADDR_D_GAIN, DYNA_ADDR_I_GAIN, DYNA_ADDR_P_GAIN, DYNA_D_GAIN_MAX_RAW, DYNA_D_GAIN_MIN_RAW, DYNA_ECODE_BAD_VAL, DYNA_ECODE_NOT_SUPP, DYNA_I_GAIN_MAX_RAW, DYNA_I_GAIN_MIN_RAW, DYNA_OK, DYNA_P_GAIN_MAX_RAW, DYNA_P_GAIN_MIN_RAW, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServoState_T::m_ctlMethod, DynaServo::m_link, DynaServo::m_nServoId, DynaServoCtlMethod_T::m_params, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServo::m_state, DynaServoCtlMethod_T::m_uCtlMethod, DynaServoSpec_T::m_uCtlMethodUsed, DynaComm::vSyncWrite(), and DynaComm::Write8().

Referenced by CalcMatesGoalSpeed(), and WriteControlMethod().

1975 {
1976  uint_t uPGain; // new p gain
1977  uint_t uIGain; // new i gain
1978  uint_t uDGain; // new d gain
1979  DynaServo *pServoMate; // servo mate
1980  int rc; // return code
1981 
1983  DYNA_TRY_IS_MASTER(this);
1984 
1985  uPGain = ctlMethod.m_params.m_pid.m_uPGain;
1986  uIGain = ctlMethod.m_params.m_pid.m_uIGain;
1987  uDGain = ctlMethod.m_params.m_pid.m_uDGain;
1988 
1991  "Control method %u.", ctlMethod.m_uCtlMethod);
1992 
1993  DYNA_TRY_EXPR(((uPGain >= DYNA_P_GAIN_MIN_RAW) &&
1994  (uPGain <= DYNA_P_GAIN_MAX_RAW)),
1996  "P-Gain %u: Out of range.", uPGain);
1997 
1998  DYNA_TRY_EXPR(((uIGain >= DYNA_I_GAIN_MIN_RAW) &&
1999  (uIGain <= DYNA_I_GAIN_MAX_RAW)),
2001  "I-Gain %u: Out of range.", uIGain);
2002 
2003  DYNA_TRY_EXPR(((uDGain >= DYNA_D_GAIN_MIN_RAW) &&
2004  (uDGain <= DYNA_D_GAIN_MAX_RAW)),
2006  "D-Gain %u: Out of range.", uDGain);
2007 
2008  //
2009  // Linked pair
2010  //
2011  if( IsLinkedMaster() )
2012  {
2013  pServoMate = m_link.m_pServoMate;
2014 
2015  rc = m_comm.vSyncWrite(DYNA_ADDR_P_GAIN, 1, 2,
2016  m_nServoId, uPGain,
2017  m_link.m_pServoMate->GetServoId(), uPGain);
2018 
2019  if( rc == DYNA_OK )
2020  {
2021  m_state.m_ctlMethod.m_params.m_pid.m_uPGain = uPGain;
2022  pServoMate->m_state.m_ctlMethod.m_params.m_pid.m_uPGain = uPGain;
2023 
2024  rc = m_comm.vSyncWrite(DYNA_ADDR_I_GAIN, 1, 2,
2025  m_nServoId, uIGain,
2026  m_link.m_pServoMate->GetServoId(), uIGain);
2027  }
2028 
2029  if( rc == DYNA_OK )
2030  {
2031  m_state.m_ctlMethod.m_params.m_pid.m_uIGain = uIGain;
2032  pServoMate->m_state.m_ctlMethod.m_params.m_pid.m_uIGain = uIGain;
2033 
2034  rc = m_comm.vSyncWrite(DYNA_ADDR_D_GAIN, 1, 2,
2035  m_nServoId, uDGain,
2036  m_link.m_pServoMate->GetServoId(), uDGain);
2037  }
2038 
2039  if( rc == DYNA_OK )
2040  {
2041  m_state.m_ctlMethod.m_params.m_pid.m_uDGain = uDGain;
2042  pServoMate->m_state.m_ctlMethod.m_params.m_pid.m_uDGain = uDGain;
2043  }
2044  }
2045 
2046  //
2047  // Solitary servo
2048  //
2049  else
2050  {
2051  rc = m_comm.Write8(m_nServoId, DYNA_ADDR_P_GAIN, uPGain);
2052 
2053  if( rc == DYNA_OK )
2054  {
2055  m_state.m_ctlMethod.m_params.m_pid.m_uPGain = uPGain;
2056  rc = m_comm.Write8(m_nServoId, DYNA_ADDR_I_GAIN, uIGain);
2057  }
2058 
2059  if( rc == DYNA_OK )
2060  {
2061  m_state.m_ctlMethod.m_params.m_pid.m_uIGain = uIGain;
2062  rc = m_comm.Write8(m_nServoId, DYNA_ADDR_D_GAIN, uDGain);
2063  }
2064 
2065  if( rc == DYNA_OK )
2066  {
2067  m_state.m_ctlMethod.m_params.m_pid.m_uDGain = uDGain;
2068  }
2069  }
2070 
2071  return rc;
2072 }
#define DYNA_P_GAIN_MAX_RAW
maximum value
Definition: Dynamixel.h:840
#define DYNA_P_GAIN_MIN_RAW
minimum value
Definition: Dynamixel.h:839
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
uint_t m_uCtlMethod
Dynamixel Internal Position Control Methods
Definition: DynaTypes.h:148
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
#define DYNA_ECODE_NOT_SUPP
feature/function not supported
Definition: Dynamixel.h:97
uint_t m_uCtlMethodUsed
Dynamixel Internal Position Control Methods
Definition: DynaTypes.h:100
#define DYNA_D_GAIN_MAX_RAW
maximum value
Definition: Dynamixel.h:884
#define DYNA_D_GAIN_MIN_RAW
minimum value
Definition: Dynamixel.h:883
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
#define DYNA_ADDR_I_GAIN
Igain (RW)
Definition: Dynamixel.h:857
#define DYNA_I_GAIN_MAX_RAW
maximum value
Definition: Dynamixel.h:862
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
#define DYNA_I_GAIN_MIN_RAW
minimum value
Definition: Dynamixel.h:861
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
union DynaServoCtlMethod_T::@2 m_params
parameters to control methods
#define DYNA_ADDR_D_GAIN
Dgain (RW)
Definition: Dynamixel.h:879
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
DynaServoCtlMethod_T m_ctlMethod
position control method
Definition: DynaTypes.h:199
#define DYNA_ADDR_P_GAIN
Pgain (RW)
Definition: Dynamixel.h:835
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::WriteGoalPos ( int  nGoalOdPos)
virtual

Write to the servo state memory to set the new goal position.

If the servo [pair] are in servo mode, rotation will occur until the position(s) are achieved.

If this servo is the master in a linked pair of servos, both servos' state written.

Control Table:
RAM Goal Position.
Dynamixel Position Common Values.
Parameters
nGoalOdPosOdometer goal position (odometer ticks). In continuous mode, writing the goal position has no effect on movement.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1013 of file DynaServoGeneric.cxx.

References CalcMatesGoalPos(), DYNA_ADDR_GOAL_POS_LSB, DYNA_ECODE_BAD_VAL, DYNA_MODE_SERVO, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_cfg, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServo::m_state, DynaServoState_T::m_uGoalPos, DynaServoSpec_T::m_uRawPosMax, DynaServoSpec_T::m_uRawPosMin, DynaServoCfg_T::m_uServoMode, DynaServo::OdometerToEncoder(), DynaComm::vSyncWrite(), and DynaComm::Write16().

Referenced by CvtRawVoltToVolts(), MoveAtSpeedTo(), MoveTo(), and Stop().

1014 {
1015  int nEncPos; // encoder position
1016  int rc; // return code
1017 
1019  DYNA_TRY_IS_MASTER(this);
1020 
1021  nEncPos = OdometerToEncoder(nGoalOdPos);
1022 
1024  {
1025  DYNA_TRY_EXPR(((nEncPos >= m_spec.m_uRawPosMin) &&
1026  (nEncPos <= m_spec.m_uRawPosMax)),
1028  "Servo %d: Goal odometer position %d (encoder=%d): Out of range.",
1029  m_nServoId, nGoalOdPos, nEncPos);
1030  }
1031 
1032  //
1033  // Linked pair
1034  //
1035  if( IsLinkedMaster() )
1036  {
1037  int nGoalOdPosMate; // mate's calculated goal odometer position
1038  int nEncGoalPosMate; // mate's calculated goal encoder position
1039 
1040  if( (rc = CalcMatesGoalPos(nGoalOdPos, &nGoalOdPosMate)) == DYNA_OK )
1041  {
1042  nEncGoalPosMate = m_link.m_pServoMate->OdometerToEncoder(nGoalOdPosMate);
1044  m_nServoId, (uint_t)nEncPos,
1045  m_link.m_pServoMate->GetServoId(), // RDK FIX ME
1046  (uint_t)nEncGoalPosMate);
1047 
1048  if( rc == DYNA_OK )
1049  {
1050  m_state.m_uGoalPos = (uint_t)nEncPos;
1051  m_link.m_pServoMate->m_state.m_uGoalPos = (uint_t)nEncGoalPosMate;
1052  }
1053  }
1054  }
1055 
1056  //
1057  // Solitary servo
1058  //
1059  else
1060  {
1061  rc = m_comm.Write16(m_nServoId, DYNA_ADDR_GOAL_POS_LSB, (uint_t)nEncPos);
1062 
1063  if( rc == DYNA_OK )
1064  {
1065  m_state.m_uGoalPos = (uint_t)nEncPos;
1066  }
1067  }
1068 
1069  return rc;
1070 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_MODE_SERVO
servo mode with limited rotation
Definition: Dynamixel.h:170
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
uint_t m_uRawPosMin
minimum raw position value (servo mode)
Definition: DynaTypes.h:101
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
DynaServoCfg_T m_cfg
servo shadowed EEPROM configuration
Definition: DynaServo.h:838
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int CalcMatesGoalPos(int nGoalOdPos, int *pGoalOdPosMate)
Calculate the linked mate&#39;s goal position given this servo&#39;s goal position.
virtual int Write16(int nServoId, uint_t uAddr, ushort_t uhVal)=0
Write a 16-bit value to Dynamixel servo control table.
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
int OdometerToEncoder(int nOdPos)
Convert virtual odometer units to servo encoder units.
Definition: DynaServo.h:367
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
uint_t m_uRawPosMax
maximum raw position value (servo mode)
Definition: DynaTypes.h:102
uint_t m_uServoMode
servo mode Dynamixel Operational Modes
Definition: DynaTypes.h:136
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
uint_t m_uGoalPos
goal position (encoder ticks)
Definition: DynaTypes.h:200
#define DYNA_ADDR_GOAL_POS_LSB
goal position lsb (RW)
Definition: Dynamixel.h:909
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::WriteGoalSpeed ( int  nGoalSpeed)
virtual

Write to the servo state memory the new goal speed and direction.

For servos in continuous mode, speeds are in the range [-max,max] where the values < 0, 0, and > 0 specify goal rotation in the clockwise direction, stop, or goal rotation in the counterclockwise direction, respectively.

For servos in servo mode, the goal direction is not applicable, and therefore, the speeds are in the range [0,max]. The special value 0 is equivalent to the maximum rpm speed without servo speed control.

If the servo is in continuous mode, rotation will occur indefinitely in the direction specified and at the given speed.

Control Table:
RAM Goal Speed and Direction.
Dynamixel Angular Speed Common Values.
Dynamixel Direction Common Values.
Parameters
nGoalSpeedGoal speed.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1096 of file DynaServoGeneric.cxx.

References CalcMatesGoalSpeed(), DYNA_ADDR_GOAL_SPEED_LSB, DYNA_ECODE_BAD_VAL, DYNA_OK, DYNA_SPEED_MAX_RAW, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), iabs(), DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServo::m_link, DynaServoState_T::m_nGoalSpeed, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, PackGoalSpeed(), DynaComm::vSyncWrite(), and DynaComm::Write16().

Referenced by CvtRawVoltToVolts(), MoveAtSpeed(), MoveAtSpeedTo(), and Stop().

1097 {
1098  int nGoalSpeedMate; // mate's calculated speed
1099  uint_t uVal1, uVal2; // working values
1100  int rc; // return code
1101 
1103  DYNA_TRY_IS_MASTER(this);
1104 
1105  DYNA_TRY_EXPR( (iabs(nGoalSpeed) <= DYNA_SPEED_MAX_RAW),
1107  "Goal speed %d: Out of range.", nGoalSpeed);
1108 
1109  uVal1 = PackGoalSpeed(nGoalSpeed);
1110 
1111  //
1112  // Linked pair
1113  //
1114  if( IsLinkedMaster() )
1115  {
1116  nGoalSpeedMate = CalcMatesGoalSpeed(nGoalSpeed);
1117 
1118  uVal2 = PackGoalSpeed(nGoalSpeedMate);
1119 
1121  m_nServoId, uVal1,
1122  m_link.m_pServoMate->GetServoId(), uVal2);
1123 
1124  if( rc == DYNA_OK )
1125  {
1126  m_state.m_nGoalSpeed = nGoalSpeed;
1127  m_link.m_pServoMate->m_state.m_nGoalSpeed = nGoalSpeedMate;
1128  }
1129  }
1130 
1131  //
1132  // Solitary servo
1133  //
1134  else
1135  {
1137 
1138  if( rc == DYNA_OK )
1139  {
1140  m_state.m_nGoalSpeed = nGoalSpeed;
1141  }
1142  }
1143 
1144  return rc;
1145 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_ADDR_GOAL_SPEED_LSB
goal speed lsb (RW)
Definition: Dynamixel.h:940
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
INLINE_IN_H int iabs(int a)
Return absolute value of a.
Definition: DynaOlio.h:91
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int Write16(int nServoId, uint_t uAddr, ushort_t uhVal)=0
Write a 16-bit value to Dynamixel servo control table.
int m_nGoalSpeed
goal speed (raw)
Definition: DynaTypes.h:201
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t PackGoalSpeed(int nGoalSpeed)
Pack the goal speed into the control table value.
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_SPEED_MAX_RAW
maximum raw value
Definition: Dynamixel.h:266
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
virtual int CalcMatesGoalSpeed(int nGoalSpeed)
Calculate the linked mate&#39;s speed speed given this servo&#39;s goal speed.
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::WriteLed ( bool  bState)
virtual

Write to the servo state memory to turn on or off the servo LED.

If this servo is the master in a linked pair of servos, both servos' state written.

Control Table:
RAM LED On/Off.
Parameters
bStateOn (true) or off (false) state.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 898 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LED, DYNA_LED_OFF, DYNA_LED_ON, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServoState_T::m_bLed, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaComm::vSyncWrite(), and DynaComm::Write8().

Referenced by CvtRawVoltToVolts().

899 {
900  uint_t uVal; // working value
901  int rc; // return code
902 
904  DYNA_TRY_IS_MASTER(this);
905 
906  uVal = bState? DYNA_LED_ON: DYNA_LED_OFF;
907 
908  //
909  // Linked pair
910  //
911  if( IsLinkedMaster() )
912  {
913  rc = m_comm.vSyncWrite(DYNA_ADDR_LED, 1, 2,
914  m_nServoId, uVal,
915  m_link.m_pServoMate->GetServoId(), uVal);
916 
917  if( rc == DYNA_OK )
918  {
919  m_state.m_bLed = bState;
920  m_link.m_pServoMate->m_state.m_bLed = bState;
921  }
922  }
923 
924  //
925  // Solitary servo
926  //
927  else
928  {
929  rc = m_comm.Write8(m_nServoId, DYNA_ADDR_LED, uVal);
930 
931  if( rc == DYNA_OK )
932  {
933  m_state.m_bLed = bState;
934  }
935  }
936 
937  return rc;
938 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_LED_OFF
LED off.
Definition: Dynamixel.h:693
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
bool_t m_bLed
led on/off
Definition: DynaTypes.h:198
#define DYNA_ADDR_LED
LED on/off (RW)
Definition: Dynamixel.h:689
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
#define DYNA_LED_ON
LED on.
Definition: Dynamixel.h:694
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::WriteMaxTorqueLimit ( uint_t  uMaxTorqueLim)
virtual

Write to the servo state memory to set the new maximum torque limit.

If this servo is the master in a linked pair of servos, both servos' state written.

Control Table:
RAM Maximum Torque Limit.
Dynamixel Torque Common Values.
Parameters
uMaxTorqueLimMaximum torque limit.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 1169 of file DynaServoGeneric.cxx.

References DYNA_ADDR_LIM_TORQUE_MAX_LSB, DYNA_ECODE_BAD_VAL, DYNA_OK, DYNA_TRY_COMM, DYNA_TRY_EXPR, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_spec, DynaServo::m_state, DynaServoState_T::m_uLimTorqueMax, DynaServoSpec_T::m_uRawTorqueMax, DynaServoSpec_T::m_uRawTorqueMin, DynaComm::vSyncWrite(), and DynaComm::Write16().

Referenced by CvtRawVoltToVolts(), and ReloadMaxTorqueLimit().

1170 {
1171  int rc; // return code
1172 
1174  DYNA_TRY_IS_MASTER(this);
1175 
1176  DYNA_TRY_EXPR(((uMaxTorqueLim >= m_spec.m_uRawTorqueMin) &&
1177  (uMaxTorqueLim <= m_spec.m_uRawTorqueMax)),
1179  "Maximum torque limit %u: Out of range.", uMaxTorqueLim);
1180 
1181  //
1182  // Linked pair
1183  //
1184  if( IsLinkedMaster() )
1185  {
1187  m_nServoId, uMaxTorqueLim,
1188  m_link.m_pServoMate->GetServoId(), uMaxTorqueLim);
1189 
1190  if( rc == DYNA_OK )
1191  {
1192  m_state.m_uLimTorqueMax = uMaxTorqueLim;
1193  m_link.m_pServoMate->m_state.m_uLimTorqueMax = uMaxTorqueLim;
1194  }
1195  }
1196 
1197  //
1198  // Solitary servo
1199  //
1200  else
1201  {
1203  uMaxTorqueLim);
1204 
1205  if( rc == DYNA_OK )
1206  {
1207  m_state.m_uLimTorqueMax = uMaxTorqueLim;
1208  }
1209  }
1210 
1211  return rc;
1212 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_TRY_EXPR(expr, ecode, efmt,...)
Test if the servo is in the required mode(s) exception macro.
uint_t m_uLimTorqueMax
maximum torque limit
Definition: DynaTypes.h:202
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int Write16(int nServoId, uint_t uAddr, ushort_t uhVal)=0
Write a 16-bit value to Dynamixel servo control table.
uint_t m_uRawTorqueMin
minimum raw torque value
Definition: DynaTypes.h:106
#define DYNA_ADDR_LIM_TORQUE_MAX_LSB
current torque limit lsb (RW)
Definition: Dynamixel.h:965
uint_t m_uRawTorqueMax
maximum raw torque value
Definition: DynaTypes.h:107
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
DynaServoSpec_T m_spec
servo specification
Definition: DynaServo.h:837
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.
int DynaServoGeneric::WriteTorqueEnable ( bool  bState)
virtual

Write to the servo state memory to set the new torque enable value.

If the torque state is false (off), no power is applied to the servo, allowing it to be free rotated by any external force.

If this servo is the master in a linked pair of servos, both servos' state written.

Control Table:
RAM Torque Enable.
Parameters
bStateTorque enabled (true) or disabled (off) state.
Returns
On success, DYNA_OK is returned.
On error, the appropriate < 0 negated Dynamixel Error Code is returned.

Implements DynaServo.

Definition at line 831 of file DynaServoGeneric.cxx.

References DYNA_ADDR_TORQUE_EN, DYNA_OK, DYNA_TORQUE_EN_OFF, DYNA_TORQUE_EN_ON, DYNA_TRY_COMM, DYNA_TRY_IS_MASTER, DynaServo::GetServoId(), DynaServo::IsLinkedMaster(), DynaServoState_T::m_bTorqueEnabled, DynaServo::m_comm, DynaServo::m_link, DynaServo::m_nServoId, DynaServo::CrossLink_T::m_pServoMate, DynaServo::m_state, DynaComm::vSyncWrite(), and DynaComm::Write8().

Referenced by CvtRawVoltToVolts(), EStop(), Freeze(), and Release().

832 {
833  uint_t uVal; // working value
834  int rc; // return code
835 
837  DYNA_TRY_IS_MASTER(this);
838 
839  uVal = bState? DYNA_TORQUE_EN_ON: DYNA_TORQUE_EN_OFF;
840 
841  //
842  // Linked pair
843  //
844  if( IsLinkedMaster() )
845  {
847  m_nServoId, uVal,
848  m_link.m_pServoMate->GetServoId(),uVal);
849 
850  if( rc == DYNA_OK )
851  {
852  m_state.m_bTorqueEnabled = bState;
854  }
855  }
856 
857  //
858  // Solitary servo
859  //
860  else
861  {
863 
864  if( rc == DYNA_OK )
865  {
866  m_state.m_bTorqueEnabled = bState;
867  }
868  }
869 
870  return rc;
871 }
bool IsLinkedMaster() const
Test if this servo is a linked master.
Definition: DynaServo.h:236
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_TORQUE_EN_OFF
disable power drive to the motor
Definition: Dynamixel.h:676
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
Definition: DynaComm.cxx:420
#define DYNA_TRY_IS_MASTER(pservo)
Test if the servo is a master servo.
virtual int Write8(int nServoId, uint_t uAddr, byte_t byVal)=0
Write an 8-bit value to Dynamixel servo control table.
bool_t m_bTorqueEnabled
torque [not] enabled
Definition: DynaTypes.h:197
CrossLink_T m_link
servo cross linkage
Definition: DynaServo.h:840
int m_nServoId
servo id
Definition: DynaServo.h:836
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
DynaComm & m_comm
attached Dynamixel bus comm. object
Definition: DynaServo.h:835
DynaServoState_T m_state
servo shadowed RAM state
Definition: DynaServo.h:839
#define DYNA_TORQUE_EN_ON
enable power drive to the motor
Definition: Dynamixel.h:677
#define DYNA_ADDR_TORQUE_EN
torque enable (RW)
Definition: Dynamixel.h:672
#define DYNA_TRY_COMM(comm)
Test if bus communication is available exception macro.

Member Data Documentation

const int DynaServoGeneric::DYNA_MODEL_NUM = DYNA_MODEL_NUM_GENERIC
static

Model number

Definition at line 79 of file DynaServoGeneric.h.

Referenced by DynaServo::New().


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