Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SensorState Struct Reference

A global instance of this structure is registered via DataSource::setSensorState() during launch, so that DataSources know where to put their results. More...

#include <DataSource.h>

Inheritance diagram for SensorState:

Detailed Description

A global instance of this structure is registered via DataSource::setSensorState() during launch, so that DataSources know where to put their results.

Subclasses of DataSource don't access this structure directly, they should call the static DataSource functions to write its fields. Image based data sources like cameras will send raw buffers of data via DataSource::setImage, ignoring this structure.

Definition at line 221 of file DataSource.h.

List of all members.

Public Member Functions

 SensorState ()
 constructor
bool hasProvidedOutput () const
 returns true if any of providedOutputs is greater than zero
bool hasUnprovidedOutput () const
 returns true if any of providedOutputs is zero

Public Attributes

unsigned int providedOutputs [NumOutputs]
 Counts the number of sensor data sources which are providing readings for each output.
float outputs [NumOutputs]
 maps to WorldState::outputs, assign via DataSource::setOutputValue
float buttons [NumButtons]
 maps to WorldState::buttons, assign via DataSource::setButtonValue
float sensors [NumSensors]
 maps to WorldState::sensors, assign via DataSource::setSensorValue
float pids [NumPIDJoints][3]
 maps to WorldState::pids, only assigned via MotionExecThread
float pidduties [NumPIDJoints]
 maps to WorldState::pidduties, assign via DataSource::setPIDDutyValue
unsigned int timestamp
 simulator time of last update to one of the value arrays
unsigned int frameNumber
 Serial number for the update, incremented each time Simulator sends an update notification.
bool dirty
 this flag should be set when any of the fields are updated, cleared when releaseResource is called (when timestamp is set instead)
plist::Primitive< bool > * motionOverride
 This may be set to point to the Motion.OverrideSensors configuration setting, causing sensor updates for outputs to be ignored (forcing open loop).
void(* resourceSync )()
 a function to be called whenever releaseResource() is called and dirty flag is set; called at the end once the resource is immediately available

Protected Member Functions

virtual void useResource (Data &d)
virtual void releaseResource (Data &d)

Protected Attributes

Thread::Lock lock
 lock to prevent concurrent access to the structure, but should use the SensorState with MarkScope to set the dirty flag on unlock

Private Member Functions

 SensorState (const SensorState &)
 don't call
SensorStateoperator= (const SensorState &)
 don't call

Constructor & Destructor Documentation

SensorState (  ) 

constructor

Definition at line 12 of file DataSource.cc.

SensorState ( const SensorState  )  [private]

don't call


Member Function Documentation

bool hasProvidedOutput (  )  const

returns true if any of providedOutputs is greater than zero

Definition at line 226 of file DataSource.h.

bool hasUnprovidedOutput (  )  const

returns true if any of providedOutputs is zero

Definition at line 228 of file DataSource.h.

Referenced by MotionExecThread::applyPostureFeedback().

SensorState& operator= ( const SensorState  )  [private]

don't call

void releaseResource ( Data d  )  [protected, virtual]

Implements Resource.

Definition at line 25 of file DataSource.cc.

virtual void useResource ( Data d  )  [protected, virtual]

Implements Resource.

Definition at line 266 of file DataSource.h.


Member Data Documentation

this flag should be set when any of the fields are updated, cleared when releaseResource is called (when timestamp is set instead)

Definition at line 253 of file DataSource.h.

Referenced by releaseResource(), Simulator::sendSensor(), DataSource::setButtonValue(), DataSource::setOutputValue(), DataSource::setPIDDutyValue(), and DataSource::setSensorValue().

unsigned int frameNumber

Serial number for the update, incremented each time Simulator sends an update notification.

This is not incremented for each DataSource modification because there might be multiple data sources, or a data source might make multiple partial updates within each Simulator frame.

Definition at line 250 of file DataSource.h.

Referenced by DataSource::getSensorFrameNumber(), Main::gotSensors(), and Simulator::sendSensor().

Thread::Lock lock [protected]

lock to prevent concurrent access to the structure, but should use the SensorState with MarkScope to set the dirty flag on unlock

Definition at line 272 of file DataSource.h.

Referenced by releaseResource(), and useResource().

This may be set to point to the Motion.OverrideSensors configuration setting, causing sensor updates for outputs to be ignored (forcing open loop).

This is useful if loading sensor data from log, where we want to compute new output positions in simulation, but using the "pure" sensors for input

Definition at line 257 of file DataSource.h.

Referenced by DataSource::setOutputValue(), and SharedGlobals::SharedGlobals().

float pids[NumPIDJoints][3]

maps to WorldState::pids, only assigned via MotionExecThread

Definition at line 242 of file DataSource.h.

Referenced by MotionExecThread::poll(), and SensorState().

unsigned int providedOutputs[NumOutputs]

Counts the number of sensor data sources which are providing readings for each output.

This isn't a configuration setting per se, but needed so motion process can tell if it should provide feedback for each output. If an output doesn't have any sensor feedback (or override is true), then motion should provide feedback. If more than one sensor is providing the same output, that could be a problem, but not dealt with here.

The simulator's initialization routines will pass this to DataSource::setOutputTracker().

Definition at line 237 of file DataSource.h.

Referenced by MotionExecThread::applyPostureFeedback(), Simulator::cmdStatus(), hasUnprovidedOutput(), DataSource::ignoringOutput(), DataSource::providingOutput(), and SensorState().

void(* resourceSync)()

a function to be called whenever releaseResource() is called and dirty flag is set; called at the end once the resource is immediately available

Definition at line 263 of file DataSource.h.

Referenced by releaseResource(), Simulator::setMotionEnteringRealtime(), Simulator::setMotionLeavingRealtime(), and Simulator::~Simulator().

unsigned int timestamp

simulator time of last update to one of the value arrays

Definition at line 245 of file DataSource.h.

Referenced by releaseResource(), and Simulator::sendSensor().


The documentation for this struct 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