Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SSC32Driver Class Reference

#include <SSC32Driver.h>

Inheritance diagram for SSC32Driver:

List of all members.


Detailed Description

description of SSC32Driver

Definition at line 13 of file SSC32Driver.h.


Public Member Functions

 SSC32Driver (const std::string &name)
virtual ~SSC32Driver ()
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 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
virtual unsigned int getData (const char *&payload, unsigned int &payloadSize, unsigned int &timestamp, std::string &name)
 called to retrieve the most recent data segment, or blocking until new data is available
virtual void setDataSourceThread (LoadDataThread *th)
 called by the LoadDataThread subclass, allows you to register for properties which your subclass may care about
virtual void plistValueChanged (const plist::PrimitiveBase &pl)

Public Attributes

plist::ArrayOf
< plist::Primitive< int > > 
servos
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< bool > sparse
plist::Primitive< std::string > commName
plist::Primitive< bool > queryServos

Static Public Attributes

static const unsigned int NUM_SERVO = 32
static const unsigned int NUM_INPUT = 4
static const int UNUSED = -1

Protected Member Functions

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)

Protected Attributes

bool motionActive
bool sensorsActive
std::string lastSensor
unsigned int frameNumber

Static Private Attributes

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

Constructor & Destructor Documentation

SSC32Driver ( const std::string &  name  )  [inline, explicit]

Definition at line 19 of file SSC32Driver.h.

virtual ~SSC32Driver (  )  [inline, virtual]

Definition at line 38 of file SSC32Driver.h.


Member Function Documentation

virtual std::string getClassName (  )  const [inline, 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 40 of file SSC32Driver.h.

Referenced by plistValueChanged().

virtual MotionHook* getMotionSink (  )  [inline, virtual]

Reimplemented from DeviceDriver.

Definition at line 42 of file SSC32Driver.h.

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

Reimplemented from DeviceDriver.

Definition at line 43 of file SSC32Driver.h.

void motionStarting (  )  [virtual]

Called when motion process is starting.

Reimplemented from MotionHook.

Definition at line 12 of file SSC32Driver.cc.

void motionStopping (  )  [virtual]

Called when motion process is stopping.

Reimplemented from MotionHook.

Definition at line 21 of file SSC32Driver.cc.

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 31 of file SSC32Driver.cc.

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

See also:
timestamp argument of getData()

Implements DataSource.

Definition at line 78 of file SSC32Driver.cc.

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

returns a descriptive name of the next data segment for user feedback

See also:
name argument of getData()

Implements DataSource.

Definition at line 53 of file SSC32Driver.h.

Referenced by getData().

unsigned int getData ( const char *&  payload,
unsigned int &  payloadSize,
unsigned int &  timestamp,
std::string &  name 
) [virtual]

called to retrieve the most recent data segment, or blocking until new data is available

Parameters:
[out] payload on return, should point to beginning of data segment, or NULL if none available
[out] payloadSize on return, should indicate size in bytes of data segment as payload
[in] timestamp the suggested return time; if multiple samples may be taken in the interval, they should be skipped until this time
[out] timestamp on return, should contain the time at which the data arrived (real time stream) or was scheduled to be sent (log on disk)
[out] name on return, a human-readable name for the frame -- e.g. filename for a data file loaded from disk
Returns:
frame serial number, used to tell when frames from the data source have been dropped (indicated by the return value incrementing by more than one)
If no more data is available, set payload to NULL, and return the current frame (i.e. don't increment serial number).

This call should block until data is available. Other functions may be called asynchronously from other threads while in this function, see ThreadNS::Lock to implement mutual exclusion locks if needed.

The input value of timestamp is a suggestion from the user's requested framerate -- try to return the frame closest to it. If it is already past (e.g. 0 on 'advance'), return the current data! If you return a timestamp in the future, the LoadDataThread will sleep until the appropriate time.

Note that this can be called when the source is frozen, which means you should unfreeze, get the current (unread) data or block until the next data, freeze again, and return the data.

Implements DataSource.

Definition at line 85 of file SSC32Driver.cc.

void setDataSourceThread ( LoadDataThread th  )  [virtual]

called by the LoadDataThread subclass, allows you to register for properties which your subclass may care about

a pointer to the LoadDataThread is passed when this is becoming the current data source; NULL will be passed when the data source is no longer being used

Reimplemented from DataSource.

Definition at line 208 of file SSC32Driver.cc.

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

Implements PrimitiveListener.

Definition at line 241 of file SSC32Driver.cc.

void provideOutput ( unsigned int  idx  )  [inline, protected]

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

Definition at line 70 of file SSC32Driver.h.

Referenced by plistValueChanged(), and setDataSourceThread().

void ignoreOutput ( unsigned int  idx  )  [inline, protected]

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

Definition at line 72 of file SSC32Driver.h.

Referenced by plistValueChanged(), and setDataSourceThread().

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

Definition at line 289 of file SSC32Driver.cc.

Referenced by motionCheck().

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

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

Definition at line 313 of file SSC32Driver.cc.

Referenced by getData().

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

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

Definition at line 323 of file SSC32Driver.cc.

Referenced by getData().

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)

Definition at line 327 of file SSC32Driver.cc.

Referenced by getData().


Member Data Documentation

const unsigned int NUM_SERVO = 32 [static]

const unsigned int NUM_INPUT = 4 [static]

Definition at line 16 of file SSC32Driver.h.

Referenced by getData(), and SSC32Driver().

const int UNUSED = -1 [static]

Definition at line 17 of file SSC32Driver.h.

Referenced by getData(), and motionCheck().

Definition at line 60 of file SSC32Driver.h.

Referenced by getData(), and SSC32Driver().

Definition at line 61 of file SSC32Driver.h.

Referenced by getServo(), setServo(), and SSC32Driver().

Definition at line 62 of file SSC32Driver.h.

Referenced by getServo(), setServo(), and SSC32Driver().

Definition at line 63 of file SSC32Driver.h.

Referenced by getData(), and SSC32Driver().

Definition at line 64 of file SSC32Driver.h.

Referenced by motionCheck(), and SSC32Driver().

bool motionActive [protected]

bool sensorsActive [protected]

Definition at line 84 of file SSC32Driver.h.

Referenced by motionStopping(), plistValueChanged(), and setDataSourceThread().

std::string lastSensor [protected]

Definition at line 85 of file SSC32Driver.h.

Referenced by getData().

unsigned int frameNumber [protected]

Definition at line 86 of file SSC32Driver.h.

Referenced by getData().

const std::string autoRegisterSSC32Driver = DeviceDriver::getRegistry().registerType<SSC32Driver>("SSC32") [static, private]

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

Definition at line 90 of file SSC32Driver.h.

Referenced by getClassName().


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

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:01:24 2007 by Doxygen 1.5.4