Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaLibInternal.h File Reference

The libDynamixel internal declarations. More...

#include <errno.h>
#include "rnr/rnrconfig.h"
#include "rnr/new.h"
#include "rnr/log.h"
#include "Dynamixel/Dynamixel.h"
#include "Dynamixel/DynaError.h"

Go to the source code of this file.

Macros

#define DYNA_LOG_ERROR(ecode, efmt, ...)
 Log Error. More...
 
#define DYNA_LOG_SYS_ERROR(ecode, efmt, ...)
 Log System Error. More...
 
#define DYNA_LOG_COMM_ERROR(estat, efmt, ...)
 Log Error. More...
 
#define DYNA_LOG_BUF(sPreface, buf, uCount, sFmt)
 Log buffer of infrared readings. More...
 
#define DYNA_LOG_SERVO_ALARMS(id, alarms)
 Log servo alarms. More...
 
#define DYNA_TRY_RC(rc, fmt, ...)
 Test if Dynamixel return code is not an error. More...
 
#define DYNA_TRY_COMM(comm)
 Test if bus communication is available exception macro. More...
 
#define DYNA_TRY_SERVO_ID(id)
 Testing if the servo id is in range exception macro. More...
 
#define DYNA_TRY_IS_MASTER(pservo)
 Test if the servo is a master servo. More...
 
#define DYNA_TRY_IS_UNLINKED(pservo)
 Test if the servo is unlinked. More...
 
#define DYNA_TRY_SERVO_HAS_MODE(pservo, mode)
 Test if the servo has one of the required modes exception macro. More...
 
#define DYNA_TRY_SERVO_IN_MODE(pservo, mode)
 Test if the servo is in the given mode. More...
 
#define DYNA_TRY_SERVO_HAS_POS_CTL(pservo)
 Test if the servo has positiion control. More...
 
#define DYNA_TRY_SERVO_HAS_AGENT(pservo)
 Test if the servo has a proxy agent. More...
 
#define DYNA_TRY_ADDR(addr)
 Test if servo address is valid. More...
 
#define DYNA_TRY_SERVO_IN_CHAIN(pchain, id)
 Test if the servo id is valid and present in chain exception macro. More...
 
#define DYNA_TRY_EXPR(expr, ecode, efmt, ...)
 Test if the servo is in the required mode(s) exception macro. More...
 

Functions

char * newstr (const char *s)
 Allocate new duplicated string. More...
 
int DynaMapDxlToEcode (int nDxlError)
 Map DXL library error code to Dynamixel error code. More...
 

Detailed Description

The libDynamixel internal declarations.

LastChangedDate
2015-03-13 13:28:02 -0600 (Fri, 13 Mar 2015)
Rev
3890
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)

Definition in file DynaLibInternal.h.

Macro Definition Documentation

#define DYNA_LOG_BUF (   sPreface,
  buf,
  uCount,
  sFmt 
)
Value:
do \
{ \
if( LOGABLE(LOG_LEVEL_DIAG3) ) \
{ \
DynaLogBuf(sPreface, buf, uCount, sFmt); \
} \
} while(0)
void DynaLogBuf(const char *sPreface, byte_t buf[], size_t uCount, const char *sFmt)
Log integer data.
Definition: DynaError.cxx:206

Log buffer of infrared readings.

Parameters
sPrefacePreface string.
bufBuffer contents to log.
uCountNumber of entries to log.
sFmtBuffer entry format string.

Definition at line 112 of file DynaLibInternal.h.

#define DYNA_LOG_COMM_ERROR (   estat,
  efmt,
  ... 
)
Value:
LOGERROR("%s(ecode=%d): %s(%d): " efmt, \
dynaCommStatString(estat), estat, \
##__VA_ARGS__)
#define DYNA_ECODE_ECOMM
dynamixel communication error
Definition: Dynamixel.h:89
const char * DynaStrError(int ecode)
Get the error string describing the Dynamixel error code.
Definition: DynaError.cxx:141

Log Error.

Parameters
estatErrored communication status code.
efmtError output format string literal.
...Error variable arguments.

Definition at line 97 of file DynaLibInternal.h.

#define DYNA_LOG_SERVO_ALARMS (   id,
  alarms 
)
Value:
do \
{ \
if( LOGABLE(LOG_LEVEL_DIAG3) && ((alarms) != DYNA_ALARM_NONE) ) \
{ \
DynaLogServoAlarms(id, alarms); \
} \
} while(0)
#define DYNA_ALARM_NONE
no alarms
Definition: Dynamixel.h:646
void DynaLogServoAlarms(int nServoId, uint_t uAlarms)
Log servo alarms.
Definition: DynaError.cxx:183

