Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

DynamixelDriver Class Reference

description of Dynamixel More...

#include <Dynamixel.h>

Inheritance diagram for DynamixelDriver:

Detailed Description

description of Dynamixel

Definition at line 21 of file Dynamixel.h.

List of all members.

Classes

class  CommThread
struct  ServoInfo
struct  ServoInfoIDSync

Public Types

enum  ServoParam_t { DYNAMIXEL_P = 0, DYNAMIXEL_I, DYNAMIXEL_D }
 

Offsets into OutputPIDs for MX series servos.

More...
enum  OldServoParam_t { DYNAMIXEL_SLOPE = 0, DYNAMIXEL_PUNCH, DYNAMIXEL_MARGIN }
 

Offsets into OuputPIDs, since Dynamixel AX and RX servos don't actually use PID control, but a different set of parameters.

More...
typedef plist::DictionaryOf
< ServoInfo >::const_iterator 
servo_iterator

Public Member Functions

 DynamixelDriver (const std::string &name)
virtual ~DynamixelDriver ()
virtual std::string getClassName () const
 Returns the name of the class (aka its type).
virtual MotionHookgetMotionSink ()
virtual void getSensorSources (std::map< std::string, DataSource * > &sources)
virtual void motionStarting ()
 Called when motion process is starting.
virtual bool isConnected ()
 Should return true if the MotionHook is successfully connected to physical hardware.
virtual void motionStopping ()
 Called when motion process is stopping.
virtual void motionCheck (const float outputs[][NumOutputs])
 Called each time the motion process has polled active motion commands.
virtual void updatePIDs (const std::vector< MotionHook::PIDUpdate > &pids)
 Called when PID values change.
virtual void registerSource ()
 User hook, called when the data source should claim which outputs it provides feedback (providingOuput()).
virtual void deregisterSource ()
 User hook, called when the data source should release its claim on outputs with feedback (ignoringOuput()).
virtual void enteringRealtime (const plist::Primitive< double > &simTimeScale)
 User hook, called when the controller is going to be running in realtime mode, which is probably the normal mode you'd expect.
virtual void leavingRealtime (bool isFullSpeed)
 User hook, called when leaving realtime mode, which means you have no idea when motionCheck() is going to be called in terms of wall-clock time.
virtual unsigned int nextTimestamp ()
 Returns the simulator time of the next data segment.
virtual const std::string & nextName ()
 Returns a descriptive name of the next data segment for user feedback (e.g. a filename for logged data).
virtual bool advance ()
 Called when the simulator is stepping while paused or advancing a frozen data source, return true if successful, or false if no more data is available.
virtual void plistValueChanged (const plist::PrimitiveBase &pl)
virtual void processDriverMessage (const DriverMessaging::Message &d)

Public Attributes

plist::DictionaryOf< ServoInfoservos
 Maps servo IDs to Tekkotsu output offsets, use command line new/delete commands to add/remove mappings.
plist::Primitive< std::string > commName
 Name of the CommPort to use, generally a SerialCommPort with direct binary TTL communication with the servos.
plist::Primitive< floatloadCompensation
 Ratio of load to deflection, if non-zero will use LoadPrediction messages and attempt to counter anticipated loads.
plist::Primitive< unsigned int > commLatency
 The delay (in MILLIseconds, ms) to get a response from the servos due to buffering in the USB-to-TTL interface.
plist::Primitive< unsigned int > numPoll
 Number of sensor queries to send before reading responses. This lets us front-load the queries so we can get multiple responses per read buffer flush period.
plist::Primitive< unsigned int > responseTime
 The amount of time (in MICROseconds, µs) to wait between sending a sensor query and sending another when front-loading the buffer. If this is too short, the next query will collide with the previous response.

Static Public Attributes

static const int START_SERVO_ID = 1
 bioloid kits start the id count at 1
static const unsigned int UNUSED = plist::OutputSelector::UNUSED

Protected Member Functions

void doFreeze ()
 user hook for when frozen is set to true; advance() will be called by simulator at user discretion.
void doUnfreeze ()
 user hook for when frozen is set to false; if enteringRealtime() has been called then you should resume sending data.
void provideOutput (unsigned int idx)
 forwards call to DataSource::providingOutput() if the index is valid
void ignoreOutput (unsigned int idx)
 forwards call to DataSource::ignoringOutput() if the index is valid
void pingServos (bool detectedOnly=false)
 tests each servo to see if it is connected
void sendZeroTorqueCmd (CommPort &comm)
 broadcasts a "relax" command to all servos

Static Protected Member Functions

