Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
MotionCommand Class ReferenceThe abstract base class for motions, provides common interface. All motions should inherit from this. More...
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. Referenced by DynamicMotionSequence::DynamicMotionSequence().
Destructor. Definition at line 130 of file MotionCommand.h.
don't call Member Function Documentation
Override this if you want to run some startup code after being added to the MotionManager. Reimplemented in ArmMC, GaitedFootstepMC, HeadPointerMC, LedMC, PIDMC, and PostureMC. Definition at line 161 of file MotionCommand.h. Referenced by start().
Override this if you want to clean up after removal from MotionManager. The old MotionManagerMsg::mc_id will still be available, but this value is no longer valid within the MotionManager. Only use it if you need to clean up associated values stored elsewhere. Reimplemented in GaitedFootstepMC. Definition at line 165 of file MotionCommand.h. Referenced by stop().
Definition at line 142 of file MotionCommand.h. Referenced by PostureMC::isAlive(), HeadPointerMC::isAlive(), ArmMC::isAlive(), and MotionManager::RemoveAccess().
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 193 of file MotionCommand.h. 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 184 of file MotionCommand.h.
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 174 of file MotionCommand.h. Referenced by interpolate().
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.
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 ArmMC, CMPackWalkMC, DynamicMotionSequence, GaitedFootstepMC, HeadPointerMC, LedMC, MotionSequenceMC< MAXMOVE >, PIDMC, PostureMC, RemoteControllerMC, SineMC, TailWagMC, UPennWalkMC, WheeledWalkMC, and XWalkMC. Referenced by shouldPrune().
not used by MotionManager at the moment, but could be used to reduce recomputation, and you may find it useful
Implemented in ArmMC, CMPackWalkMC, DynamicMotionSequence, GaitedFootstepMC, HeadPointerMC, LedMC, MotionSequenceMC< MAXMOVE >, PIDMC, PostureMC, SineMC, TailWagMC, UPennWalkMC, WheeledWalkMC, and XWalkMC.
don't call
calls EventTranslator::trapEvent() directly (avoids needing erouter, which is a non-shared global, causes problems with context, grr, silly OS) Definition at line 11 of file MotionCommand.cc. Referenced by EmergencyStopMC::freezeJoints(), EmergencyStopMC::releaseJoints(), XWalkMC::setTargetVelocity(), XWalkMC::updateOutputs(), TailWagMC::updateOutputs(), PostureMC::updateOutputs(), PIDMC::updateOutputs(), MotionSequenceMC< MAXMOVE >::updateOutputs(), LedMC::updateOutputs(), HeadPointerMC::updateOutputs(), ArmMC::updateOutputs(), XWalkMC::updateOutputsInitial(), and XWalkMC::zeroVelocities().
Definition at line 145 of file MotionCommand.h. Referenced by MotionManager::doAddMotion().
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().
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().
called after this is added to MotionManager; don't override this, use doStart instead Reimplemented in CMPackWalkMC, WheeledWalkMC, and XWalkMC. Definition at line 133 of file MotionCommand.h. Referenced by SineMC::getAcceleration(), SineMC::getCount(), SineMC::getOffsetTime(), SineMC::getSpeed(), SineMC::setParams(), SineMC::sync(), SineMC::syncAll(), and SineMC::updateOutputs().
called after this is removed from MotionManager; don't override this, use doStop instead Reimplemented in CMPackWalkMC, WheeledWalkMC, and XWalkMC. Definition at line 136 of file MotionCommand.h. Referenced by MotionManager::removeMotion().
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 ArmMC, CMPackWalkMC, DynamicMotionSequence, EmergencyStopMC, GaitedFootstepMC, HeadPointerMC, LedMC, MotionSequenceMC< MAXMOVE >, PIDMC, PostureMC, RemoteControllerMC, SineMC, TailWagMC, UPennWalkMC, WaypointWalkMC, WheeledWalkMC, and XWalkMC. Referenced by MotionManager::getOutputs(). Member Data Documentation
default true, autoprune setting, if this is true and isAlive() returns false, MotionManager will attempt to remove the MC automatically Definition at line 203 of file MotionCommand.h. Referenced by getAutoPrune(), setAutoPrune(), and shouldPrune().
send events using this, instead of posting to the erouter Definition at line 201 of file MotionCommand.h. Referenced by postEvent(), and setTranslator().
true if the MotionCommand is currently running (although it may be overridden by a higher priority MotionCommand) Definition at line 204 of file MotionCommand.h. Referenced by isActive(), start(), and stop(). The documentation for this class was generated from the following files: |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:59:13 2016 by Doxygen 1.6.3 |