Log servo alarms.

Parameters
idServo id.
alarmsAlarm bits fields.

Definition at line 131 of file DynaLibInternal.h.

Referenced by DynaCommSerial::Read16(), DynaCommSerial::Read8(), DynaCommSerial::Reset(), DynaServoGeneric::SyncState(), DynaCommSerial::Write16(), and DynaCommSerial::Write8().

#define DYNA_LOG_SYS_ERROR (   ecode,
  efmt,
  ... 
)
Value:
LOGSYSERROR("%s(ecode=%d): " efmt, \
DynaStrError(ecode), (ecode>=0? ecode: -ecode), \
##__VA_ARGS__)
const char * DynaStrError(int ecode)
Get the error string describing the Dynamixel error code.
Definition: DynaError.cxx:141

Log System Error.

Parameters
ecodePackage Error Codes error code.
efmtError output format string literal.
...Error variable arguments.

Definition at line 85 of file DynaLibInternal.h.

Referenced by DynaCommSerial::SetBaudRate().

#define DYNA_TRY_ADDR (   addr)
Value:
do \
{ \
if( !( (((int)(addr) >= DYNA_EEPROM_MIN_ADDR) && \
((int)(addr) <= DYNA_EEPROM_MAX_ADDR)) || \
(((int)(addr) >= DYNA_RAM_MIN_ADDR) && \
((int)(addr) <= DYNA_RAM_MAX_ADDR)) ) ) \
{ \
"Control table address 0x%02x: Out of range.", (int)(addr)); \
return -DYNA_ECODE_BAD_VAL; \
} \
} while(0)
#define DYNA_RAM_MIN_ADDR
minimum RAM adderss
Definition: Dynamixel.h:335
#define DYNA_EEPROM_MIN_ADDR
minimum EEPROM adderss
Definition: Dynamixel.h:333
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_EEPROM_MAX_ADDR
maximum EEPROM adderss
Definition: Dynamixel.h:334
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85
#define DYNA_RAM_MAX_ADDR
maximum RAM adderss
Definition: Dynamixel.h:336

Test if servo address is valid.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]addrServo control table address.

Definition at line 349 of file DynaLibInternal.h.

Referenced by DynaServoEX106P::Read(), DynaServoGeneric::Read(), DynaServoEX106P::Write(), and DynaServoGeneric::Write().

#define DYNA_TRY_COMM (   comm)
Value:
do \
{ \
if( !(comm).IsOpen() ) \
{ \
DYNA_LOG_ERROR(DYNA_ECODE_BADF, "Communication not open."); \
return -DYNA_ECODE_BADF; \
} \
} while(0)
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_ECODE_BADF
no comm object or not open
Definition: Dynamixel.h:88

Test if bus communication is available exception macro.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]commDynamixel bus communication object.

Definition at line 171 of file DynaLibInternal.h.