static void provideValues (const ServoInfo &info, const DynamixelProtocol::ServoSensorsResponse &response)
 sends servo feedback values into the framework
static void provideValues (ServoInfo &info, const DynamixelProtocol::AXS1SensorsResponse &response)
 sends AX-S1 sensor values into the framework
template<class T >
static void writeSyncEntries (std::ostream &os, const std::vector< T > &entries)
 sends a series of sync write entries into a stream (adding appropriate header and checksum)

Protected Attributes

DynamixelDriver::ServoInfoIDSync servoIDSync
DynamixelDriver::CommThread commThread
bool motionActive
bool sensorsActive
std::string lastSensor

Static Protected Attributes

static unsigned int VOLTAGE_SENSOR_OFFSET = capabilities.findSensorOffset("PowerVoltage")
 index of the voltage sensor
static unsigned int TEMP_SENSOR_OFFSET = capabilities.findSensorOffset("PowerThermo")
 index of the temperature sensor

Static Private Attributes

static const std::string autoRegisterDynamixelDriver = DeviceDriver::getRegistry().registerType<DynamixelDriver>("Dynamixel")
 holds the class name, set via registration with the DeviceDriver registry

Member Typedef Documentation

typedef plist::DictionaryOf< ServoInfo >::const_iterator servo_iterator

Definition at line 249 of file Dynamixel.h.


Member Enumeration Documentation

Offsets into OuputPIDs, since Dynamixel AX and RX servos don't actually use PID control, but a different set of parameters.

Enumerator:
DYNAMIXEL_SLOPE 

compliance slope, the proportional control (P in PID)

DYNAMIXEL_PUNCH 

punch, a constant added to the slope once error exceeds compliance margin

DYNAMIXEL_MARGIN 

compliance margin, the amount of error to tolerate before triggering a torque response

Definition at line 34 of file Dynamixel.h.

Offsets into OutputPIDs for MX series servos.

Enumerator:
DYNAMIXEL_P 

P parameter for PID control.

DYNAMIXEL_I 

I parameter for PID control.

DYNAMIXEL_D 

D parameter for PID control.

Definition at line 27 of file Dynamixel.h.


Constructor & Destructor Documentation

DynamixelDriver ( const std::string &  name  )  [explicit]

Definition at line 40 of file Dynamixel.h.

virtual ~DynamixelDriver (  )  [virtual]

Definition at line 65 of file Dynamixel.h.


Member Function Documentation

bool advance (  )  [virtual]

Called when the simulator is stepping while paused or advancing a frozen data source, return true if successful, or false if no more data is available.

Implements DataSource.

Definition at line 166 of file Dynamixel.cc.

Referenced by CommThread::runloop().

void deregisterSource (  )  [virtual]

User hook, called when the data source should release its claim on outputs with feedback (ignoringOuput()).

It would be wise to call this from your destructor as well.

Reimplemented from DataSource.

Definition at line 120 of file Dynamixel.cc.

void doFreeze (  )  [protected, virtual]

user hook for when frozen is set to true; advance() will be called by simulator at user discretion.

Reimplemented from DataSource.

Definition at line 151 of file Dynamixel.cc.

void doUnfreeze (  )  [protected, virtual]

user hook for when frozen is set to false; if enteringRealtime() has been called then you should resume sending data.

Reimplemented from DataSource.

Definition at line 144 of file Dynamixel.cc.

virtual void enteringRealtime ( const plist::Primitive< double > &   )  [virtual]

User hook, called when the controller is going to be running in realtime mode, which is probably the normal mode you'd expect.

You might be in realtime mode, but a debugger breakpoint will still pause things, or thread scheduling could hiccup, so try to be robust.
The argument is a reference to SharedGlobals::timeScale, so the data source can subscribe to changes in simulation speed if it can use that information. (We avoid direct dependency on the tekkotsu simulator so this code can be reused for other tools too.)

Reimplemented from DataSource.

Definition at line 86 of file Dynamixel.h.

virtual std::string getClassName (  )  const [virtual]

Returns the name of the class (aka its type).

Suggested implementation is to declare a static string member, set it to the result of calling the registry's registerType, and then return that member here

Implements DeviceDriver.

Definition at line 71 of file Dynamixel.h.

Referenced by plistValueChanged().

virtual MotionHook* getMotionSink (  )  [virtual]

Reimplemented from DeviceDriver.

Definition at line 73 of file Dynamixel.h.

virtual void getSensorSources ( std::map< std::string, DataSource * > &  sources  )  [virtual]

Reimplemented from DeviceDriver.

