![]() |
Dynamixel
2.9.5
RoadNarrows Robotics Dynamixel Package
|
Dynamixel Bus Communications Abstract Base Class. More...
#include <DynaComm.h>
Public Types | |
typedef void(* | HalfDuplexTxFunc_T) (void *pArg) |
Half-duplex control transmit function type. | |
typedef void(* | HalfDuplexRxFunc_T) (void *pArg, size_t uNumTxBytes) |
Half-duplex control receive function type. | |
Public Member Functions | |
DynaComm () | |
DynaComm (const char *sUri, int nBaudRate) | |
virtual | ~DynaComm () |
Destructor. | |
const char * | GetDeviceUri () const |
const int | GetBaudRate () const |
virtual int | GetResourceId () const =0 |
Get system-unique resource identifier. More... | |
virtual int | Open (const char *sDevUri, int nBaudRate)=0 |
Open communication to dynamixel bus. More... | |
virtual int | Open ()=0 |
(Re)Open communication to dynamixel bus. More... | |
virtual int | Close ()=0 |
Close communication to dynamixel bus. More... | |
virtual int | SetBaudRate (int nNewBaudRate)=0 |
Set the Dynamixel Bus new baud rate. More... | |
virtual int | SetHalfDuplexCtl (int nSignal, HalfDuplexTxFunc_T fnEnableTx=NULL, HalfDuplexRxFunc_T fnEnableRx=NULL)=0 |
virtual int | Read8 (int nServoId, uint_t uAddr, byte_t *pVal)=0 |
Read an 8-bit value from Dynamixel servo control table. More... | |
virtual int | Read8 (int nServoId, uint_t uAddr, uint_t *pVal) |
Read an 8-bit value from Dynamixel servo control table. More... | |
virtual int | Write8 (int nServoId, uint_t uAddr, byte_t byVal)=0 |
Write an 8-bit value to Dynamixel servo control table. More... | |
virtual int | Write8 (int nServoId, uint_t uAddr, uint_t uVal) |
Write an 8-bit value to Dynamixel servo control table. More... | |
virtual int | Read16 (int nServoId, uint_t uAddr, ushort_t *pVal)=0 |
Read a 16-bit value from Dynamixel servo control table. More... | |
virtual int | Read16 (int nServoId, uint_t uAddr, uint_t *pVal) |
Read a 16-bit value from Dynamixel servo control table. More... | |
virtual int | Write16 (int nServoId, uint_t uAddr, ushort_t uhVal)=0 |
Write a 16-bit value to Dynamixel servo control table. More... | |
virtual int | Write16 (int nServoId, uint_t uAddr, uint_t uVal) |
Write a 16-bit value to Dynamixel servo control table. More... | |
virtual int | vSyncWrite (uint_t uAddr, uint_t uValSize, uint_t uCount,...) |
Synchronous write 8/16-bit values to a list of Dynamixel servos. More... | |
virtual int | SyncWrite (uint_t uAddr, uint_t uValSize, DynaSyncWriteTuple_T tuples[], uint_t uCount)=0 |
Synchronous Write 8/16-bit values to a list of Dynamixel servos. More... | |
virtual bool | Ping (int nServoId)=0 |
Ping the servo. More... | |
virtual int | Reset (int nServoId)=0 |
Reset a servo back to default values. More... | |
virtual bool | IsOpen () |
Test if Dynamixel Bus is open. More... | |
virtual uint_t | GetAlarms () |
Get current alarms. More... | |
virtual void | ClearAlarms () |
Clear current alarms. | |
virtual uint_t | GetBusStatus () |
Get the Dynamixel Bus status. More... | |
Static Public Member Functions | |
static DynaComm * | New (const char *sUri, int nBaudRate) |
Archetype constructor to create a new Dynamixel bus communication derived instance. More... | |
static std::string | GetAlarmsString (const uint_t uAlarms, const std::string &strSep="; ") |
Get a formatted servo alarms string associated with the alarms. More... | |
static std::string | GetAlarmsShortString (const uint_t uAlarms, const std::string &strSep=",") |
Get a formatted servo alarms short string associated with the alarms. More... | |
static const char * | GetBusStatusString (uint_t uBusStatus) |
Get the string describing the Dynamixel servo communication status. More... | |
static int | BaudRateToNum (int nBaudRate) |
Map baud rate to Dynamixel baud number. More... | |
static int | BaudNumToRate (int nBaudRate) |
Map baud number to Dynamixel baud rate. More... | |
static int | BaudRateAt (int nIndex) |
Get the baud rate associated with the given index. More... | |
static int | BaudNumAt (int nIndex) |
Get the baud number associated with the given index. More... | |
Protected Attributes | |
char * | m_sDevUri |
dynamixel bus device URI | |
int | m_nBaudRate |
baud rate | |
bool | m_bIsOpen |
dynamixel bus communication is [not] open | |
uint_t | m_uBusStatus |
bus comminication status | |
uint_t | m_uAlarms |
servo alarms from last I/O operation | |
shm_mutex_t | m_mutexComm |
synchonization mutex | |
Static Protected Attributes | |
static const key_t | ShmKey = 0x70add12a |
shared memory key More... | |
Dynamixel Bus Communications Abstract Base Class.
The DynaComm abstract class provides the I/O template to communicate with Dynamixel servos on a Dynamixel bus.
Definition at line 80 of file DynaComm.h.
DynaComm::DynaComm | ( | ) |
Default constructor.
Definition at line 149 of file DynaComm.cxx.
References DYNA_ALARM_NONE.
DynaComm::DynaComm | ( | const char * | sUri, |
int | nBaudRate | ||
) |
Initialization constructor.
sUri | Dynamixel Bus device Uniform Resource Identifier string. |
nBaudRate | Device baud rate. |
Definition at line 159 of file DynaComm.cxx.
References DYNA_ALARM_NONE, and newstr().
|
static |
Get the baud number associated with the given index.
This function can be used to iterate of all supported baud rates.
nIndex | Zero based index. |
Definition at line 408 of file DynaComm.cxx.
References DynaBaudMap.
Referenced by GetBusStatus().
|
static |
Map baud number to Dynamixel baud rate.
nBaudNum | Baud number. |
Definition at line 382 of file DynaComm.cxx.
References DYNA_ECODE_BAD_VAL, and DynaBaudMap.
Referenced by GetBusStatus(), and DynaServo::ReadBaudRate().
|
static |
Get the baud rate associated with the given index.
This function can be used to iterate of all supported baud rates.
nIndex | Zero based index. |
Definition at line 396 of file DynaComm.cxx.
References DynaBaudMap.
Referenced by GetBusStatus(), and DynaShellCmdCreate::TabCompletion().
|
static |
Map baud rate to Dynamixel baud number.
nBaudRate | Baud rate. |
Definition at line 368 of file DynaComm.cxx.
References DYNA_ECODE_BAD_VAL, and DynaBaudMap.
Referenced by GetBusStatus(), New(), DynaCommSerial::Open(), DynaCommSerial::SetBaudRate(), and DynaServo::WriteBaudRate().
|
pure virtual |
Close communication to dynamixel bus.
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by GetBaudRate().
|
inlinevirtual |
Get current alarms.
Definition at line 393 of file DynaComm.h.
References m_uAlarms.
Referenced by DynaServoGeneric::ReadHealth().
|
static |
Get a formatted servo alarms short string associated with the alarms.
uAlarms | Dynamixel servo alarm bits. |
strSep | Separator string between alarm substrings. |
Definition at line 340 of file DynaComm.cxx.
References DYNA_ALARM_NONE, and DynaServoAlarmShortStrTbl.
Referenced by ClearAlarms().
|
static |
Get a formatted servo alarms string associated with the alarms.
uAlarms | Dynamixel servo alarm bits. |
strSep | Separator string between alarm substrings. |
Definition at line 312 of file DynaComm.cxx.
References DYNA_ALARM_NONE, and DynaServoAlarmStrTbl.
Referenced by ClearAlarms(), DynaShellCmdReadHealth::doExec(), DynaLogServoAlarms(), and DynaShell::Error().
|
inline |
Get the current baud rate.
Definition at line 146 of file DynaComm.h.
References Close(), GetResourceId(), m_nBaudRate, Open(), Read8(), SetBaudRate(), and SetHalfDuplexCtl().
|
inlinevirtual |
Get the Dynamixel Bus status.
Definition at line 434 of file DynaComm.h.
References BaudNumAt(), BaudNumToRate(), BaudRateAt(), BaudRateToNum(), GetBusStatusString(), and m_uBusStatus.
|
static |
Get the string describing the Dynamixel servo communication status.
uBusStatus | Dynamixel bus communication status. |
Definition at line 298 of file DynaComm.cxx.
References DynaBusStatusStrTbl.
Referenced by GetBusStatus().
|
inline |
Get the Dynamixel Bus Uniform Resource Identifier.
Definition at line 136 of file DynaComm.h.
References m_sDevUri.
|
pure virtual |
Get system-unique resource identifier.
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by GetBaudRate().
|
inlinevirtual |
Test if Dynamixel Bus is open.
Definition at line 383 of file DynaComm.h.
References m_bIsOpen.
Referenced by DynaShellCmd::ChkComm(), DynaShellCmdCreate::CommNew(), DynaShellCmdMegaScan::CommNew(), and New().
|
static |
Archetype constructor to create a new Dynamixel bus communication derived instance.
The specific DynaComm object created depends on the URI specified. Currently two derived objects are supported:
DynaCommSerial | Direct connected serial device. |
DynaCommBotSense | BotSense proxied serial device. |
/devicepath
botsense://[hostname][:port]/devicepath
sUri | Uniform Resource Identifier string. |
nBaudRate | Dynamixel bus supported baud rate. |
Definition at line 179 of file DynaComm.cxx.
References BaudRateToNum(), DYNA_ECODE_BAD_DEV, DYNA_ECODE_BAD_VAL, DYNA_LOG_ERROR, and IsOpen().
Referenced by DynaShellCmdCreate::CommNew(), DynaShellCmdMegaScan::CommNew(), and MainInitArgs().
|
pure virtual |
Open communication to dynamixel bus.
The given serial device is opened at the given baud rate.
sDevUri | Device Uniform Resource Identifier. |
nBaudRate | Device baud rate. |
Implemented in DynaCommBotSense, and DynaCommSerial.
|
pure virtual |
(Re)Open communication to dynamixel bus.
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by GetBaudRate().
|
pure virtual |
Ping the servo.
nServoId | Servo id. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by DynaShellCmdPing::Exec(), DynaShellCmdMegaScan::Exec(), DynaServo::Ping(), DynaServoGeneric::Ping(), and Write16().
|
pure virtual |
Read a 16-bit value from Dynamixel servo control table.
nServoId | Servo id. | |
uAddr | Servo control table address. | |
[out] | pVal | Value read. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by DynaServoGeneric::CfgReadMaxTorqueLimit(), DynaServoGeneric::CfgReadRotationLimits(), DynaShellCmdReadMaxTorqueLimit::doExec(), DynaShellCmdReadWord::doExec(), DynaServo::DumpCtlTbl(), DynaServoEX106P::Read(), DynaServoGeneric::Read(), Read16(), DynaServoGeneric::ReadCurLoad(), DynaServoGeneric::ReadCurPos(), DynaServoGeneric::ReadCurSpeed(), DynaServoGeneric::ReadGoalPos(), DynaServoGeneric::ReadGoalSpeed(), DynaServoGeneric::ReadMaxTorqueLimit(), DynaServo::ReadModelNumber(), DynaServoEX106P::ReadSensedCurrent(), and Write8().
|
inlinevirtual |
Read a 16-bit value from Dynamixel servo control table.
nServoId | Servo id. | |
uAddr | Servo control table address. | |
[out] | pVal | Value read. |
Definition at line 290 of file DynaComm.h.
References DYNA_OK, Read16(), and Write16().
|
pure virtual |
Read an 8-bit value from Dynamixel servo control table.
nServoId | Servo id. | |
uAddr | Servo control table address. | |
[out] | pVal | Value read. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by DynaServoGeneric::CfgReadAlarmShutdownMask(), DynaServoEX106P::CfgReadDriveMode(), DynaServoGeneric::CfgReadTemperatureLimit(), DynaServoGeneric::CfgReadVoltageLimits(), DynaShellCmdReadByte::doExec(), DynaServo::DumpCtlTbl(), GetBaudRate(), DynaServoEX106P::Read(), DynaServoGeneric::Read(), Read8(), DynaServo::ReadBaudRate(), DynaServoGeneric::ReadCtlMethodCompliance(), DynaServoGeneric::ReadCtlMethodPid(), DynaServo::ReadFirmwareVersion(), DynaServoGeneric::ReadHealth(), DynaServoGeneric::ReadIsMoving(), DynaServoGeneric::ReadLed(), DynaServo::ReadServoId(), DynaServoGeneric::ReadTorqueEnable(), and DynaServoGeneric::SyncCfg().
|
inlinevirtual |
Read an 8-bit value from Dynamixel servo control table.
nServoId | Servo id. | |
uAddr | Servo control table address. | |
[out] | pVal | Value read. |
Definition at line 231 of file DynaComm.h.
References DYNA_OK, Read8(), and Write8().
|
pure virtual |
Reset a servo back to default values.
nServoId | Servo id. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by DynaServo::Reset(), DynaServoGeneric::Reset(), and Write16().
|
pure virtual |
Set the Dynamixel Bus new baud rate.
nNewBaudRate | New baud rate. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by GetBaudRate().
|
pure virtual |
Set Dynamixel Bus half-duplex software control.
The Dynamixel 3-wire bus is half-duplex. Hardware may automatically control toggling between transmit and receive (e.g. RoadNarrows DynaUSB dongle). If there is no hardware support, then software must provide the tx/rx toggle functions.
nSignal | Signal assign to toggle. |
fnEnableTx | Enable transmit function. |
fnEnableRx | Enable receive function. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by DynaShellCmdSetHalfDuplexCtl::Exec(), and GetBaudRate().
|
pure virtual |
Synchronous Write 8/16-bit values to a list of Dynamixel servos.
uAddr | Servo control table write address. |
uValSize | Value storage size at addtess. 1 or 2 bytes. |
tuples | Array of servo id, write value 2-tuples. |
uCount | Number of tuples. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by DynaShellCmdWriteByte::doExec(), DynaShellCmdWriteWord::doExec(), DynaChain::SyncWriteGoalPos(), DynaChain::SyncWriteGoalSpeed(), DynaChain::SyncWriteTorqueEnable(), and Write16().
|
virtual |
Synchronous write 8/16-bit values to a list of Dynamixel servos.
uAddr | Servo control table write address. |
uValSize | Value storage size of field at addtess. 1 or 2 bytes. |
uCount | Number of tuples. |
... | A variable argument list of uCount 2-tuples of type (int,uint_t) specifying the servo id and the packed raw field value. |
Definition at line 420 of file DynaComm.cxx.
References DYNA_ID_NUMOF, DynaSyncWriteTuple_T::m_nServoId, and DynaSyncWriteTuple_T::m_uVal.
Referenced by DynaServoGeneric::CfgWriteAlarmShutdownMask(), DynaServoEX106P::CfgWriteDriveMode(), DynaServoGeneric::CfgWriteMaxTorqueLimit(), DynaServoGeneric::CfgWriteRotationLimits(), DynaServoGeneric::CfgWriteTemperatureLimit(), DynaServoGeneric::CfgWriteVoltageLimits(), Write16(), DynaServoGeneric::WriteCtlMethodCompliance(), DynaServoGeneric::WriteCtlMethodPid(), DynaServoGeneric::WriteGoalPos(), DynaServoGeneric::WriteGoalSpeed(), DynaServoGeneric::WriteLed(), DynaServoGeneric::WriteMaxTorqueLimit(), and DynaServoGeneric::WriteTorqueEnable().
|
pure virtual |
Write a 16-bit value to Dynamixel servo control table.
nServoId | Servo id. |
uAddr | Servo control table address. |
uhVal | Value written. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by DynaServoGeneric::CfgWriteMaxTorqueLimit(), DynaServoGeneric::CfgWriteRotationLimits(), DynaShellCmdWriteMaxTorqueLimit::doExec(), DynaShellCmdWriteWord::doExec(), Read16(), DynaServoEX106P::Write(), DynaServoGeneric::Write(), Write16(), DynaServoGeneric::WriteGoalPos(), DynaServoGeneric::WriteGoalSpeed(), and DynaServoGeneric::WriteMaxTorqueLimit().
|
inlinevirtual |
Write a 16-bit value to Dynamixel servo control table.
nServoId | Servo id. |
uAddr | Servo control table address. |
uVal | Value written. |
Definition at line 322 of file DynaComm.h.
References Ping(), Reset(), SyncWrite(), vSyncWrite(), and Write16().
|
pure virtual |
Write an 8-bit value to Dynamixel servo control table.
nServoId | Servo id. |
uAddr | Servo control table address. |
byVal | Value written. |
Implemented in DynaCommBotSense, and DynaCommSerial.
Referenced by DynaServoGeneric::CfgWriteAlarmShutdownMask(), DynaServoEX106P::CfgWriteDriveMode(), DynaServoGeneric::CfgWriteTemperatureLimit(), DynaServoGeneric::CfgWriteVoltageLimits(), DynaShellCmdWriteByte::doExec(), Read8(), DynaServoEX106P::Write(), DynaServoGeneric::Write(), Write8(), DynaServo::WriteBaudRate(), DynaServoGeneric::WriteCtlMethodCompliance(), DynaServoGeneric::WriteCtlMethodPid(), DynaServoGeneric::WriteLed(), DynaServo::WriteServoId(), and DynaServoGeneric::WriteTorqueEnable().
|
inlinevirtual |
Write an 8-bit value to Dynamixel servo control table.
nServoId | Servo id. |
uAddr | Servo control table address. |
uVal | Value written. |
Definition at line 263 of file DynaComm.h.
References Read16(), and Write8().
|
staticprotected |