Homepage Demos Overview Downloads Tutorials Reference
Credits

WorldState Class Reference

#include <WorldState.h>

List of all members.


Detailed Description

The state of the robot and its environment.

Contains sensor readings, current joint positions, etc.
This is a shared memory region between MainObj, MotoObj, and possibly others in the future

Be very careful about including structures that use pointers in this class... they will only be valid from the OObject that created them, others may cause a crash if they try to access them.

WorldState takes power and sensor updates from the system and maintains the last known values in its member fields. It throws events when some of these values change, listed in the ButtonSourceID, SensorSourceID, and PowerSourceID namespaces.

Status events for buttons only generated if the WorldState::alwaysGenerateStatus flag is turned on, otherwise, by default, they are only generated when a value has changed (i.e. when the pressure sensitive buttons get a new pressure reading)

Definition at line 114 of file WorldState.h.

Public Member Functions

 WorldState ()
 constructor - sets everything to zeros

void read (OSensorFrameVectorData &sensor, EventRouter *er)
 will process a sensor reading as given by OPEN-R

void read (const OPowerStatus &power, EventRouter *er)
 will process a power status update as given by OPEN-R


Public Attributes

bool alwaysGenerateStatus
 controls whether status events are generated for the boolean buttons

float outputs [NumOutputs]
 last sensed positions of joints, for ears (or other future "boolean joints"), x<.5 is up, x>=.5 is down; indexes (aka offsets) are defined in the target model's namespace (e.g. ERS210Info)

float buttons [NumButtons]
 magnitude is pressure for some, 0/1 for others; indexes are defined in the ButtonOffset_t of the target model's namespace (e.g. ERS210Info::ButtonOffset_t)

float sensors [NumSensors]
 IR, Accel, Thermo, Power stuff; indexes are defined in SensorOffset_t of the target model's namespace (e.g. ERS210Info::SensorOffset_t).

float pids [NumPIDJoints][3]
 current PID settings (same ordering as the outputs)

float pidduties [NumPIDJoints]
 duty cycles - -1 means the motor is trying to move full power in negative direction, 1 means full power in positive direction, in practice, these values stay rather small - 0.15 is significant force. (same ordering as the outputs)

float vel_x
 the current, egocentric rate of forward locomotion

float vel_y
 the current, egocentric rate of sideways (leftward is positive) locomotion

float vel_a
 the current, egocentric rate of rotational (counterclockwise is positive) locomotion

unsigned int vel_time
 the time at which we began moving along the current velocity vector

unsigned int robotStatus
 bitmask, see OPENR/OPower.h

unsigned int batteryStatus
 bitmask, see OPENR/OPower.h

unsigned int powerFlags [PowerSourceID::NumPowerSIDs]
 bitmasks of similarly-grouped items from previous two masks, corresponds to the PowerSourceID::PowerSourceID_t's

unsigned int button_times [NumButtons]
 value is time of current press, 0 if not down

unsigned int lastSensorUpdateTime
 primarily so calcDers can determine the time difference between updates, but others might want to know this too...

ProfilerOfSize< 20 > mainProfile
 holds code profiling information for MainObject

ProfilerOfSize< 06 > motionProfile
 holds code profiling information for MotionObject

unsigned int robotDesign
 bitmask corresponding to OPENR::GetRobotDesign()


Static Public Attributes

const double g = 9.80665
 the gravitational acceleration of objects on earth

const double IROORDist = 900.0
 If IR returns this, we're out of range.

const unsigned int ERS210Mask = 1<<0
 use this to test for ERS-210 features

const unsigned int ERS220Mask = 1<<1
 use this to test for ERS-220 features

const unsigned int ERS7Mask = 1<<2
 use this to test for ERS-7 features


Protected Member Functions

void chkEvent (EventRouter *er, unsigned int off, float newval, const char *name)
 Tests to see if the button status has changed and post events as needed.

void chkPowerEvent (unsigned int sid, unsigned int cur, unsigned int mask, const char *name, std::string actname[PowerSourceID::NumPowerSIDs], std::string dename[PowerSourceID::NumPowerSIDs], unsigned int summask[PowerSourceID::NumPowerSIDs])
 sets the names of the flags that will be generating events