Referenced by DynaChain::AddNewServo(), DynaChain::AddNewServosByScan(), DynaServoGeneric::AgentWriteGoalPos(), DynaServoGeneric::AgentWriteGoalSpeed(), DynaServoGeneric::AgentWriteGoalSpeedPos(), DynaServoGeneric::CfgReadAlarmShutdownMask(), DynaServoEX106P::CfgReadDriveMode(), DynaServoGeneric::CfgReadMaxTorqueLimit(), DynaServoGeneric::CfgReadRotationLimits(), DynaServoGeneric::CfgReadServoMode(), DynaServoGeneric::CfgReadTemperatureLimit(), DynaServoGeneric::CfgReadVoltageLimits(), DynaServoGeneric::CfgWriteAlarmShutdownMask(), DynaServoEX106P::CfgWriteDriveMode(), DynaServoGeneric::CfgWriteMaxTorqueLimit(), DynaServoGeneric::CfgWriteRotationLimits(), DynaServoGeneric::CfgWriteServoMode(), DynaServoGeneric::CfgWriteServoModeContinuous(), DynaServoGeneric::CfgWriteTemperatureLimit(), DynaServoGeneric::CfgWriteVoltageLimits(), DynaChain::ChainEntryNew(), DynaServoGeneric::EStop(), DynaChain::EStop(), DynaServoGeneric::Freeze(), DynaChain::Freeze(), DynaServoGeneric::MoveAtSpeed(), DynaChain::MoveAtSpeed(), DynaServoGeneric::MoveAtSpeedTo(), DynaChain::MoveAtSpeedTo(), DynaServoGeneric::MoveTo(), DynaChain::MoveTo(), DynaCommSerial::Ping(), DynaCommBotSense::Ping(), DynaServo::Ping(), DynaServoGeneric::Ping(), DynaServoEX106P::Read(), DynaServoGeneric::Read(), DynaCommSerial::Read16(), DynaCommBotSense::Read16(), DynaCommSerial::Read8(), DynaCommBotSense::Read8(), DynaServo::ReadBaudRate(), DynaServoGeneric::ReadControlMethod(), DynaServoGeneric::ReadCurLoad(), DynaServoGeneric::ReadCurPos(), DynaServoGeneric::ReadCurSpeed(), DynaServoGeneric::ReadDynamics(), DynaServo::ReadFirmwareVersion(), DynaServoGeneric::ReadGoalPos(), DynaServoGeneric::ReadGoalSpeed(), DynaServoGeneric::ReadHealth(), DynaServoGeneric::ReadIsMoving(), DynaServoGeneric::ReadLed(), DynaServoGeneric::ReadMaxTorqueLimit(), DynaServo::ReadModelNumber(), DynaServoEX106P::ReadSensedCurrent(), DynaServo::ReadServoId(), DynaServoGeneric::ReadTorqueEnable(), DynaServoGeneric::Release(), DynaChain::Release(), DynaServoGeneric::ReloadMaxTorqueLimit(), DynaCommSerial::Reset(), DynaCommBotSense::Reset(), DynaServo::Reset(), DynaServoGeneric::Reset(), DynaServoGeneric::Stop(), DynaChain::Stop(), DynaServoEX106P::SyncCfg(), DynaServoGeneric::SyncCfg(), DynaChain::SyncMoveAtSpeed(), DynaChain::SyncMoveAtSpeedTo(), DynaChain::SyncMoveTo(), DynaServoEX106P::SyncState(), DynaServoGeneric::SyncState(), DynaCommSerial::SyncWrite(), DynaCommBotSense::SyncWrite(), DynaChain::SyncWriteGoalPos(), DynaChain::SyncWriteGoalSpeed(), DynaChain::SyncWriteTorqueEnable(), DynaChain::vSyncMoveAtSpeed(), DynaChain::vSyncMoveAtSpeedTo(), DynaChain::vSyncWriteGoalPos(), DynaChain::vSyncWriteGoalSpeed(), DynaServoEX106P::Write(), DynaServoGeneric::Write(), DynaCommSerial::Write16(), DynaCommBotSense::Write16(), DynaCommSerial::Write8(), DynaCommBotSense::Write8(), DynaServo::WriteBaudRate(), DynaServoGeneric::WriteControlMethod(), DynaServoGeneric::WriteCtlMethodCompliance(), DynaServoGeneric::WriteCtlMethodPid(), DynaServoGeneric::WriteGoalPos(), DynaServoGeneric::WriteGoalSpeed(), DynaServoGeneric::WriteLed(), DynaServoGeneric::WriteMaxTorqueLimit(), DynaServo::WriteServoId(), and DynaServoGeneric::WriteTorqueEnable().

