Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

BehaviorBase Class Reference

The basis from which all other Behaviors should inherit. More...

#include <BehaviorBase.h>

Inheritance diagram for BehaviorBase:

Detailed Description

The basis from which all other Behaviors should inherit.

For complex behaviors, it may be helpful to break aspects of the behaviors into independent 'states', and use a state machine formalism to control them. See StateNode and Transition for more information.

Quick-start boilerplate is included in the distribution: project/templates/behavior.h:

Tutorials:

start() and stop() are control functions to trigger the appropriate state change in the behavior. preStart(), doStart(), and postStart() are hooks to notify subclasses in order to enact this change. Thus, subclasses should override one (or more) of the latter 3 functions, and users should call the main start() / stop() methods to (de)activate the behavior, not the hooks.

Also, if you instantiate a behavior on the stack instead of the heap (this is very rarely done), remember to call setAutoDelete(false) (provided from the ReferenceCounter base class) — don't want it to try to free memory on the stack when the behavior is stopped! (The stack limits the allocation of the behavior to the current scope, which overrides the reference counting.)

Don't forget to include a call to the REGISTER_BEHAVIOR macro so that your behavior will be inserted into the menu system!

Definition at line 54 of file BehaviorBase.h.

List of all members.

Classes

class  MonitorMotion
 An instance is created for each motion activated through addMotion(), listening in case the motion is removed by some other means, thus invalidating the MC_ID. More...

Public Member Functions

virtual ~BehaviorBase ()
 destructor - if is active when deleted, will display a warning (don't delete directly - use removeReference())
virtual void start ()
 Calling this signals that the behavior should start running. It will increment the reference counter, add to the registry, and call the subclass hooks (preStart() / doStart() postStart() ).
virtual void stop ()
 Calling this signals the behavior to stop running. In turn, this calls doStop(), then removes the behavior from the registry and subtracts from the reference counter Ñ thus may delete the object if no other references remain.
virtual void processEvent (const EventBase &curEvent)
 Assigns curEvent to event and calls to doEvent() for user processing.
virtual std::string getName () const
 Identifies the behavior in menus and such.
virtual void setName (const std::string &name)
 Allows dynamic renaming of behaviors.
virtual std::string getDescription () const
 Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).
virtual std::string getClassName () const
 Returns the name of the class of this behavior (aka its type) using typeid and gcc's demangle.
virtual bool isActive () const
 Returns true if the behavior is currently running.

Static Public Member Functions

