Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
MotionCommand Class Reference#include <MotionCommand.h>
Inheritance diagram for MotionCommand:
![]() Detailed DescriptionThe abstract base class for motions, provides common interface. All motions should inherit from this.For instructions on how to create:
To create a new type of motion, you'll want to subclass this. You don't need to do anything fancy, but just be sure to override the 3 abstract functions, updateOutputs(), isAlive(), and isDirty().
There is a quick-start boilerplate included in the distribution: project When an output is set to a value, that output is held at that value until it is set to a new value, even if the MotionCommand that set it is pruned or stops using the output. Outputs never "reset" to 0 or some other relatively arbitrary base value if all the MotionCommands are removed. However, PID values will reset to the default values if pruned or not set since these values do have a base value which you will want to use 99% of the time. Be aware that there is a delay between when you set a joint to a value and that actually is taken into account by the system - it's on the order of FrameTime*NumFrames (currently 8*4 = 32 ms, so worse case 2*8*4 = 64 ms) This is because the commands are double buffered. PIDs, on the other hand, seem to take effect more quickly. This un-synchronization can sometimes cause a bit of jerkiness (mainly on startup, where there's a large difference between desired and target values.) Here is the cycle of calls made by MotionManager to your command:
So, if you want to hold a joint at a value, each time your updateOutputs function is called, you should tell the MotionManager to keep the joint there (using one of MotionManager::setOutput()'s). If you do not set a joint after a call to updateOutputs, the MotionManager will assume you are no longer using that joint and a lower priority MotionCommand may inherit it. MotionCommands which generate events should use the inherited MotionCommand::postEvent() instead of trying to access a global erouter - the inherited version will properly handle sending the events regardless of the current process context, but trying to access a non-shared global like erouter could cause problems otherwise.
Definition at line 92 of file MotionCommand.h.
Constructor & Destructor Documentation
Constructor: Defaults to kStdPriority and autoprune==true.
Definition at line 124 of file MotionCommand.h.
don't call
Member Function Documentation
is called once per update cycle, can do any processing you need to change your priorities or set output commands on the MotionManager
Implemented in DynamicMotionSequence, EmergencyStopMC, HeadPointerMC, LedMC, MotionSequenceMC< MAXMOVE >, PIDMC, PostureMC, RemoteControllerMC, TailWagMC, UPennWalkMC, WalkMC, and WaypointWalk< MAX_WAY >. Referenced by MotionManager::getOutputs().
not used by MotionManager at the moment, but could be used to reduce recomputation, and you may find it useful
Implemented in DynamicMotionSequence, HeadPointerMC, LedMC, MotionSequenceMC< MAXMOVE >, PIDMC, PostureMC, TailWagMC, UPennWalkMC, and WalkMC.
used to prune "dead" motions from the MotionManager note that a motion could be "paused" or inactive and therefore not dirty, but still alive, biding its time to "strike" ;)
Implemented in DynamicMotionSequence, HeadPointerMC, LedMC, MotionSequenceMC< MAXMOVE >, PIDMC, PostureMC, RemoteControllerMC, TailWagMC, UPennWalkMC, and WalkMC. Referenced by shouldPrune().
called after this is added to MotionManager
Reimplemented in HeadPointerMC, LedMC, PIDMC, PostureMC, and WalkMC. Definition at line 133 of file MotionCommand.h. Referenced by WalkMC::DoStart(), PostureMC::DoStart(), PIDMC::DoStart(), LedMC::DoStart(), and HeadPointerMC::DoStart().
called after this is removed from MotionManager
Reimplemented in WalkMC. Definition at line 136 of file MotionCommand.h. Referenced by WalkMC::DoStop(), MotionManager::processMsg(), and MotionManager::removeMotion().
returns true if the MotionCommand is currently running (although it may be overridden by a higher priority MotionCommand)
Definition at line 139 of file MotionCommand.h.
Definition at line 142 of file MotionCommand.h. Referenced by PostureMC::isAlive(), and MotionManager::RemoveAccess().
Definition at line 145 of file MotionCommand.h. Referenced by MotionManager::doAddMotion().
whether this motion should be removed from its motion group automatically ( MotionCommand::autoprune && !isAlive())
Definition at line 149 of file MotionCommand.h. Referenced by MotionManager::getOutputs().
only called from MMCombo during process setup, allows MotionCommands to send events
Definition at line 152 of file MotionCommand.h. Referenced by MotionManager::checkinMotion(), and MotionManager::convertMotion().
this utility function will probably be of use to a lot of MotionCommand's Does a weighted average of a and b, favoring b by x percent (so x==0 results in a, x==1 results in b)
Definition at line 167 of file MotionCommand.h. Referenced by interpolate().
this utility function will probably be of use to a lot of MotionCommand's Does a weighted average of a and b, favoring b by x percent (so x==0 results in a, x==1 results in b)
Definition at line 177 of file MotionCommand.h.
this utility function will probably be of use to a lot of MotionCommand's, see interpolate(double a,double b,double r) interpolates both value and weights of JointCmd's
Definition at line 186 of file MotionCommand.h.
calls EventTranslator::trapEvent() directly (avoids needing erouter, which is a non-shared global, causes problems with context, grr, silly OS)
Definition at line 9 of file MotionCommand.cc. Referenced by WalkMC::DoStart(), WalkMC::DoStop(), EmergencyStopMC::freezeJoints(), EmergencyStopMC::releaseJoints(), WalkMC::updateOutputs(), TailWagMC::updateOutputs(), PostureMC::updateOutputs(), MotionSequenceMC< MAXMOVE >::updateOutputs(), and LedMC::updateOutputs().
This function sets all wheel values to 0.
Definition at line 17 of file MotionCommand.cc. Referenced by DoStop().
don't call
Member Data Documentation
send events using this, instead of posting to the erouter
Definition at line 197 of file MotionCommand.h. Referenced by postEvent(), and setTranslator().
default true, autoprune setting, if this is true and isAlive() returns false, MotionManager will attempt to remove the MC automatically
Definition at line 199 of file MotionCommand.h. Referenced by getAutoPrune(), setAutoPrune(), and shouldPrune().
true if the MotionCommand is currently running (although it may be overridden by a higher priority MotionCommand)
Definition at line 200 of file MotionCommand.h. Referenced by DoStart(), DoStop(), and isActive().
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 |