#define DYNA_TRY_EXPR (   expr,
  ecode,
  efmt,
  ... 
)
Value:
do \
{ \
if ( !(expr) ) \
{ \
DYNA_LOG_ERROR(ecode, "%s: " efmt, #expr, ##__VA_ARGS__); \
return (ecode > 0) ? -(ecode) : ecode; \
} \
} while(0)
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.

Test if the servo is in the required mode(s) exception macro.

If the check is false, an appropriate error is logged and the calling function immediately returns with the appropriate < 0 error code.

Parameters
exprExpression to evaluate
ecodeCogniBoost error code.
efmtError output format string literal.
...Variable arguments.

Definition at line 401 of file DynaLibInternal.h.

Referenced by DynaServoGeneric::AgentWriteGoalSpeed(), DynaServoGeneric::AgentWriteGoalSpeedPos(), DynaServoGeneric::CalcMatesGoalPos(), DynaServoEX106P::CfgWriteDriveMode(), DynaServoGeneric::CfgWriteMaxTorqueLimit(), DynaServoGeneric::CfgWriteRotationLimits(), DynaServoGeneric::CfgWriteTemperatureLimit(), DynaServoGeneric::CfgWriteVoltageLimits(), DynaChain::LinkServos(), DynaChain::SyncWriteGoalPos(), DynaChain::SyncWriteGoalSpeed(), DynaChain::UnlinkServos(), DynaServoGeneric::WriteCtlMethodCompliance(), DynaServoGeneric::WriteCtlMethodPid(), DynaServoGeneric::WriteGoalPos(), DynaServoGeneric::WriteGoalSpeed(), and DynaServoGeneric::WriteMaxTorqueLimit().

#define DYNA_TRY_IS_MASTER (   pservo)
Value:
do \
{ \
if( !((pservo)->IsMaster()) ) \
{ \
"Servo %d: Not a master servo.", \
(pservo)->m_nServoId); \
return -DYNA_ECODE_SLAVE; \
} \
} while(0)
#define DYNA_ECODE_SLAVE
invalid slave operation
Definition: Dynamixel.h:99
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.

Test if the servo is a master servo.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]pservoPointer to DynaServo derived object.

Definition at line 210 of file DynaLibInternal.h.

Referenced by DynaServoGeneric::AgentWriteGoalPos(), DynaServoGeneric::AgentWriteGoalSpeed(), DynaServoGeneric::AgentWriteGoalSpeedPos(), DynaServoGeneric::CfgWriteAlarmShutdownMask(), DynaServoEX106P::CfgWriteDriveMode(), DynaServoGeneric::CfgWriteMaxTorqueLimit(), DynaServoGeneric::CfgWriteRotationLimits(), DynaServoGeneric::CfgWriteServoMode(), DynaServoGeneric::CfgWriteServoModeContinuous(), DynaServoGeneric::CfgWriteTemperatureLimit(), DynaServoGeneric::CfgWriteVoltageLimits(), DynaServoGeneric::EStop(), DynaServoGeneric::Freeze(), DynaServoGeneric::MoveAtSpeed(), DynaChain::MoveAtSpeed(), DynaServoGeneric::MoveAtSpeedTo(), DynaChain::MoveAtSpeedTo(), DynaServoGeneric::MoveTo(), DynaChain::MoveTo(), DynaServoGeneric::Release(), DynaServoGeneric::ReloadMaxTorqueLimit(), DynaServoGeneric::Stop(), DynaChain::SyncMoveAtSpeed(), DynaChain::SyncMoveAtSpeedTo(), DynaChain::SyncMoveTo(), DynaChain::SyncWriteGoalPos(), DynaChain::SyncWriteGoalSpeed(), DynaChain::vSyncMoveAtSpeed(), DynaServoGeneric::WriteControlMethod(), DynaServoGeneric::WriteCtlMethodCompliance(), DynaServoGeneric::WriteCtlMethodPid(), DynaServoGeneric::WriteGoalPos(), DynaServoGeneric::WriteGoalSpeed(), DynaServoGeneric::WriteLed(), DynaServoGeneric::WriteMaxTorqueLimit(), and DynaServoGeneric::WriteTorqueEnable().

