Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SkewlZoneDriver Class Reference

description of SkewlZoneDriver More...

#include <SkewlZoneDriver.h>

Inheritance diagram for SkewlZoneDriver:

Detailed Description

description of SkewlZoneDriver

Definition at line 64 of file SkewlZoneDriver.h.

List of all members.

Public Member Functions

 SkewlZoneDriver (const std::string &name)
virtual ~SkewlZoneDriver ()
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 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 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 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 simplePrintVec (const char *sPrefix, double fBuf[], size_t uCount)
virtual int createSZclient ()
virtual int connectSZserver ()
virtual int openRCB3 ()
virtual void attachRCB3 ()
virtual int RCB3EStop ()
virtual int convertIndex (int index)
virtual int indexInverted (int index)
virtual void setSZunits ()
virtual void printServos ()
virtual void initMotorVec ()

Public Attributes

BsLibClient_P pClient
int h
BsBotMotorPosVec_T vecMotorPos
BsBotMotorSpeedPosVec_T vecMotorMove
int index
int rc
plist::Primitive< std::string > serialPath
plist::ArrayOf
< plist::OutputSelector
servos
 TODO this should replace commName (see where commName is used to allow runtime reconfiguration).
plist::ArrayOf
< plist::Primitive< int > > 
inputs
plist::ArrayOf
< plist::Primitive< unsigned
int > > 
minPW
plist::ArrayOf
< plist::Primitive< unsigned
int > > 
maxPW
plist::ArrayOf
< plist::Primitive< bool > > 
buttonMode
plist::Primitive< boolsparse
plist::Primitive< std::string > commName
 TODO this should be replaced by serialPath.
plist::Primitive< boolqueryServos
 TODO this might not make sense for this driver?

Static Public Attributes

static const unsigned int NUM_SERVO = NumOutputs
static const unsigned int NUM_INPUT = NumSensors
static const 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
virtual void setServo (std::ostream &ss, unsigned int servoIdx, float v)
 converts the value v from radians into the specified servo's pulse width range
virtual float getServo (unsigned int servoIdx, unsigned int pw)
 converts the value pw from specified servo's pulse width range into radians
virtual float getAnalog (unsigned int inputIdx, unsigned char s)
 converts the value s from specified input's signal to voltage
virtual float getDigital (unsigned int inputIdx, unsigned char cur, unsigned char latch)
 converts the value cur and latch to the output format (0 if low, 0.5 if high but has been low, 1 if consistent high)
float angleCalibration (unsigned int servoIdx, int mode, float v)

Protected Attributes

CallbackPollThread poller
bool motionActive
bool sensorsActive
unsigned int lastSensorTime
unsigned int frameNumber

Static Private Attributes

static const std::string autoRegisterSkewlZoneDriver
 holds the class name, set via registration with the DeviceDriver registry

Constructor & Destructor Documentation

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

Definition at line 84 of file SkewlZoneDriver.h.

virtual ~SkewlZoneDriver (  )  [virtual]

Definition at line 145 of file SkewlZoneDriver.h.


Member Function Documentation

virtual 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.

float angleCalibration ( unsigned int  servoIdx,
int  mode,
float  v 
) [protected]
virtual void attachRCB3 (  )  [virtual]

Referenced by SkewlZoneDriver().

virtual int connectSZserver (  )  [virtual]

Referenced by SkewlZoneDriver().

virtual int convertIndex ( int  index  )  [virtual]
virtual int createSZclient (  )  [virtual]

Referenced by SkewlZoneDriver().

virtual 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.

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.

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.

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 164 of file SkewlZoneDriver.h.

virtual float getAnalog ( unsigned int  inputIdx,
unsigned char  s 
) [protected, virtual]

converts the value s from specified input's signal to voltage

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 147 of file SkewlZoneDriver.h.

virtual float getDigital ( unsigned int  inputIdx,
unsigned char  cur,
unsigned char  latch 
) [protected, virtual]