static std::string getClassDescription ()
 Gives a short description of what this class of behaviors does... you should override this (but don't have to).
static const std::set
< BehaviorBase * > & 
getRegistry ()
 This read-only set allows us list all the currently instantiated behaviors.
template<class T >
static BehaviorSwitchControlBaseregisterControllerEntry (const std::string &name, const std::string &menu, int flags=BEH_DEFAULTS)
 Registers a behavior class to be added to the specified Controller menu, use '/' to specify sub-menus, see REGISTER_BEHAVIOR macro.
static std::string humanifyClassName (const std::string &name)
 A simple utility call for REGISTER_BEHAVIOR and friends to remove trailing "Behavior" suffix from display names and fix CamelCase. Disabled because it interferes with the Storyboard and other components; should be re-implemented inside ControllerGUI.

Protected Types

enum  Prunability_t { PERSISTENT, PRUNABLE }
 

Specifies parameters for addMotion().

More...
typedef MotionManagerMsg::MC_ID MC_ID
 Typically would use MotionManager::MC_ID, but re-specified here for convenience and to avoid dependence on MotionManager.h.

Protected Member Functions

virtual void preStart ()
 Called by start() before the doStart(), allows superclasses to do some initialization startup preceeding subclass customization.
virtual void doStart ()
 Delegate function for subclasses to be notified when the behavior starts up.
virtual void postStart ()
 Called by start() after the doStart(), allows superclasses to complete initialization.
virtual void doStop ()
 Delegate function for subclasses to be notified when the behavior starts up.
virtual void doEvent ()
 Delegate function for event processing, the event itself is pointed to (only for the duration of the doEvent() call!) by event.
virtual MC_ID addMotion (const SharedObjectBase &mc, Prunability_t prune=PERSISTENT)
 Registers the MotionCommand (contained within a shared memory region) with the MotionManager, and allows the behavior to track active motions so they can be automatically removed on stop().
virtual MC_ID addMotion (const SharedObjectBase &mc, Prunability_t prune, float priority)
 Registers the MotionCommand (contained within a shared memory region) with the MotionManager, and allows the behavior to track active motions so they can be automatically removed on stop().
virtual void removeMotion (MC_ID mcid)
 Removes the motion from the MotionManager.
template<template< typename T > class M, class T >
void removeMotion (const M< T > &mc)
 forwarding function so you can pass SharedObject<T> or MotionPtr<T> directly; extracts the MC_ID and passes to the other removeMotion
 BehaviorBase ()
 constructor, will use getClassName() as the instance name
 BehaviorBase (const std::string &name)
 constructor, name is used as both instance name and class name
 BehaviorBase (const BehaviorBase &b)
 copy constructor; assumes subclass handles copying approriately - i.e. if b is active, the copy will be as well, even though doStart was never called..
BehaviorBaseoperator= (const BehaviorBase &b)
 assignment operator; assumes subclass handles assignment appropriately - i.e. if b is active, the copy will be as well, even though doStart was never called..

Static Protected Member Functions

static std::set< BehaviorBase * > & getRegistryInstance ()
 static function to provide well-defined initialization order

Protected Attributes

std::map< MC_ID, MonitorMotionautoMotions
 A list of active motions registered with this behavior to be removed when the behavior stops.
bool started
 true when the behavior is active
std::string instanceName
 holds the name of this instance of behavior, if empty then getName() forwards to getClassName()
const EventBaseevent
 the event, received by processEvent, stored for duration of call to doEvent() (also doStart() in the case of a StateNode receiving a transition), NULL at all other times

Static Protected Attributes

static const MC_ID invalid_MC_ID = MotionManagerMsg::invalid_MC_ID
 Typically would use MotionManager::invalid_MC_ID, but re-specified here for convenience and to avoid dependence on MotionManager.h.

Private Member Functions

virtual void DoStart (struct __USE_doStart_NOT_DoStart__ &)
 temporary to produce warnings to help people update
virtual void DoStop (struct __USE_doStart_NOT_DoStart__ &)
 temporary to produce warnings to help people update

Member Typedef Documentation

Typically would use MotionManager::MC_ID, but re-specified here for convenience and to avoid dependence on MotionManager.h.

Definition at line 123 of file BehaviorBase.h.


Member Enumeration Documentation

enum BehaviorBase::Prunability_t [protected]

Specifies parameters for addMotion().

Enumerator:
PERSISTENT 

The motion will not be removed until forced to do so by behavior ending or a call to removeMotion().

PRUNABLE 

The motion can remove itself once it is "complete", which varies motion to motion. Some may never "end", making this equivalent to PERSISTENT in those cases.

Definition at line 158 of file BehaviorBase.h.


Constructor & Destructor Documentation

BehaviorBase::~BehaviorBase (  )  [virtual]

destructor - if is active when deleted, will display a warning (don't delete directly - use removeReference())

Definition at line 35 of file BehaviorBase.cc.

BehaviorBase::BehaviorBase (  )  [protected]

constructor, will use getClassName() as the instance name

Definition at line 8 of file BehaviorBase.cc.

BehaviorBase::BehaviorBase ( const std::string &  name  )  [explicit, protected]

constructor, name is used as both instance name and class name

Definition at line 14 of file BehaviorBase.cc.

BehaviorBase::BehaviorBase ( const BehaviorBase b  )  [protected]

copy constructor; assumes subclass handles copying approriately - i.e. if b is active, the copy will be as well, even though doStart was never called..

Definition at line 20 of file BehaviorBase.cc.


Member Function Documentation

BehaviorBase::MC_ID BehaviorBase::addMotion ( const SharedObjectBase mc,
Prunability_t  prune,
float  priority 
) [protected, virtual]

Registers the MotionCommand (contained within a shared memory region) with the MotionManager, and allows the behavior to track active motions so they can be automatically removed on stop().

If you manually call motman->addPersistentMotion() or motman->addPrunableMotion(), you avoid this safety net, such that for better or worse the motion could be "leaked" and outlive the behavior. In rare cases, this may be desired if the motion is self-pruning or shared with another behavior.

Note that you can pass either SharedObject<MC> instances, or MotionPtr<MC> instances, which automatically expose their internal SharedObject when passed as such.

Definition at line 138 of file BehaviorBase.cc.

BehaviorBase::MC_ID BehaviorBase::addMotion ( const SharedObjectBase mc,
Prunability_t  prune = PERSISTENT 
) [protected, virtual]

Registers the MotionCommand (contained within a shared memory region) with the MotionManager, and allows the behavior to track active motions so they can be automatically removed on stop().

If you manually call motman->addPersistentMotion() or motman->addPrunableMotion(), you avoid this safety net, such that for better or worse the motion could be "leaked" and outlive the behavior. In rare cases, this may be desired if the motion is self-pruning or shared with another behavior.

Note that you can pass either SharedObject<MC> instances, or MotionPtr<MC> instances, which automatically expose their internal SharedObject when passed as such.

Definition at line 133 of file BehaviorBase.cc.

Referenced by LookAtMarkers::setup().

void BehaviorBase::doEvent (  )  [protected, virtual]

Delegate function for event processing, the event itself is pointed to (only for the duration of the doEvent() call!) by event.

Default implementation watches for 'private' text message events (those forwarded by a BehaviorSwitchControl from ControllerGUI input) and will publically rebroadcast them. The idea is that your own processEvent gets first dibs, but if the behavior doesn't handle the text message, it will be handed off for others.

Reimplemented in Controller, FreeMemReportControl, ArmController, CameraStreamBehavior, DepthCam, EchoBehavior, EStopController, GamepadController, MicrophoneServer, RawCam, RegionCam, SegCam, UPennWalkControllerBehavior, WalkController, WMMonitorBehavior, WorldStateSerializerBehavior, DynamicMotionSequenceNode, LogNode, MCNodeBase, MotionSequenceNode< SIZE >, RecordMotionNode, SoundNode, SpeechNode, WalkToTargetNode, WaypointEngineNode< W, mcName, mcDesc >, BatteryMonitorBehavior, CameraBehavior, FlashIPAddrBehavior, CompareTrans< T >, CompletionTrans, ConnectionMadeTrans, EventTrans, GrasperTrans, LostTargetTrans, NullTrans, PilotTrans, SignalTrans< T >, SmoothCompareTrans< T >, TextMsgTrans, TimeOutTrans, VisualTargetCloseTrans, VisualTargetTrans, GrasperNode, DualCoding::Lookout, DualCoding::MapBuilder, MapBuilderNode, DualCoding::Pilot, DualCoding::Pilot::RunMotionModel, DualCoding::Pilot::RunOpticalFlow, DualCoding::Pilot::CollisionChecker, DualCoding::Pilot::CollisionDispatch, DualCoding::Pilot::SetOdometryMachine::TurnHead, PilotNode, TrackNode, KoduInterpreter::KoduEventListener, KoduInterpreter::GiveActionRunner::GiveActionStart, KoduInterpreter::ReceiveActionRunner::ReceiveActionStart, KoduInterpreter::NotificationMonitor, DeadReckoningBehavior< ParticleT >, FFPlanner, FFPlanNode, PitchDetector, BallDetectionGenerator, BufferedImageGenerator, CDTGenerator, FilterBankGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator.

Definition at line 91 of file BehaviorBase.cc.

Referenced by processEvent().

virtual void BehaviorBase::DoStart ( struct __USE_doStart_NOT_DoStart__ &   )  [private, virtual]

temporary to produce warnings to help people update

Definition at line 238 of file BehaviorBase.h.

virtual void BehaviorBase::doStart (  )  [protected, virtual]

Delegate function for subclasses to be notified when the behavior starts up.

Should be overridden by subclasses to subscribe to events, install motion commands, etc.

doStart() is basically a hook to allow subclasses to jump in and do some customization of behavior parameters while the behavior is starting. If you are writing a behavior class and do not expect further derivation, just override doStart() yourself. However, if you do expect further derivation of your class, consider using preStart() or postStart() instead, and leave doStart() for the 'leaf' classes.

Reimplemented in Controller, FreeMemReportControl, Aibo3DControllerBehavior, ArmController, DepthCam, EchoBehavior, EStopController, HeadController, MicrophoneServer, RawCam, RegionCam, SegCam, SpeakerServer, UPennWalkControllerBehavior, WalkController, WMMonitorBehavior, WorldStateSerializerBehavior, PostStateCompletion, PostMachineCompletion, PostMachineSuccess, PostMachineFailure, WalkToTargetNode, BatteryMonitorBehavior, CameraBehavior, FlashIPAddrBehavior, Grasper::PlanBodyApproach, Grasper::DoBodyApproach, Grasper::FindObj, Grasper::PlanArmApproach, Grasper::FingersApproach, Grasper::DoBodyApproach2, Grasper::DoBodyApproach3, Grasper::Verify::VerifyDispatch, Grasper::Verify::GetAprilTag, Grasper::Verify::GetDomino, Grasper::Verify::GetCross, Grasper::Verify::CheckGripperLoad, Grasper::Verify::CheckUserVerify, Grasper::ArmGrasp, Grasper::ArmPulse, Grasper::ArmNudge, Grasper::ArmRaise, Grasper::PlanBodyTransport, Grasper::DoBodyTransport, Grasper::PlanArmDeliver, Grasper::ReleaseArm, Grasper::DoWithdraw, Grasper::MoveArm, Grasper::Rest::GetRestType, Grasper::Rest::GetOpenGripperFlag, Grasper::SetJoint, Grasper::PathPlanConstrained, Grasper::PathPlanToRest, Grasper::IfRequestIs, Grasper::SignalGraspError, Grasper::GrasperSucceeded, Grasper::GrasperFailed, Grasper::NextRequest, DualCoding::Lookout, DualCoding::Pilot, DualCoding::Pilot::RunMotionModel, DualCoding::Pilot::RunOpticalFlow, DualCoding::Pilot::CollisionChecker, DualCoding::Pilot::ReportCompletion, DualCoding::Pilot::CollisionDispatch, DualCoding::Pilot::TerminateDueToCollision, DualCoding::Pilot::SetupLandmarkExtractor, DualCoding::Pilot::PlanPath, DualCoding::Pilot::ConstructNavPlan, DualCoding::Pilot::ExecutePlan::NextTask, DualCoding::Pilot::ExecutePlan::Walk, DualCoding::Pilot::ExecutePlan::Turn, DualCoding::Pilot::ExecutePlan::AdjustHeading, DualCoding::Pilot::ExecutePlan::ExecuteStep, DualCoding::Pilot::LocalizationUtility::TakeInitialPicture, DualCoding::Pilot::LocalizationUtility::CheckEnoughLandmarks, DualCoding::Pilot::LocalizationUtility::ChooseGazePoints, DualCoding::Pilot::LocalizationUtility::PrepareForNextGazePoint, DualCoding::Pilot::LocalizationUtility::TakeNextPicture, DualCoding::Pilot::LocalizationUtility::ReturnToInitialHeading, DualCoding::Pilot::LocalizationUtility::Localize, DualCoding::Pilot::WalkMachine::WalkMachine_Walker, DualCoding::Pilot::WalkMachine::SetWalking, DualCoding::Pilot::WaypointWalkMachine::WaypointWalkMachine_WaypointWalker, DualCoding::Pilot::WaypointWalkMachine::SetWalking, DualCoding::Pilot::SetVelocityMachine::SetVelocityMachine_Walker, DualCoding::Pilot::GoToShapeMachine::CheckParameters, DualCoding::Pilot::GoToShapeMachine::SetUpPlanNode, DualCoding::Pilot::GoToShapeMachine::SetMaxTurn, DualCoding::Pilot::ClearOldPath, DualCoding::Pilot::LookForObject, DualCoding::Pilot::LookForTarget, DualCoding::Pilot::PushObjectMachine::SetMaxTurn, DualCoding::Pilot::PushObjectMachine::CheckParameters, DualCoding::Pilot::PushObjectMachine::SetUpObjToDest, DualCoding::Pilot::PushObjectMachine::AddBackupPt, DualCoding::Pilot::PushObjectMachine::AddAcquirePt, DualCoding::Pilot::PushObjectMachine::SetUpObjToDest2, DualCoding::Pilot::PushObjectMachine::SetUpInitToObj, DualCoding::Pilot::PushObjectMachine::ChoosePathInitToObj, DualCoding::Pilot::PushObjectMachine::ChoosePathObjToDest, DualCoding::Pilot::PushObjectMachine::SetUpExecute2, DualCoding::Pilot::PushObjectMachine::DisplayStraightLineInitToObj, DualCoding::Pilot::PushObjectMachine::DisplayStraightLineObjToDest, DualCoding::Pilot::PushObjectMachine::DisplayPathInitToObj, DualCoding::Pilot::PushObjectMachine::DisplayPathObjToDest, DualCoding::Pilot::PushObjectMachine::WalkBackward, DualCoding::Pilot::PushObjectMachine::WalkForward, DualCoding::Pilot::PushObjectMachine::FetchObj, DualCoding::Pilot::PushObjectMachine::AdjustPush, DualCoding::Pilot::PushObjectMachine::CheckObjectPos, DualCoding::Pilot::PushObjectMachine::MoveObjectPos, DualCoding::Pilot::VisualSearchMachine::Search, DualCoding::Pilot::VisualSearchMachine::Check, DualCoding::Pilot::VisualSearchMachine::Rotate, DualCoding::Pilot::SetOdometryMachine::TurnHead, DualCoding::Pilot::Dispatch, EventGeneratorBase, KoduInterpreter::InitializeAgent::CreateWorld, KoduInterpreter::InitializeAgent::ParseKode, KoduInterpreter::InitializeAgent::LookAround, KoduInterpreter::InitializeAgent::PointHeadFwd, KoduInterpreter::InitializeAgent::OrganizeWorld, KoduInterpreter::WalkMonitor, KoduInterpreter::PerceptualMultiplexor::MultiplexorStart, KoduInterpreter::PerceptualMultiplexor::MapBuilderTaskRunner::ExecuteMapBuilderTask, KoduInterpreter::PerceptualMultiplexor::MapBuilderTaskRunner::ExamineMapBuilderResults, KoduInterpreter::PerceptualMultiplexor::PilotTaskRunner::ExecutePilotTask, KoduInterpreter::PerceptualMultiplexor::PilotTaskRunner::SetTaskSuccess, KoduInterpreter::PerceptualMultiplexor::PilotTaskRunner::SetTaskFailure, KoduInterpreter::PerceptualMultiplexor::MultiplexorEnd, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::PauseInterpretation, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::StartRecovery, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::InitiateManipRecovery::GetObjectInfo, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::InitiateManipRecovery::OpenGripper, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForItemRecovery::Reverse, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForItemRecovery::LocateLostObject, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForItemRecovery::SetGrasperTarget, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForItemRecovery::FaceTarget, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::RetrieveLostObject, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::VerifyObjectWasGrabbed::LookAtTheGripper, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::VerifyObjectWasGrabbed::VerifyObjectInGripper, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::NeedToLookAround, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::LookForTag, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::RepositionBody, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::FindObjectAgain, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::RepositionGripperObject, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::GetTagLocation, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::LocalizeAgent::CreateLocalizeTask, KoduInterpreter::PerceptualMultiplexor::FailureRecovery::EndRecovery, KoduInterpreter::KoduConditionEvaluator, KoduInterpreter::KoduActionRunner, KoduInterpreter::DropActionRunner::DropActionStart, KoduInterpreter::DropActionRunner::ExecuteDrop::DropItem, KoduInterpreter::DropActionRunner::ExecuteDrop::LookAtObjectAprilTag, KoduInterpreter::DropActionRunner::ExecuteDrop::RecordAprilTagPos, KoduInterpreter::DropActionRunner::ExecuteDrop::ReverseBody, KoduInterpreter::DropActionRunner::ExecuteDrop::LocalizeAgent, KoduInterpreter::DropActionRunner::ExecuteDrop::RepositionReleasedObject::LookForObjectAgain, KoduInterpreter::DropActionRunner::ExecuteDrop::RepositionReleasedObject::RepositionObject, KoduInterpreter::DropActionRunner::DropActionEnd, KoduInterpreter::GrabActionRunner::GrabActionStart::IsObjectNear, KoduInterpreter::GrabActionRunner::GrabActionStart::GetTagId, KoduInterpreter::GrabActionRunner::PrepareBody::FaceObject, KoduInterpreter::GrabActionRunner::PrepareBody::ReverseBody, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::GrabObject, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::VerifyObjectWasGrabbed::LookAtTheGripper, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::VerifyObjectWasGrabbed::VerifyObjectInGripper, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::NeedToLookAround, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::LookAroundForObject, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::RepositionBody, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::FindObjectAgain, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::RepositionGripperObject, KoduInterpreter::GrabActionRunner::ExecuteGrabAction::CreateGripMonTask, KoduInterpreter::GrabActionRunner::GrabActionEnd, KoduInterpreter::GiveActionRunner::PositionBody::Rotate, KoduInterpreter::GiveActionRunner::PositionBody::Walk, KoduInterpreter::GiveActionRunner::Backup, KoduInterpreter::GiveActionRunner::GiveActionStart, KoduInterpreter::GiveActionRunner::GiveActionSend, KoduInterpreter::ReceiveActionRunner::ReceiveActionTurnAndGet::Rotate, KoduInterpreter::ReceiveActionRunner::ReceiveActionTurnAndGet::LookDown, KoduInterpreter::ReceiveActionRunner::ReceiveActionTurnAndGet::FindObject, KoduInterpreter::ReceiveActionRunner::ReceiveActionStart, KoduInterpreter::ReceiveActionRunner::FindObject, KoduInterpreter::ReceiveActionRunner::ReceiveActionEnd, KoduInterpreter::MotionActionRunner::MotionStart, KoduInterpreter::MotionActionRunner::ExecuteMotionAction::CheckMotionType, KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteGoToShapeRequest, KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteSimpleMotion::CheckForValidTarget, KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteSimpleMotion::FindMotionTarget, KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteSimpleMotion::CreateFinalApproachCommand, KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteSimpleMotion::ExecuteSimpleTurn, KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteSimpleMotion::ExecuteSimpleWalk, KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteDriverMotion, KoduInterpreter::MotionActionRunner::MotionEnd, KoduInterpreter::PageSwitchActionRunner::PageSwitchStart, KoduInterpreter::PageSwitchActionRunner::SwitchToNewPage, KoduInterpreter::PageSwitchActionRunner::PageSwitchEnd, KoduInterpreter::PlayActionRunner::PlayStart, KoduInterpreter::PlayActionRunner::PlayEnd, KoduInterpreter::PlayActuator, KoduInterpreter::SayActuator, KoduInterpreter::CompleteSayActuator, KoduInterpreter::ScoreActuator, KoduInterpreter::NotificationMonitor, DeadReckoningBehavior< ParticleT >, LookAtMarkers::DummyFinish, PitchDetector, BufferedImageGenerator, CDTGenerator, and RawCameraGenerator.

Definition at line 139 of file BehaviorBase.h.

Referenced by start().

virtual void BehaviorBase::DoStop ( struct __USE_doStart_NOT_DoStart__ &   )  [private, virtual]

temporary to produce warnings to help people update

Definition at line 239 of file BehaviorBase.h.

virtual void BehaviorBase::doStop (  )  [protected, virtual]

Delegate function for subclasses to be notified when the behavior starts up.

May be overridden to cleanup when the behavior is shutting down. However events will automatically be unsubscribed, and by using addMotion(), motions will automatically be removed by stop(), so you may not need any cleanup.

Reimplemented in Controller, FreeMemReportControl, Aibo3DControllerBehavior, ArmController, DepthCam, EchoBehavior, EStopController, HeadController, MicrophoneServer, RawCam, RegionCam, SegCam, SpeakerServer, UPennWalkControllerBehavior, WalkController, WMMonitorBehavior, WorldStateSerializerBehavior, WalkToTargetNode, BatteryMonitorBehavior, CameraBehavior, FlashIPAddrBehavior, Grasper, DualCoding::Lookout, DualCoding::Pilot, DualCoding::Pilot::SetOdometryMachine::TurnHead, DualCoding::Pilot::SetOdometryMachine, EventGeneratorBase, and PitchDetector.

Definition at line 149 of file BehaviorBase.h.

Referenced by stop().

static std::string BehaviorBase::getClassDescription (  )  [static]

Gives a short description of what this class of behaviors does... you should override this (but don't have to).

If you do override this, also consider overriding getDescription() to return it

Reimplemented in Controller, Aibo3DControllerBehavior, ArmController, CameraStreamBehavior, DepthCam, EchoBehavior, EStopController, GamepadController, HeadController, RawCam, RegionCam, SegCam, UPennWalkControllerBehavior, WalkController, WMMonitorBehavior, WorldStateSerializerBehavior, LedNode, LogNode, MCNodeBase, MCNode< T, mcName, mcDesc, completes >, RecordMotionNode, WalkToTargetNode, BatteryMonitorBehavior, CameraBehavior, FlashIPAddrBehavior, TextMsgTrans, DualCoding::Lookout, DeadReckoningBehavior< ParticleT >, LookAtMarkers, PitchDetector, BallDetectionGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, SegmentedColorGenerator, MCNode< LedMC >, MCNode< WalkMC, defWalkNodeName, defWalkNodeDesc >, MCNode< MotionSequenceMC< SIZE >, defMotionSequenceNodeName, defMotionSequenceNodeDesc, true >, MCNode< DynamicMotionSequence, defDynamicMotionSequenceNodeName, defDynamicMotionSequenceNodeDesc, true >, MCNode< PostureMC, defPostureNodeName, defPostureNodeDesc, true >, MCNode< TailWagMC, defTailWagNodeName, defTailWagNodeDesc, false >, MCNode< W, mcName, mcDesc >, MCNode< HeadPointerMC, defHeadPointerNodeName, defHeadPointerNodeDesc, true >, MCNode< PIDMC, defPIDNodeName, defPIDNodeDesc, true >, and MCNode< ArmMC, defArmNodeName, defArmNodeDesc, true >.

Definition at line 105 of file BehaviorBase.h.

Referenced by getDescription().

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

Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).

By default simply returns getName(), because any calls from a BehaviorBase function to getClassDescription() are going to call BehaviorBase::getClassDescription(), not ~YourSubClass~getClassDescription(), because static functions can't be virtual in C++ (doh!)

This means that getDescription called on a pointer to a BehaviorBase of unknown subtype would always return an empty string, which is pretty useless. So instead we return the name in this situation. If you want getDescription to return getClassDescription, you'll have to override it in your subclass to do so.

Reimplemented in Controller, Aibo3DControllerBehavior, ArmController, CameraStreamBehavior, DepthCam, EchoBehavior, EStopController, GamepadController, HeadController, RawCam, RegionCam, SegCam, UPennWalkControllerBehavior, WalkController, WMMonitorBehavior, WorldStateSerializerBehavior, LedNode, LogNode, MCNodeBase, MCNode< T, mcName, mcDesc, completes >, RecordMotionNode, WalkToTargetNode, BatteryMonitorBehavior, CameraBehavior, FlashIPAddrBehavior, TextMsgTrans, DualCoding::Lookout, DualCoding::MapBuilder, DeadReckoningBehavior< ParticleT >, PitchDetector, MCNode< LedMC >, MCNode< WalkMC, defWalkNodeName, defWalkNodeDesc >, MCNode< MotionSequenceMC< SIZE >, defMotionSequenceNodeName, defMotionSequenceNodeDesc, true >, MCNode< DynamicMotionSequence, defDynamicMotionSequenceNodeName, defDynamicMotionSequenceNodeDesc, true >, MCNode< PostureMC, defPostureNodeName, defPostureNodeDesc, true >, MCNode< TailWagMC, defTailWagNodeName, defTailWagNodeDesc, false >, MCNode< W, mcName, mcDesc >, MCNode< HeadPointerMC, defHeadPointerNodeName, defHeadPointerNodeDesc, true >, MCNode< PIDMC, defPIDNodeName, defPIDNodeDesc, true >, and MCNode< ArmMC, defArmNodeName, defArmNodeDesc, true >.

Definition at line 95 of file BehaviorBase.h.

Referenced by BehaviorSwitchControl< B, Al >::getDescription(), and BehaviorSwitchControlBase::getDescription().

virtual std::string BehaviorBase::getName (  )  const [virtual]

Identifies the behavior in menus and such.

Reimplemented in FreeMemReportControl, and Transition.

Definition at line 77 of file BehaviorBase.h.

Referenced by PNGGenerator::calcImage(), JPEGGenerator::calcImage(), BallDetectionGenerator::createEvent(), EventRouter::dispTimers(), SegCam::doEvent(), RawCam::doEvent(), LogNode::doEvent(), FlashIPAddrBehavior::doEvent(), FilterBankGenerator::doEvent(), DepthCam::doEvent(), BufferedImageGenerator::doEvent(), KoduInterpreter::PageSwitchActionRunner::SwitchToNewPage::doStart(), KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteSimpleMotion::FindMotionTarget::doStart(), KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteSimpleMotion::CheckForValidTarget::doStart(), KoduInterpreter::MotionActionRunner::ExecuteMotionAction::ExecuteGoToShapeRequest::doStart(), KoduInterpreter::ReceiveActionRunner::FindObject::doStart(), KoduInterpreter::GrabActionRunner::GrabActionEnd::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::CreateGripMonTask::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::RepositionGripperObject::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::FindObjectAgain::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::RepositionBody::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::LookAroundForObject::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::PrepareForAnotherGrasp::NeedToLookAround::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::VerifyObjectWasGrabbed::VerifyObjectInGripper::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::VerifyObjectWasGrabbed::LookAtTheGripper::doStart(), KoduInterpreter::GrabActionRunner::ExecuteGrabAction::GrabObject::doStart(), KoduInterpreter::GrabActionRunner::PrepareBody::ReverseBody::doStart(), KoduInterpreter::GrabActionRunner::PrepareBody::FaceObject::doStart(), KoduInterpreter::GrabActionRunner::GrabActionStart::GetTagId::doStart(), KoduInterpreter::GrabActionRunner::GrabActionStart::IsObjectNear::doStart(), KoduInterpreter::DropActionRunner::DropActionEnd::doStart(), KoduInterpreter::DropActionRunner::ExecuteDrop::RepositionReleasedObject::RepositionObject::doStart(), KoduInterpreter::DropActionRunner::ExecuteDrop::RepositionReleasedObject::LookForObjectAgain::doStart(), KoduInterpreter::DropActionRunner::ExecuteDrop::LocalizeAgent::doStart(), KoduInterpreter::DropActionRunner::ExecuteDrop::ReverseBody::doStart(), KoduInterpreter::DropActionRunner::ExecuteDrop::RecordAprilTagPos::doStart(), KoduInterpreter::DropActionRunner::ExecuteDrop::LookAtObjectAprilTag::doStart(), KoduInterpreter::DropActionRunner::ExecuteDrop::DropItem::doStart(), KoduInterpreter::DropActionRunner::DropActionStart::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::EndRecovery::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::LocalizeAgent::CreateLocalizeTask::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::GetTagLocation::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::RepositionGripperObject::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::FindObjectAgain::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::RepositionBody::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::LookForTag::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForAnotherGrasp::NeedToLookAround::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::VerifyObjectWasGrabbed::VerifyObjectInGripper::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::VerifyObjectWasGrabbed::LookAtTheGripper::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::RetrieveLostObject::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForItemRecovery::FaceTarget::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForItemRecovery::SetGrasperTarget::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForItemRecovery::LocateLostObject::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::PrepareForItemRecovery::Reverse::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::InitiateManipRecovery::OpenGripper::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::ObjectManipRecovery::InitiateManipRecovery::GetObjectInfo::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::StartRecovery::doStart(), KoduInterpreter::PerceptualMultiplexor::FailureRecovery::PauseInterpretation::doStart(), KoduInterpreter::PerceptualMultiplexor::PilotTaskRunner::SetTaskFailure::doStart(), KoduInterpreter::PerceptualMultiplexor::PilotTaskRunner::SetTaskSuccess::doStart(), KoduInterpreter::PerceptualMultiplexor::PilotTaskRunner::ExecutePilotTask::doStart(), KoduInterpreter::PerceptualMultiplexor::MapBuilderTaskRunner::ExecuteMapBuilderTask::doStart(), KoduInterpreter::WalkMonitor::doStart(), KoduInterpreter::InitializeAgent::OrganizeWorld::doStart(), KoduInterpreter::InitializeAgent::LookAround::doStart(), EventLogger::find(), getDescription(), BehaviorSwitchControlBase::getName(), EventLogger::isListening(), EventLogger::logImage(), EventLogger::logMessage(), EventLogger::logWebcam(), SpeechNode::postStart(), LogNode::postStart(), StateNode::postStateCompletion(), StateNode::postStateSignal(), StateNode::postStateStart(), StateNode::postStateStop(), processEvent(), EventLogger::processStateMachineEvent(), CameraStreamBehavior::receiveData(), FilterBankGenerator::refresh(), EventLogger::runCommand(), Controller::select(), EventLogger::spider(), StateNode::start(), RecordMotionNode::stop(), and ~BehaviorBase().

static const std::set<BehaviorBase*>& BehaviorBase::getRegistry (  )  [static]

This read-only set allows us list all the currently instantiated behaviors.

Not all of these behaviors are necessarily active, this is everything that has been allocated and not yet deallocated

Definition at line 112 of file BehaviorBase.h.

Referenced by EventLogger::find(), and EventLogger::runCommand().

std::set< BehaviorBase * > & BehaviorBase::getRegistryInstance (  )  [static, protected]

static function to provide well-defined initialization order

Definition at line 101 of file BehaviorBase.cc.

Referenced by BehaviorBase(), getRegistry(), and ~BehaviorBase().

std::string BehaviorBase::humanifyClassName ( const std::string &  name  )  [static]

A simple utility call for REGISTER_BEHAVIOR and friends to remove trailing "Behavior" suffix from display names and fix CamelCase. Disabled because it interferes with the Storyboard and other components; should be re-implemented inside ControllerGUI.

a rough heuristic for inserting spaces... before any non-lowercase letter (i.e. caps or nums) where previous or next is lower, but not within a digit string or before a final digit string

Definition at line 107 of file BehaviorBase.cc.

BehaviorBase & BehaviorBase::operator= ( const BehaviorBase b  )  [protected]

assignment operator; assumes subclass handles assignment appropriately - i.e. if b is active, the copy will be as well, even though doStart was never called..

Definition at line 27 of file BehaviorBase.cc.

void BehaviorBase::processEvent ( const EventBase curEvent  )  [virtual]

Assigns curEvent to event and calls to doEvent() for user processing.

This is basically a hack for noobs who can't grok function arguments at the expense of creating a more complicated overall design for everyone else...
On the up side, this also allows optional event references for StateNodes receiving a transition, so they can inspect the triggering event. Also if we someday want to make BehaviorBase smarter and do some built-in event processing, it would go here.

Implements EventListener.

Reimplemented in EventGeneratorBase.

Definition at line 80 of file BehaviorBase.cc.

Referenced by BatteryMonitorBehavior::doStart(), ArmController::relax(), and BehaviorSwitchControlBase::takeInput().

template<class T >
BehaviorSwitchControlBase * BehaviorBase::registerControllerEntry ( const std::string &  name,
const std::string &  menu,
int  flags = BEH_DEFAULTS 
) [static]

Registers a behavior class to be added to the specified Controller menu, use '/' to specify sub-menus, see REGISTER_BEHAVIOR macro.

This only works when called as an initializer to a static variable. Once the menus have been initialized, later calls to this function won't update the menus.

Definition at line 246 of file BehaviorBase.h.

template<template< typename T > class M, class T >
void BehaviorBase::removeMotion ( const M< T > &  mc  )  [protected]

forwarding function so you can pass SharedObject<T> or MotionPtr<T> directly; extracts the MC_ID and passes to the other removeMotion

Definition at line 188 of file BehaviorBase.h.

Referenced by removeMotion().

void BehaviorBase::removeMotion ( MotionManager::MC_ID  mcid  )  [protected, virtual]

Removes the motion from the MotionManager.

As long as there exists a SharedObject reference to the underlying memory region (such as within a MotionPtr instance), the memory is not actually deallocated, and you can resubmit the same motion later if desired.

Definition at line 152 of file BehaviorBase.cc.

virtual void BehaviorBase::setName ( const std::string &  name  )  [virtual]

Allows dynamic renaming of behaviors.

Definition at line 80 of file BehaviorBase.h.

Referenced by BehaviorSwitchControlBase::BehaviorSwitchControlBase(), and BehaviorSwitchControl< B, Al >::startmine().

void BehaviorBase::start (  )  [virtual]

Calling this signals that the behavior should start running. It will increment the reference counter, add to the registry, and call the subclass hooks (preStart() / doStart() postStart() ).

Generally you shouldn't override this -- override some combination of preStart(), doStart(), and postStart() instead.

Reimplemented in GamepadController, and StateNode.

Definition at line 46 of file BehaviorBase.cc.

Referenced by XWalkEdit::activate(), BehaviorActivatorControl::activate(), Transition::doFire(), RandomTrans::fire(), and BehaviorSwitchControlBase::startmine().

void BehaviorBase::stop (  )  [virtual]

Calling this signals the behavior to stop running. In turn, this calls doStop(), then removes the behavior from the registry and subtracts from the reference counter Ñ thus may delete the object if no other references remain.

You shouldn't override this — override doStop instead.
Warning: if you do override, call this at the end of your stop(), not beginning (as it might delete this !)

Reimplemented in GamepadController, LedActivate, LogNode, MCNodeBase, RecordMotionNode, SoundNode, SpeechNode, WalkNode, WaypointEngineNode< W, mcName, mcDesc >, StateNode, Transition, CompletionTrans, DualCoding::MapBuilder, PilotNode, TrackNode, and KoduInterpreter::MotionActionRunner.

Definition at line 69 of file BehaviorBase.cc.

Referenced by BehaviorActivatorControl::activate(), WalkController::doEvent(), SegCam::doEvent(), RawCam::doEvent(), DepthCam::doEvent(), BehaviorSwitchControlBase::setGroup(), BehaviorSwitchControlBase::stopother(), BehaviorSwitchControlBase::BehaviorGroup::~BehaviorGroup(), FreeMemReportControl::~FreeMemReportControl(), and XWalkEdit::~XWalkEdit().


Member Data Documentation

A list of active motions registered with this behavior to be removed when the behavior stops.

If a motion is externally removed, e.g. prunes itself, the MonitorMotion instance kicks in to remove the dead MC_ID from this list

Definition at line 219 of file BehaviorBase.h.

Referenced by addMotion(), BehaviorBase::MonitorMotion::processEvent(), removeMotion(), stop(), and ~BehaviorBase().

const EventBase* BehaviorBase::event [protected]

the event, received by processEvent, stored for duration of call to doEvent() (also doStart() in the case of a StateNode receiving a transition), NULL at all other times

Definition at line 235 of file BehaviorBase.h.

Referenced by WorldStateSerializerBehavior::doEvent(), WalkController::doEvent(), VisualTargetTrans::doEvent(), VisualTargetCloseTrans::doEvent(), TimeOutTrans::doEvent(), TextMsgTrans::doEvent(), SignalTrans< T >::doEvent(), SegmentedColorGenerator::doEvent(), SegCam::doEvent(), RLEGenerator::doEvent(), RegionGenerator::doEvent(), RegionCam::doEvent(), RawCameraGenerator::doEvent(), RawCam::doEvent(), PNGGenerator::doEvent(), PitchDetector::doEvent(), PilotTrans::doEvent(), MotionSequenceNode< SIZE >::doEvent(), MCNodeBase::doEvent(), DualCoding::MapBuilder::doEvent(), LostTargetTrans::doEvent(), DualCoding::Lookout::doEvent(), LookAtMarkers::Search::doEvent(), LookAtMarkers::TrackMarker::doEvent(), LogNode::doEvent(), KoduInterpreter::NotificationMonitor::doEvent(), KoduInterpreter::ReceiveActionRunner::ReceiveActionStart::doEvent(), KoduInterpreter::GiveActionRunner::GiveActionStart::doEvent(), KoduInterpreter::KoduEventListener::doEvent(), JPEGGenerator::doEvent(), InterleavedYUVGenerator::doEvent(), GrasperTrans::doEvent(), GrasperNode::doEvent(), GamepadController::doEvent(), FreeMemReportControl::doEvent(), FlashIPAddrBehavior::doEvent(), FilterBankGenerator::doEvent(), FFPlanNode::doEvent(), FFPlanner::doEvent(), EventTrans::doEvent(), EStopController::doEvent(), EchoBehavior::doEvent(), DynamicMotionSequenceNode::doEvent(), DepthCam::doEvent(), DeadReckoningBehavior< ParticleT >::doEvent(), Controller::doEvent(), CompletionTrans::doEvent(), CDTGenerator::doEvent(), CameraStreamBehavior::doEvent(), CameraBehavior::doEvent(), BufferedImageGenerator::doEvent(), doEvent(), BatteryMonitorBehavior::doEvent(), BallDetectionGenerator::doEvent(), ArmController::doEvent(), LookAtMarkers::Search::doStart(), LookAtMarkers::TrackMarker::doStart(), Grasper::GrasperFailed::doStart(), Grasper::SignalGraspError::doStart(), Grasper::SetJoint::doStart(), TrackNode::preStart(), SpeechNode::preStart(), SoundNode::preStart(), PilotNode::preStart(), MotionSequenceNode< SIZE >::preStart(), DynamicMotionSequenceNode::preStart(), and processEvent().

std::string BehaviorBase::instanceName [protected]

holds the name of this instance of behavior, if empty then getName() forwards to getClassName()

Definition at line 234 of file BehaviorBase.h.

Referenced by Transition::getName(), getName(), operator=(), and setName().

Typically would use MotionManager::invalid_MC_ID, but re-specified here for convenience and to avoid dependence on MotionManager.h.

Definition at line 125 of file BehaviorBase.h.

bool BehaviorBase::started [protected]

true when the behavior is active

Definition at line 233 of file BehaviorBase.h.

Referenced by isActive(), operator=(), StateNode::start(), start(), stop(), and ~BehaviorBase().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:05 2016 by Doxygen 1.6.3