void calcDers (double next, double &cur, double &vel, double &acc, double invtimediff)
 given the next value, calculates and stores the next current, the velocity, and the acceleration


Protected Attributes

unsigned int curtime
 set by read(OSensorFrameVectorData& sensor, EventRouter* er) for chkEvent() so each call doesn't have to


Private Member Functions

 WorldState (const WorldState &)
 don't use

WorldState operator= (const WorldState &)
 don't use


Constructor & Destructor Documentation

WorldState::WorldState  ) 
 

constructor - sets everything to zeros

Definition at line 28 of file WorldState.cc.

WorldState::WorldState const WorldState  )  [private]
 

don't use


Member Function Documentation

void WorldState::calcDers double  next,
double &  cur,
double &  vel,
double &  acc,
double  invtimediff
[inline, protected]
 

given the next value, calculates and stores the next current, the velocity, and the acceleration

Parameters:
next the new value that's about to be set
cur the previous value
vel the previous 1st derivative
acc the previous 2nd derivative
invtimediff $1/(curtime-prevtime)$ in seconds

Definition at line 192 of file WorldState.h.

void WorldState::chkEvent EventRouter er,
unsigned int  off,
float  newval,
const char *  name
[protected]
 

Tests to see if the button status has changed and post events as needed.

Definition at line 362 of file WorldState.cc.

Referenced by read().

void WorldState::chkPowerEvent unsigned int  sid,
unsigned int  cur,
unsigned int  mask,
const char *  name,
std::string  actname[PowerSourceID::NumPowerSIDs],
std::string  dename[PowerSourceID::NumPowerSIDs],
unsigned int  summask[PowerSourceID::NumPowerSIDs]
[inline, protected]
 

sets the names of the flags that will be generating events

note that this function does not actually do the event posting, unlike chkEvent()

Definition at line 175 of file WorldState.h.

Referenced by read().

WorldState WorldState::operator= const WorldState  )  [private]
 

don't use

void WorldState::read const OPowerStatus &  power,
EventRouter er
 

will process a power status update as given by OPEN-R

This will cause events to be posted

Definition at line 287 of file WorldState.cc.

void WorldState::read OSensorFrameVectorData &  sensor,
EventRouter er
 

will process a sensor reading as given by OPEN-R

This will cause events to be posted

Todo:
change to use most recent instead of oldest - is a buffer!

Definition at line 71 of file WorldState.cc.

Referenced by MMCombo::DoStart(), MMCombo::GotPowerEvent(), and MMCombo::GotSensorFrame().


Member Data Documentation

bool WorldState::alwaysGenerateStatus
 

controls whether status events are generated for the boolean buttons

Definition at line 119 of file WorldState.h.

Referenced by chkEvent().

unsigned int WorldState::batteryStatus
 

bitmask, see OPENR/OPower.h

Definition at line 133 of file WorldState.h.

unsigned int WorldState::button_times[NumButtons]
 

value is time of current press, 0 if not down

Definition at line 136 of file WorldState.h.

Referenced by chkEvent(), EmergencyStopMC::trigger(), and WorldState().

float WorldState::buttons[NumButtons]
 

magnitude is pressure for some, 0/1 for others; indexes are defined in the ButtonOffset_t of the target model's namespace (e.g. ERS210Info::ButtonOffset_t)

Definition at line 122 of file WorldState.h.

Referenced by chkEvent(), SoundTestBehavior::play(), WorldStateSerializerBehavior::processEvent(), SensorObserverControl::processEvent(), AlanBehavior::processEvent(), Controller::trapEvent(), and WorldState().

unsigned int WorldState::curtime [protected]
 

set by read(OSensorFrameVectorData& sensor, EventRouter* er) for chkEvent() so each call doesn't have to

Definition at line 167 of file WorldState.h.

Referenced by chkEvent(), and read().

const unsigned int WorldState::ERS210Mask = 1<<0 [static]
 

use this to test for ERS-210 features

Definition at line 162 of file WorldState.h.