#define DYNA_TRY_IS_UNLINKED (   pservo)
Value:
do \
{ \
if( !((pservo)->IsUnlinked()) ) \
{ \
"Servo %d: Operation not supported: Linked with servo %d.", \
(pservo)->m_nServoId, (pservo)->m_link.m_pServoMate->GetServoId()); \
return -DYNA_ECODE_LINKED; \
} \
} while(0)
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_ECODE_LINKED
linked servos error
Definition: Dynamixel.h:98

Test if the servo is unlinked.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]pservoPointer to DynaServo derived object.

Definition at line 231 of file DynaLibInternal.h.

#define DYNA_TRY_RC (   rc,
  fmt,
  ... 
)
Value:
do \
{ \
if( (rc) < 0 ) \
{ \
DYNA_LOG_ERROR(rc, fmt, ##__VA_ARGS__); \
return rc; \
} \
} while(0)
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.

Test if Dynamixel return code is not an error.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]commDynamixel bus communication object.

Definition at line 152 of file DynaLibInternal.h.

Referenced by DynaServoGeneric::CalcMatesGoalPos(), DynaCommBotSense::SetBaudRate(), DynaCommBotSense::SetHalfDuplexCtl(), and DynaChain::SyncWriteGoalPos().

#define DYNA_TRY_SERVO_HAS_AGENT (   pservo)
Value:
do \
{ \
if( (pservo)->m_pAgent == NULL ) \
{ \
"Servo %d: No servo proxy agent.", \
(pservo)->m_nServoId); \
} \
} while(0)
#define DYNA_ECODE_NOT_SUPP
feature/function not supported
Definition: Dynamixel.h:97
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.

Test if the servo has a proxy agent.

The proxy agent is required to do position control for servos in continuous mode, since the servos do not support this function.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]pservoPointer to DynaServo derived object.

Definition at line 328 of file DynaLibInternal.h.

Referenced by DynaServoGeneric::AgentWriteGoalPos(), DynaServoGeneric::AgentWriteGoalSpeed(), and DynaServoGeneric::AgentWriteGoalSpeedPos().

#define DYNA_TRY_SERVO_HAS_MODE (   pservo,
  mode 
)
Value:
do \
{ \
if( !((pservo)->m_spec.m_uSupportedModes & (mode)) ) \
{ \
"Servo %d: Required %s mode not supported.",\
(pservo)->m_nServoId, \
(((mode)&DYNA_MODE_CONTINUOUS)? "continuous": "servo")); \
} \
} while(0)
#define DYNA_ECODE_NOT_SUPP
feature/function not supported
Definition: Dynamixel.h:97
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171

Test if the servo has one of the required modes exception macro.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]pservoPointer to DynaServo derived object.
[in]modeRequired servo modes mask.

Definition at line 253 of file DynaLibInternal.h.

Referenced by DynaServoGeneric::CfgWriteServoModeContinuous().

#define DYNA_TRY_SERVO_HAS_POS_CTL (   pservo)
Value:
do \
{ \
if( ((pservo)->m_cfg.m_uServoMode != DYNA_MODE_SERVO) && \
!(pservo)->m_spec.m_bHas360Pos ) \
{ \
"Servo %d: Does not support position control.", \
(pservo)->m_nServoId); \
} \
} while(0)
#define DYNA_MODE_SERVO
servo mode with limited rotation
Definition: Dynamixel.h:170
#define DYNA_ECODE_NOT_SUPP
feature/function not supported
Definition: Dynamixel.h:97
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.

Test if the servo has positiion control.

A servo has position control if:

  • in servo mode (servo will translate to new position).
  • in continuous mode with 360 ° position data (host will translate to new position).

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]pservoPointer to DynaServo derived object.

Definition at line 303 of file DynaLibInternal.h.

Referenced by DynaServoGeneric::AgentWriteGoalPos(), DynaServoGeneric::AgentWriteGoalSpeed(), DynaServoGeneric::AgentWriteGoalSpeedPos(), DynaServoGeneric::MoveAtSpeedTo(), DynaChain::MoveAtSpeedTo(), DynaServoGeneric::MoveTo(), DynaServoGeneric::ReadCurPos(), DynaChain::SyncMoveAtSpeedTo(), and DynaChain::SyncMoveTo().

