Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
MotionManager Class Reference#include <MotionManager.h>
Detailed DescriptionThe purpose of this class is to repeatedly compute the final set of joint angles for the robot, managing a set of (possibly conflicting) MotionCommands.Since Main and Motion run as separate processes, they could potentially try to access the same motion command at the same time, leading to unpredictable behavior. The MotionManager enforces a set of locks to serialize access to the MotionCommands. Although you could call checkoutMotion() and checkinMotion() directly, it is instead recommended to use MMAccessor to automatically handle casting and checkin for you.
The other problem is that we are sharing the memory holding MotionCommands between processes. MotionManager will do the necessary magic behind the scenes to distribute new MotionCommands to all the involved processes (currently just Main and Motion)
// type A: prunable motions are automatically removed when completed: motman->addPrunableMotion( SharedObject<YourMC>([arg1,...]) [, priority ] ); // type B: persistent motions are removed only when you explicitly request it: MC_ID id = motman->addPersistentMotion( SharedObject<YourMC>([arg1,...]) [, priority ] ); // then later: motman->removeMotion(id); The priority level can be changed later via setPriority(), and there are symbolic values defined in kIgnoredPriority through kEmergencyPriority to give some common guidelines on the magnitudes to use. The default priority level if unspecified is kStdPriority.
If you want to do some more initializations not handled by the MotionCommand's constructor (the
SharedObject<YourMC> yourmc([arg1,[arg2,...]]); yourmc->cmd1(); yourmc->cmd2(); //... motman->addPrunableMotion(yourmc [, ...]); //or addPersistentMotion(...)
Notice that
Definition at line 83 of file MotionManager.h.
Member Typedef Documentationuse this type when referring to the ID numbers that MotionManager hands out
Definition at line 93 of file MotionManager.h.
type to use to refer to accessors of MotionManager (or its locks)
Definition at line 211 of file MotionManager.h.
Constructor & Destructor Documentation
this shouldn't be called...
Member Function Documentation
LOCKS MotionManager Everyone who is planning to use the MotionManager needs to call this before they access it or suffer a horrible fate
Definition at line 65 of file MotionManager.cc.
called with incoming messages, will pass non-echos to processMsg()
Definition at line 619 of file MotionManager.cc. Referenced by InitAccess().
needed in order to dereference shared memory regions before shutting down
Definition at line 84 of file MotionManager.cc.
sets etrans, should be called before any events can be sent
Definition at line 115 of file MotionManager.h.
LOCKS MotionManager This gets called by receivedMsg when under Aperios, or directly if you already have an RCRegion
Definition at line 638 of file MotionManager.cc. Referenced by receivedMsg().
LOCKS MotionManager Requests a value be set for the specified output, copies cmd across frames
Definition at line 143 of file MotionManager.cc. Referenced by Controller::deactivate(), Controller::DoStop(), MotionCommand::resetWheels(), UPennWalkMC::SetLegJoints(), WalkMC::updateOutputs(), TailWagMC::updateOutputs(), RemoteControllerMC::updateOutputs(), PostureMC::updateOutputs(), PIDMC::updateOutputs(), MotionSequenceMC< MAXMOVE >::updateOutputs(), LedMC::updateOutputs(), EmergencyStopMC::updateOutputs(), and DynamicMotionSequence::updateOutputs().
LOCKS MotionManager Requests a value be set for the specified output in the specified frame
Definition at line 167 of file MotionManager.cc.
LOCKS MotionManager Requests a value be set for the specified output across frames
Definition at line 190 of file MotionManager.cc.
LOCKS MotionManager Requests a PID be set for the specified output, notice that this might be overruled by a higher priority motion
Definition at line 221 of file MotionManager.cc.
LOCKS MotionManager Requests a value and PID be set for the specified output
Definition at line 242 of file MotionManager.cc.
LOCKS MotionManager Requests a value and PID be set for the specified output
Definition at line 268 of file MotionManager.cc.
Returns the value of the output last sent to the OS. Note that this will differ from the sensed value in state, even when staying still. There is no corresponding getOutputPID because this value *will* duplicate the value in state.
Definition at line 126 of file MotionManager.h. Referenced by EmergencyStopMC::freezeJoints(), PostureMC::setDirty(), and PostureMC::setOutputCmd().
sets the priority level of a MotionCommand, symbolic values are available to give some guidelines -- see kIgnoredPriority through kEmergencyPriority
Definition at line 127 of file MotionManager.h. Referenced by Controller::activate(), Controller::deactivate(), MCNodeBase::DoStart(), MCNodeBase::DoStop(), and BatteryMonitorBehavior::processEvent().
returns priority level of a MotionCommand, symbolic values are available to give some guidelines -- see kIgnoredPriority through kEmergencyPriority
Definition at line 128 of file MotionManager.h. Referenced by setOutput().
returns the MC_ID of the first MotionCommand
Definition at line 132 of file MotionManager.h. Referenced by getOutputs(). returns the MC_ID of MotionCommand following the one that is passed
Definition at line 133 of file MotionManager.h. Referenced by MotionSequenceEngine::compress(), and getOutputs().
returns the MC_ID of the one-past-the-end MotionCommand (like the STL)
Definition at line 134 of file MotionManager.h. Referenced by getOutputs().
locks the command and possibly performs RTTI conversion; supports recursive calls
Definition at line 821 of file MotionManager.cc. Referenced by MMAccessor< MC_t >::checkout(), MCValueEditControl< T >::doSelect(), getOutputs(), processMsg(), RemoveAccess(), removeMotion(), LoadWalkControl::selectedFile(), and SaveWalkControl::takeInput().
marks a MotionCommand as unused
Definition at line 869 of file MotionManager.cc. Referenced by MMAccessor< MC_t >::checkin(), MCValueEditControl< T >::doSelect(), getOutputs(), processMsg(), RemoveAccess(), removeMotion(), LoadWalkControl::selectedFile(), and SaveWalkControl::takeInput().
allows access to a MotionCommand without checking it out; warning never call a function based on this, only access member fields through it
Definition at line 142 of file MotionManager.h. Referenced by MMAccessor< MC_t >::MMAccessor(), Controller::setEStopID(), and BatteryMonitorBehavior::startWarning().
returns the number of times mcid has been checked out minus the times it's been checked in
Definition at line 143 of file MotionManager.h.
locks the command and possibly performs RTTI conversion; supports recursive calls
Definition at line 144 of file MotionManager.h.
LOCKS MotionManager adds a new motion (wrapped in a SharedObject) and marks that it should be automatically deleted when the MotionCommand::isAlive() returns false.
Definition at line 150 of file MotionManager.h. Referenced by AutoGetupBehavior::processEvent(), RunSequenceControl< SequenceSize >::runFile(), LoadPostureControl::runFile(), TorqueCalibrate::TakeMeasurementControl::takeInput(), and MotionSequenceNode< SIZE >::updateMS().
LOCKS MotionManager adds a new motion (wrapped in a SharedObject) and marks that it should not be deleted, until removeMotion(MC_ID mcid) is called.
Definition at line 152 of file MotionManager.h. Referenced by WaypointWalkControl::activate(), TorqueCalibrate::TakeMeasurementControl::activate(), PostureEditor::activate(), WalkToTargetNode::DoStart(), WalkControllerBehavior::DoStart(), UPennWalkControllerBehavior::DoStart(), MCNodeBase::DoStart(), HeadPointControllerBehavior::DoStart(), Controller::DoStart(), RunSequenceControl< SequenceSize >::selectedFile(), LoadPostureControl::selectedFile(), and BatteryMonitorBehavior::startWarning().
LOCKS MotionManager removes the specified MotionCommand
Definition at line 883 of file MotionManager.cc. Referenced by WaypointWalkControl::deactivate(), TorqueCalibrate::TakeMeasurementControl::deactivate(), PostureEditor::deactivate(), WalkToTargetNode::DoStop(), WalkControllerBehavior::DoStop(), UPennWalkControllerBehavior::DoStop(), MotionSequenceNode< SIZE >::DoStop(), MCNodeBase::DoStop(), HeadPointControllerBehavior::DoStop(), Controller::DoStop(), getOutputs(), RunSequenceControl< SequenceSize >::processEvent(), LoadPostureControl::processEvent(), MCNodeBase::setMC(), BatteryMonitorBehavior::stopWarning(), MotionSequenceNode< SIZE >::teardown(), LoadPostureControl::~LoadPostureControl(), and RunSequenceControl< SequenceSize >::~RunSequenceControl().
gets an exclusive lock on MotionManager - functions marked LOCKS MotionManager will cause (and require) this to happen automatically
Definition at line 157 of file MotionManager.h. Referenced by checkinMotion(), and checkoutMotion().
LOCKS MotionManager called by MotionObject to fill in the output values for the next NumFrames frames (only MotoObj should call this...) What's worse? A plethora of functions which are only called, and only useful at one place, or a big massive function which doesn't pollute the namespace? This is the latter, for better or worse. Definition at line 297 of file MotionManager.cc.
call this when you want MotionManager to update modified PID values, returns true if changes made (only MotoObj should be calling this...), see PIDMC for general PID documentation This function handles the conversion from the Tekkotsu format (one regular IEEE float per parameter, to the OPEN-R format (which takes a specialized, reduced precision floating point number) This is all documented in PIDMC as well. In order to send Tekkotsu's PIDs to the system, they are converted to the gain/shift format. On the ERS-2xx, we could dynamically choose shift values to allow more precision in setting values. With the ERS-7, all shifts are shared, so they must be set to a common set of values, defined by WorldState::DefaultPIDShifts. This limits the range of gains which can then be set. Due to the mysterious warning which would occur with the 2xx, (AGRMSDriver::SetGain() : 0x0A IS USED FOR GAIN SHIFT VALUE.) and since this seems to be the way things are going, all models now, by default, use global shift values (which can vary from model to model, just global for each model) You can revert to the dynamic shift selection by commenting-in the noted code section below. A final note: the OPENR::SetJointGain function seems to be a rather costly function call. You should probably try to avoid setting PIDs at too high a frequency. Definition at line 556 of file MotionManager.cc.
does the actual work of adding a motion We have made this function protected because it's more readable if you call addPrunableMotion() or addPersistentMotion() instead... we decided requiring people to pass a true/false arguement wouldn't make it clear what that true/false was controlling. Definition at line 750 of file MotionManager.cc. Referenced by addPersistentMotion(), and addPrunableMotion().
sets up a motion command to be accessed by the current process
Definition at line 851 of file MotionManager.cc. Referenced by checkoutMotion(), and processMsg().
LOCKS MotionManager, called internally to do the work of setting the PID... you probably want to call setOutput with an OutputPID argument, not this... Note that we don't actually set the PIDs in the system here, we just queue them up. PID changes seem to be an expensive operation, so may only want to clear the queue at some reduced rate (although that's not actually currently being done, it just could be) Definition at line 953 of file MotionManager.cc. Referenced by getOutputs(), and setOutput().
called at the begining of many functions to lock MotionManager
Definition at line 213 of file MotionManager.h. Referenced by doAddMotion(), getOutputs(), processMsg(), RemoveAccess(), removeMotion(), setOutput(), setPID(), and ~MotionManager().
called at the end of a function which called func_begin() to release it
Definition at line 214 of file MotionManager.h. Referenced by doAddMotion(), func_end(), getOutputs(), processMsg(), RemoveAccess(), removeMotion(), setOutput(), setPID(), and ~MotionManager().
template<class T>
same as func_end(), except passes return value through
Definition at line 215 of file MotionManager.h.
during iteration, skips over motioncommands which are still in transit from on OObject to another
Definition at line 991 of file MotionManager.cc.
pulls an entry from cmdlist's free section and returns its index
Definition at line 241 of file MotionManager.h. Referenced by doAddMotion().
puts an entry back into cmdlist's free section
Definition at line 242 of file MotionManager.h. Referenced by processMsg(), RemoveAccess(), and ~MotionManager().
Definition at line 261 of file MotionManager.h. Referenced by checkinMotion(), checkoutMotion(), convertMotion(), doAddMotion(), func_begin(), InitAccess(), isOwner(), lock(), peekMotion(), processMsg(), receivedMsg(), RemoveAccess(), removeMotion(), skip_ahead(), trylock(), and ~MotionManager().
this shouldn't be called...
Member Data Documentation
This is the number of processes which will be accessing the MotionManager. Probably just MainObject and MotionObject... This isn't really a hard maximum, but should be actual expected, need to know when they're all connected Definition at line 89 of file MotionManager.h. Referenced by MotionManager::CommandEntry::CommandEntry(), doAddMotion(), and InitAccess().
This is the maximum number of Motions which can be managed, can probably be increased reasonably without trouble.
Definition at line 91 of file MotionManager.h. Referenced by checkinMotion(), checkoutMotion(), and removeMotion().
for errors and undefined stuff
Definition at line 94 of file MotionManager.h. Referenced by WaypointWalkControl::activate(), ValueSetControl< T >::activate(), PostureEditor::activate(), BehaviorSwitchActivatorControl::activate(), MMAccessor< MC_t >::checkin(), checkinMotion(), checkoutLevel(), checkoutMotion(), WaypointWalkControl::deactivate(), TorqueCalibrate::TakeMeasurementControl::deactivate(), PostureEditor::deactivate(), ControlBase::deactivate(), BatteryCheckControl::deactivate(), doAddMotion(), ControlBase::doReadStdIn(), ControlBase::doSelect(), MCNodeBase::DoStart(), WalkToTargetNode::DoStop(), MotionSequenceNode< SIZE >::DoStop(), MCNodeBase::DoStop(), Controller::DoStop(), MCNode< T, mcName, mcDesc, completes >::getMC(), getOutputs(), isOwner(), MMAccessor< MC_t >::MMAccessor(), BatteryCheckControl::pause(), peekMotion(), TorqueCalibrate::TakeMeasurementControl::processEvent(), RunSequenceControl< SequenceSize >::processEvent(), MotionSequenceNode< SIZE >::processEvent(), LoadPostureControl::processEvent(), processMsg(), ControlBase::refresh(), removeMotion(), BatteryCheckControl::report(), LoadWalkControl::selectedFile(), MCNodeBase::setMC(), setOutput(), BatteryMonitorBehavior::stopWarning(), SaveWalkControl::takeInput(), MotionSequenceNode< SIZE >::teardown(), MotionSequenceNode< SIZE >::updateMS(), LoadPostureControl::~LoadPostureControl(), and RunSequenceControl< SequenceSize >::~RunSequenceControl().
won't be expressed, handy if you want to temporarily pause something
Definition at line 98 of file MotionManager.h. Referenced by Controller::deactivate(), Controller::DoStart(), MCNodeBase::DoStop(), and BatteryMonitorBehavior::processEvent().
will only be expressed if *nothing* else is using that joint
Definition at line 99 of file MotionManager.h. Referenced by setOutput().
for stuff that's not background but lower than standard
Definition at line 100 of file MotionManager.h.
for every-day commands
Definition at line 101 of file MotionManager.h. Referenced by MCNodeBase::DoStart().
for stuff that should override standard stuff
Definition at line 102 of file MotionManager.h. Referenced by TorqueCalibrate::TakeMeasurementControl::activate(), and AutoGetupBehavior::processEvent().
for really important stuff, such as the emergency stop
Definition at line 103 of file MotionManager.h. Referenced by Controller::activate(), Controller::DoStart(), BatteryMonitorBehavior::processEvent(), and BatteryMonitorBehavior::startWarning().
stores PID updates, up to one per joint (if same is set more than once, it's just overwrites previous update)
Definition at line 208 of file MotionManager.h. Referenced by setPID(), and updatePIDs().
the list where MotionCommands are stored, remember, we're in a shared memory region with different base addresses - no pointers!
Definition at line 237 of file MotionManager.h. Referenced by begin(), checkinMotion(), checkoutLevel(), checkoutMotion(), convertMotion(), doAddMotion(), end(), getOutputs(), getPriority(), InitAccess(), isOwner(), next(), peekMotion(), pop_free(), processMsg(), push_free(), RemoveAccess(), removeMotion(), setPriority(), size(), skip_ahead(), and ~MotionManager().
MC_ID of the MotionCommand currently being updated by getOutputs(), or NULL if not in getOutputs. This is used by the setOutput()'s to tell which MotionCommand is calling.
Definition at line 238 of file MotionManager.h. Referenced by getOutputs(), and setOutput().
The main lock for the class.
Definition at line 244 of file MotionManager.h. Referenced by func_begin(), func_end(), InitAccess(), lock(), trylock(), and unlock().
requested positions by each of the MC's for each of the outputs
Definition at line 247 of file MotionManager.h. Referenced by getOutputs(), and setOutput().
Holds the final values for the outputs of the last frame generated.
Definition at line 248 of file MotionManager.h. Referenced by getOutputs(), MotionManager(), and setOutput().
Holds the weighted values and total weight for the outputs of the last frame.
Definition at line 249 of file MotionManager.h. Referenced by getOutputCmd(), getOutputs(), and MotionManager::OutputState::OutputState().
The number of accessors who have registered with InitAccess().
Definition at line 251 of file MotionManager.h. Referenced by doAddMotion(), InitAccess(), processMsg(), RemoveAccess(), and ~MotionManager().
Storage of each process's attachment of the message queue, used to internally transmit sound buffers to SoundPlay.
Definition at line 256 of file MotionManager.h. Referenced by doAddMotion(), InitAccess(), and removeMotion().
message receivers which watch for incoming motion command regions, or requests to free them
Definition at line 257 of file MotionManager.h. Referenced by InitAccess(), and RemoveAccess().
pointers to per-process thread locks, acquired during message processing from one of mcrecvs
Definition at line 258 of file MotionManager.h. Referenced by InitAccess(), and receivedMsg().
Stores the accessor id assigned in InitAccess() for each process.
Definition at line 262 of file MotionManager.h. Referenced by getAccID(), and InitAccess().
EventTranslator for sending events to Main -- each process will set the correct value for calls within that process.
Definition at line 263 of file MotionManager.h. Referenced by convertMotion(), and setTranslator().
The documentation for this class was generated from the following files: |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:58:32 2007 by Doxygen 1.5.4 |