Referenced by read(), and WorldState().

const unsigned int WorldState::ERS220Mask = 1<<1 [static]
 

use this to test for ERS-220 features

Definition at line 163 of file WorldState.h.

Referenced by read(), and WorldState().

const unsigned int WorldState::ERS7Mask = 1<<2 [static]
 

use this to test for ERS-7 features

Definition at line 164 of file WorldState.h.

Referenced by read(), and WorldState().

const double WorldState::g = 9.80665 [static]
 

the gravitational acceleration of objects on earth

Definition at line 23 of file WorldState.cc.

const double WorldState::IROORDist = 900.0 [static]
 

If IR returns this, we're out of range.

Definition at line 24 of file WorldState.cc.

unsigned int WorldState::lastSensorUpdateTime
 

primarily so calcDers can determine the time difference between updates, but others might want to know this too...

Definition at line 138 of file WorldState.h.

Referenced by WorldStateSerializerBehavior::processEvent(), SensorObserverControl::processEvent(), and read().

ProfilerOfSize<20> WorldState::mainProfile
 

holds code profiling information for MainObject

Definition at line 143 of file WorldState.h.

Referenced by ProfilerCheckControl::activate(), SegmentedColorGenerator::calcImage(), RLEGenerator::calcImage(), RegionGenerator::calcImage(), RawCameraGenerator::calcImage(), JPEGGenerator::calcImage(), InterleavedYUVGenerator::calcImage(), CDTGenerator::calcImage(), MMCombo::GotImage(), MMCombo::GotPowerEvent(), MMCombo::GotSensorFrame(), BallDetectionGenerator::processEvent(), and MMCombo::ReadySendJoints().

ProfilerOfSize<06> WorldState::motionProfile
 

holds code profiling information for MotionObject

Definition at line 144 of file WorldState.h.

Referenced by ProfilerCheckControl::activate(), and MMCombo::ReadySendJoints().

float WorldState::outputs[NumOutputs]
 

last sensed positions of joints, for ears (or other future "boolean joints"), x<.5 is up, x>=.5 is down; indexes (aka offsets) are defined in the target model's namespace (e.g. ERS210Info)

Definition at line 121 of file WorldState.h.

Referenced by HeadPointerMC::convFromBodyRelative(), HeadPointerMC::convToBodyRelative(), HeadLevelBehavior::DoStart(), Aibo3DControllerBehavior::DoStart(), MotionManager::getOutputs(), HeadPointerMC::HeadPointerMC(), WorldStateSerializerBehavior::processEvent(), WalkToTargetMachine::processEvent(), StareAtBallBehavior::processEvent(), SimpleChaseBallBehavior::processEvent(), SensorObserverControl::processEvent(), HeadLevelBehavior::processEvent(), FollowHeadBehavior::processEvent(), ChaseBallBehavior::processEvent(), read(), MMCombo::ReadySendJoints(), WalkMC::resetLegPos(), MotionSequence::resume(), BatteryMonitorBehavior::setFlipper(), PostureEngine::takeSnapshot(), EmergencyStopMC::takeSnapshot(), EmergencyStopMC::updateOutputs(), MotionManager::updateWorldState(), and WorldState().

float WorldState::pidduties[NumPIDJoints]
 

duty cycles - -1 means the motor is trying to move full power in negative direction, 1 means full power in positive direction, in practice, these values stay rather small - 0.15 is significant force. (same ordering as the outputs)

Definition at line 125 of file WorldState.h.

Referenced by WorldStateSerializerBehavior::processEvent(), SensorObserverControl::processEvent(), read(), BanditMachine::setup(), EmergencyStopMC::updateOutputs(), and WorldState().

float WorldState::pids[NumPIDJoints][3]
 

current PID settings (same ordering as the outputs)

Definition at line 124 of file WorldState.h.

Referenced by MotionManager::getOutputs(), WorldStateSerializerBehavior::processEvent(), MotionManager::setPID(), MotionManager::updatePIDs(), and WorldState().

unsigned int WorldState::powerFlags[PowerSourceID::NumPowerSIDs]
 