converts the value cur and latch to the output format (0 if low, 0.5 if high but has been low, 1 if consistent high)

virtual MotionHook* getMotionSink (  )  [virtual]

Reimplemented from DeviceDriver.

Definition at line 149 of file SkewlZoneDriver.h.

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

Reimplemented from DeviceDriver.

Definition at line 150 of file SkewlZoneDriver.h.

virtual float getServo ( unsigned int  servoIdx,
unsigned int  pw 
) [protected, virtual]

converts the value pw from specified servo's pulse width range into radians

void ignoreOutput ( unsigned int  idx  )  [protected]

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

Definition at line 217 of file SkewlZoneDriver.h.

virtual int indexInverted ( int  index  )  [virtual]
virtual void initMotorVec (  )  [virtual]

Referenced by SkewlZoneDriver().

virtual 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.

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 165 of file SkewlZoneDriver.h.

virtual 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.

virtual void motionStarting (  )  [virtual]

Called when motion process is starting.

Reimplemented from MotionHook.

virtual void motionStopping (  )  [virtual]

Called when motion process is stopping.

Reimplemented from MotionHook.

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 161 of file SkewlZoneDriver.h.

virtual 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.

virtual int openRCB3 (  )  [virtual]

Referenced by SkewlZoneDriver().

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

Implements PrimitiveListener.

virtual void printServos (  )  [virtual]

Referenced by SkewlZoneDriver().

void provideOutput ( unsigned int  idx  )  [protected]

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

Definition at line 215 of file SkewlZoneDriver.h.

virtual int RCB3EStop (  )  [virtual]

Referenced by SkewlZoneDriver().

virtual 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.

virtual void setServo ( std::ostream &  ss,
unsigned int  servoIdx,
float  v 
) [protected, virtual]

converts the value v from radians into the specified servo's pulse width range

virtual void setSZunits (  )  [virtual]

Referenced by SkewlZoneDriver().

virtual void simplePrintVec ( const char *  sPrefix,
double  fBuf[],
size_t  uCount 
) [virtual]

Member Data Documentation

const std::string autoRegisterSkewlZoneDriver [static, private]

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

Definition at line 240 of file SkewlZoneDriver.h.

Referenced by getClassName().

Definition at line 175 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

plist::Primitive<std::string> commName

TODO this should be replaced by serialPath.

Definition at line 177 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

unsigned int frameNumber [protected]

Definition at line 236 of file SkewlZoneDriver.h.

int h

Definition at line 74 of file SkewlZoneDriver.h.

int index

Definition at line 77 of file SkewlZoneDriver.h.

Definition at line 172 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

unsigned int lastSensorTime [protected]

Definition at line 235 of file SkewlZoneDriver.h.

Definition at line 174 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

Definition at line 173 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

bool motionActive [protected]

Definition at line 233 of file SkewlZoneDriver.h.

const unsigned int NUM_INPUT = NumSensors [static]

Definition at line 67 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

const unsigned int NUM_SERVO = NumOutputs [static]

Definition at line 66 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

BsLibClient_P pClient

Definition at line 73 of file SkewlZoneDriver.h.

Definition at line 230 of file SkewlZoneDriver.h.

TODO this might not make sense for this driver?

Definition at line 178 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

int rc

Definition at line 78 of file SkewlZoneDriver.h.

bool sensorsActive [protected]

Definition at line 234 of file SkewlZoneDriver.h.

Definition at line 170 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

TODO this should replace commName (see where commName is used to allow runtime reconfiguration).

Definition at line 171 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

Definition at line 176 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

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

Definition at line 68 of file SkewlZoneDriver.h.

BsBotMotorSpeedPosVec_T vecMotorMove

Definition at line 76 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().

BsBotMotorPosVec_T vecMotorPos

Definition at line 75 of file SkewlZoneDriver.h.

Referenced by SkewlZoneDriver().


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

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