#define DYNA_TRY_SERVO_ID (   id)
Value:
do \
{ \
if( ((int)(id) < DYNA_ID_MIN) || ((int)(id) > DYNA_ID_MAX) ) \
{ \
DYNA_LOG_ERROR(DYNA_ECODE_BAD_VAL, "Servo id %d: Out-of-range.", \
(int)(id)); \
return -DYNA_ECODE_BAD_VAL; \
} \
} while(0)
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85

Testing if the servo id is in range exception macro.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]idServo id.

Definition at line 190 of file DynaLibInternal.h.

Referenced by DynaChain::AddNewServo(), DynaChain::ChainEntryDelete(), DynaChain::ChainEntryNew(), DynaServo::Ping(), DynaServo::ReadBaudRate(), DynaServo::ReadFirmwareVersion(), DynaServo::ReadModelNumber(), DynaServo::ReadServoId(), DynaServo::Reset(), DynaServo::WriteBaudRate(), and DynaServo::WriteServoId().

#define DYNA_TRY_SERVO_IN_CHAIN (   pchain,
  id 
)
Value:
do \
{ \
if( ((int)(id) < DYNA_ID_MIN) || ((int)(id) > DYNA_ID_MAX) ) \
{ \
DYNA_LOG_ERROR(DYNA_ECODE_BAD_VAL, "Servo %d: Id out of range.", \
(int)(id)); \
return -DYNA_ECODE_BAD_VAL; \
} \
else if( (pchain)->m_pChain[(id)] == NULL ) \
{ \
DYNA_LOG_ERROR(DYNA_ECODE_NO_SERVO, "Servor %d: No servo in chain.", \
(int)(id)); \
} \
} while(0)
#define DYNA_ECODE_NO_SERVO
no servo found
Definition: Dynamixel.h:86
#define DYNA_ID_MIN
minimum servo id
Definition: Dynamixel.h:146
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_ID_MAX
maximum servo id
Definition: Dynamixel.h:147
#define DYNA_ECODE_BAD_VAL
bad value
Definition: Dynamixel.h:85

Test if the servo id is valid and present in chain exception macro.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]pchainPointer to DynaChain object.
[in]idServo id.

Definition at line 373 of file DynaLibInternal.h.

Referenced by DynaChain::LinkServos(), DynaChain::MoveAtSpeed(), DynaChain::MoveAtSpeedTo(), DynaChain::MoveTo(), DynaChain::RemoveServo(), DynaChain::SyncMoveAtSpeed(), DynaChain::SyncMoveAtSpeedTo(), DynaChain::SyncMoveTo(), DynaChain::SyncWriteGoalPos(), DynaChain::SyncWriteGoalSpeed(), DynaChain::UnlinkServos(), and DynaChain::vSyncMoveAtSpeed().

#define DYNA_TRY_SERVO_IN_MODE (   pservo,
  mode 
)
Value:
do \
{ \
if( ((pservo)->m_cfg.m_uServoMode != (mode)) ) \
{ \
"Servo %d: Not in required %s mode.",\
(pservo)->m_nServoId, \
(((mode)&DYNA_MODE_CONTINUOUS)? "continuous": "servo")); \
} \
} while(0)
#define DYNA_ECODE_NOT_SUPP
feature/function not supported
Definition: Dynamixel.h:97
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171

Test if the servo is in the given mode.

If the try fails, an appropriate error is logged and the calling function is immediately exited by invoking a return with the < 0 error code.

Parameters
[in]pservoPointer to DynaServo derived object.
[in]modeRequired servo modes mask.

Definition at line 276 of file DynaLibInternal.h.

Referenced by DynaServoGeneric::MoveAtSpeed(), DynaChain::SyncMoveAtSpeed(), and DynaChain::vSyncMoveAtSpeed().

Function Documentation

int DynaMapDxlToEcode ( int  nDxlError)

Map DXL library error code to Dynamixel error code.

Parameters
nDxlErrorDXL error code.
Returns
Dynamixel library error code.