bitmasks of similarly-grouped items from previous two masks, corresponds to the PowerSourceID::PowerSourceID_t's

Definition at line 134 of file WorldState.h.

Referenced by chkPowerEvent(), MMCombo::GotPowerEvent(), read(), BatteryCheckControl::report(), BatteryMonitorBehavior::shouldWarn(), and WorldState().

unsigned int WorldState::robotDesign
 

bitmask corresponding to OPENR::GetRobotDesign()

This allows you to efficiently test different combinations, like any 2x0 model vs. any 7 model or any 3xx model (when/if the 3xx's are supported).

Testing this will give more accurate feedback as to whether features exist than checking RobotInfo values - to achieve dual booting, RobotInfo may, for instance, tell you there are two ears, but if you're running on a 220 the value you set them to will be ignored

Definition at line 161 of file WorldState.h.

Referenced by HeadPointerMC::convFromBodyRelative(), HeadPointerMC::convToBodyRelative(), LedEngine::displayNumber(), ToggleHeadLightBehavior::DoStart(), StartupBehavior::DoStart(), CameraBehavior::DoStart(), EmergencyStopMC::EmergencyStopMC(), EmergencyStopMC::freezeJoints(), HeadLevelBehavior::HeadLevelBehavior(), Controller::init(), ValueEditControl< T >::pause(), VisualTargetCloseTrans::processEvent(), ValueEditControl< T >::processEvent(), StartupBehavior::processEvent(), AlanBehavior::processEvent(), read(), MMCombo::ReadySendJoints(), EmergencyStopMC::releaseJoints(), BatteryMonitorBehavior::setFlipper(), ExploreMachine::setup(), StartupBehavior::SetupBackgroundBehaviors(), StartupBehavior::SetupModeSwitch(), SoundTestBehavior::SoundTestBehavior(), EmergencyStopMC::trigger(), TailWagMC::updateOutputs(), EmergencyStopMC::updateOutputs(), MotionManager::updateWorldState(), and WorldState().

unsigned int WorldState::robotStatus
 

bitmask, see OPENR/OPower.h

Definition at line 132 of file WorldState.h.

float WorldState::sensors[NumSensors]
 

IR, Accel, Thermo, Power stuff; indexes are defined in SensorOffset_t of the target model's namespace (e.g. ERS210Info::SensorOffset_t).

Definition at line 123 of file WorldState.h.

Referenced by BatteryMonitorBehavior::calcFlipDelay(), HeadPointerMC::convFromBodyRelative(), HeadPointerMC::convToBodyRelative(), WorldStateSerializerBehavior::processEvent(), VisualTargetCloseTrans::processEvent(), SensorObserverControl::processEvent(), BatteryMonitorBehavior::processEvent(), AutoGetupBehavior::processEvent(), read(), BatteryCheckControl::refresh(), BatteryCheckControl::report(), ExploreMachine::setup(), BatteryMonitorBehavior::shouldWarn(), BatteryMonitorBehavior::startWarning(), and WorldState().

float WorldState::vel_a
 

the current, egocentric rate of rotational (counterclockwise is positive) locomotion

Definition at line 129 of file WorldState.h.

Referenced by WalkCalibration::setupMoving(), and WorldStateVelDaemon::trapEvent().

unsigned int WorldState::vel_time
 

the time at which we began moving along the current velocity vector

Definition at line 130 of file WorldState.h.

Referenced by WorldStateVelDaemon::processEvent(), and WorldStateVelDaemon::trapEvent().

float WorldState::vel_x
 

the current, egocentric rate of forward locomotion

Definition at line 127 of file WorldState.h.

Referenced by WalkCalibration::setupMoving(), and WorldStateVelDaemon::trapEvent().

float WorldState::vel_y
 

the current, egocentric rate of sideways (leftward is positive) locomotion

Definition at line 128 of file WorldState.h.

Referenced by WalkCalibration::setupMoving(), and WorldStateVelDaemon::trapEvent().


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

Tekkotsu v2.1
Generated Tue Mar 16 23:22:33 2004 by Doxygen 1.3.5