Definition at line 74 of file Dynamixel.h.

void ignoreOutput ( unsigned int  idx  )  [protected]

forwards call to DataSource::ignoringOutput() if the index is valid

Definition at line 399 of file Dynamixel.h.

Referenced by deregisterSource(), and plistValueChanged().

bool isConnected (  )  [virtual]

Should return true if the MotionHook is successfully connected to physical hardware.

If relevant, this will only be called after motionStarting() has been called in order to initialize a connection.

This is used mainly to cancel out of the WaitForSensors if all MotionHooks return false. If you are still in the process of connecting or unsure of status, be optimistic and return true. This function will be polled at a coarse rate while blocked on sensors in case of timeouts on the part of the MotionHook render it moot.

Implements MotionHook.

Definition at line 58 of file Dynamixel.cc.

virtual void leavingRealtime ( bool   )  [virtual]

User hook, called when leaving realtime mode, which means you have no idea when motionCheck() is going to be called in terms of wall-clock time.

Argument set to true if entering full speed mode, which indicates everything should run at full native "frame rate", and may indicate more data will be processed than normal, CPU speed permitting. However, if false, almost certainly indicates updates will be sparse, trigger by user 'step' commands. May be called multiple times if changing between full-speed mode and paused

A non-realtime mode might be triggered if the user wants to pause the simulator/controller to step through something... No guarantees though! The debugger might catch a breakpoint and stop things, and this won't be called!

Reimplemented from DataSource.

Definition at line 87 of file Dynamixel.h.

void motionCheck ( const float  outputs[][NumOutputs]  )  [virtual]

Called each time the motion process has polled active motion commands.

When in realtime mode, this should be called every FrameTime*NumFrames (defined in the RobotInfo) milliseconds if running at full speed. See enteringRealtime() and leavingRealtime().

This default implementation checks to see which outputs have changed value since the last call and passes the summary on to motionUpdated(). lastOutputs will be updated with the new values after the call to motionUpdated().

If you need to process all the outputs on every frame, you only need to override this function. Your subclass doesn't need to call the MotionHook implementation unless you want to have lastOutputs updated for you.

If you only need to process the changed outputs for each frame, override motionUpdated() instead. motionUpdated() is always called for each update, even if there aren't any changes, so you can still use that if there are some outputs which need to be updated every cycle.

Reimplemented from MotionHook.

Definition at line 80 of file Dynamixel.cc.

void motionStarting (  )  [virtual]

Called when motion process is starting.

Reimplemented from MotionHook.

Definition at line 20 of file Dynamixel.cc.

Referenced by plistValueChanged().

void motionStopping (  )  [virtual]

Called when motion process is stopping.

Reimplemented from MotionHook.

Definition at line 63 of file Dynamixel.cc.

virtual const std::string& nextName (  )  [virtual]

Returns a descriptive name of the next data segment for user feedback (e.g. a filename for logged data).

Just use your class name if you don't have a useful name for individual samples.

Implements DataSource.

Definition at line 90 of file Dynamixel.h.

unsigned int nextTimestamp (  )  [virtual]

Returns the simulator time of the next data segment.

Should be in the future if nothing new since last data segment, otherwise should be the timestamp of the most recent data segment (older segments are skipped), return -1U if there is no more data

Implements DataSource.

Definition at line 159 of file Dynamixel.cc.

void pingServos ( bool  detectedOnly = false  )  [protected]

tests each servo to see if it is connected

Definition at line 273 of file Dynamixel.cc.

Referenced by advance(), motionStarting(), CommThread::plistCollectionEntriesChanged(), CommThread::plistCollectionEntryAdded(), and registerSource().

void plistValueChanged ( const plist::PrimitiveBase pl  )  [virtual]

Implements PrimitiveListener.

Definition at line 188 of file Dynamixel.cc.

Referenced by registerSource().

void processDriverMessage ( const DriverMessaging::Message d  )  [virtual]

Implements Listener.

Definition at line 255 of file Dynamixel.cc.

void provideOutput ( unsigned int  idx  )  [protected]

forwards call to DataSource::providingOutput() if the index is valid

Definition at line 397 of file Dynamixel.h.

Referenced by plistValueChanged(), and registerSource().

void provideValues ( ServoInfo info,
const DynamixelProtocol::AXS1SensorsResponse response 
) [static, protected]

sends AX-S1 sensor values into the framework

TODO: let sndCount be mapped to a button instead of sensor to provide events?

Definition at line 705 of file Dynamixel.cc.

void provideValues ( const ServoInfo info,
const DynamixelProtocol::ServoSensorsResponse response 
) [static, protected]