Definition at line 117 of file DynaError.cxx.

References DXL_COMM_RXCORRUPT, DXL_COMM_RXFAIL, DXL_COMM_RXTIMEOUT, DXL_COMM_TXERROR, DXL_COMM_TXFAIL, DYNA_ECODE_ECOMM, DYNA_ECODE_RX_BAD_PKT, DYNA_ECODE_RX_FAIL, DYNA_ECODE_RX_TIMEOUT, DYNA_ECODE_TX_ERROR, and DYNA_ECODE_TX_FAIL.

Referenced by newstr(), DynaCommSerial::Read16(), DynaCommSerial::Read8(), DynaCommSerial::Reset(), DynaCommSerial::SyncWrite(), DynaCommSerial::Write16(), and DynaCommSerial::Write8().

118 {
119  switch( nDxlError )
120  {
121  case DXL_COMM_TXFAIL:
122  return DYNA_ECODE_TX_FAIL;
123  case DXL_COMM_RXFAIL:
124  return DYNA_ECODE_RX_FAIL;
125  case DXL_COMM_TXERROR:
126  return DYNA_ECODE_TX_ERROR;
127  case DXL_COMM_RXTIMEOUT:
128  return DYNA_ECODE_RX_TIMEOUT;
129  case DXL_COMM_RXCORRUPT:
130  return DYNA_ECODE_RX_BAD_PKT;
131  default:
132  return DYNA_ECODE_ECOMM;
133  }
134 }
#define DXL_COMM_TXFAIL
transmit failure error
Definition: dxl.h:110
#define DYNA_ECODE_RX_TIMEOUT
dynamixel receive packet time out
Definition: Dynamixel.h:93
#define DXL_COMM_TXERROR
packed transmit packet format error
Definition: dxl.h:112
#define DYNA_ECODE_RX_BAD_PKT
dynamixel receive bad packet
Definition: Dynamixel.h:94
#define DXL_COMM_RXTIMEOUT
receive timeout error
Definition: dxl.h:114
#define DYNA_ECODE_ECOMM
dynamixel communication error
Definition: Dynamixel.h:89
#define DYNA_ECODE_TX_ERROR
dynamixel transmit packet error
Definition: Dynamixel.h:92
#define DXL_COMM_RXCORRUPT
receive corrupted packet
Definition: dxl.h:115
#define DXL_COMM_RXFAIL
receive failure error
Definition: dxl.h:111
#define DYNA_ECODE_TX_FAIL
dynamixel transmit packet failure
Definition: Dynamixel.h:90
#define DYNA_ECODE_RX_FAIL
dynamixel receive packet failure
Definition: Dynamixel.h:91
char* newstr ( const char *  s)
inline

Allocate new duplicated string.

Parameters
sString to duplicate.
Returns
Returns pointer to allocated string if s is not NULL and the length of s > 0.
Otherwise returns NULL.

Definition at line 432 of file DynaLibInternal.h.

References DynaMapDxlToEcode().

Referenced by DynaComm::DynaComm(), DynaCommBotSense::DynaCommBotSense(), DynaCommSerial::DynaCommSerial(), DynaServo::Init(), DynaShellCmdLoadRecording::Init(), DynaServoAX12::InitSpec(), DynaServoRX24F::InitSpec(), DynaServoRX10::InitSpec(), DynaServoRX28::InitSpec(), DynaServoRX64::InitSpec(), DynaServoMX28::InitSpec(), DynaServoMX64::InitSpec(), DynaServoMX12W::InitSpec(), DynaServoMX106::InitSpec(), DynaServoEX106P::InitSpec(), DynaServoGeneric::InitSpec(), DynaCommSerial::Open(), DynaCommBotSense::Open(), DynaRecording::SetDate(), DynaShellCmdLoadRecording::SetDateField(), and DynaShellCmd::SetPublishedInfo().

433 {
434  char *t;
435  if( (s != NULL) && (*s != 0) )
436  {
437  t = new char[strlen(s)+1];
438  strcpy(t, s);
439  }
440  else
441  {
442  t = NULL;
443  }
444  return t;
445 }
Definition: t.py:1