sends servo feedback values into the framework

Definition at line 666 of file Dynamixel.cc.

Referenced by pingServos(), and CommThread::readResponse().

void registerSource (  )  [virtual]

User hook, called when the data source should claim which outputs it provides feedback (providingOuput()).

Does not indicate the data source should start sending updates yet — wait for enteringRealtime() or advance() to be called

Reimplemented from DataSource.

Definition at line 96 of file Dynamixel.cc.

Referenced by plistValueChanged().

void sendZeroTorqueCmd ( CommPort comm  )  [protected]

broadcasts a "relax" command to all servos

Definition at line 368 of file Dynamixel.cc.

Referenced by motionStopping(), and plistValueChanged().

void updatePIDs ( const std::vector< MotionHook::PIDUpdate > &  pids  )  [virtual]

Called when PID values change.

Reimplemented from MotionHook.

Definition at line 89 of file Dynamixel.cc.

static void writeSyncEntries ( std::ostream &  os,
const std::vector< T > &  entries 
) [static, protected]

sends a series of sync write entries into a stream (adding appropriate header and checksum)

Definition at line 408 of file Dynamixel.h.

Referenced by CommThread::updateCommands().


Member Data Documentation

const std::string autoRegisterDynamixelDriver = DeviceDriver::getRegistry().registerType<DynamixelDriver>("Dynamixel") [static, private]

holds the class name, set via registration with the DeviceDriver registry

Definition at line 424 of file Dynamixel.h.

Referenced by getClassName().

The delay (in MILLIseconds, ms) to get a response from the servos due to buffering in the USB-to-TTL interface.

Definition at line 253 of file Dynamixel.h.

Referenced by deregisterSource(), DynamixelDriver(), CommThread::nextTimestamp(), plistValueChanged(), and registerSource().

plist::Primitive<std::string> commName

Name of the CommPort to use, generally a SerialCommPort with direct binary TTL communication with the servos.

Definition at line 251 of file Dynamixel.h.

Referenced by advance(), deregisterSource(), DynamixelDriver(), isConnected(), motionStarting(), motionStopping(), nextTimestamp(), pingServos(), plistValueChanged(), and registerSource().

std::string lastSensor [protected]

Definition at line 420 of file Dynamixel.h.

Ratio of load to deflection, if non-zero will use LoadPrediction messages and attempt to counter anticipated loads.

Definition at line 252 of file Dynamixel.h.

Referenced by DynamixelDriver(), and CommThread::setServo().

plist::Primitive<unsigned int> numPoll

Number of sensor queries to send before reading responses. This lets us front-load the queries so we can get multiple responses per read buffer flush period.

Definition at line 254 of file Dynamixel.h.

Referenced by deregisterSource(), DynamixelDriver(), plistValueChanged(), registerSource(), and CommThread::runloop().

The amount of time (in MICROseconds, µs) to wait between sending a sensor query and sending another when front-loading the buffer. If this is too short, the next query will collide with the previous response.

Definition at line 255 of file Dynamixel.h.

Referenced by deregisterSource(), DynamixelDriver(), plistValueChanged(), registerSource(), and CommThread::runloop().

Maps servo IDs to Tekkotsu output offsets, use command line new/delete commands to add/remove mappings.

Definition at line 248 of file Dynamixel.h.

Referenced by deregisterSource(), DynamixelDriver(), motionStarting(), pingServos(), plistValueChanged(), processDriverMessage(), registerSource(), and ~DynamixelDriver().

const int START_SERVO_ID = 1 [static]

bioloid kits start the id count at 1

Definition at line 23 of file Dynamixel.h.

Referenced by DynamixelDriver(), pingServos(), and ServoInfo::ServoInfo().

unsigned int TEMP_SENSOR_OFFSET = capabilities.findSensorOffset("PowerThermo") [static, protected]

index of the temperature sensor

Definition at line 259 of file Dynamixel.h.

Referenced by DynamixelDriver(), and provideValues().

const unsigned int UNUSED = plist::OutputSelector::UNUSED [static]

Definition at line 24 of file Dynamixel.h.

Referenced by pingServos(), ServoInfo::ServoInfo(), and CommThread::updateCommands().

unsigned int VOLTAGE_SENSOR_OFFSET = capabilities.findSensorOffset("PowerVoltage") [static, protected]

index of the voltage sensor

Definition at line 258 of file Dynamixel.h.

Referenced by DynamixelDriver(), and provideValues().


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

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Mon May 9 05:01:41 2016 by Doxygen 1.6.3