Homepage Demos Overview Downloads Tutorials Reference
Credits

RunSequenceControl.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_RunSequenceControl_h_
00003 #define INCLUDED_RunSequenceControl_h_
00004 
00005 #include "FileBrowserControl.h"
00006 #include "Motion/MotionSequenceMC.h"
00007 #include "Shared/TimeET.h"
00008 #include "Shared/Config.h"
00009 #include <string>
00010 
00011 //! Upon activation, loads a position from a file name read from cin (stored in ms/data/motion...)
00012 /*! The template parameter is passed to MotionSequenceMC's template parameter in order
00013  *  to specify the number of keyframes to reserve - larger values use more memory, but will allow
00014  *  you to load more complicated sequences.
00015  */
00016 template<unsigned int SequenceSize>
00017 class RunSequenceControl : public FileBrowserControl, public EventListener {
00018 public:
00019   //! Constructor, sets filter to *.mot
00020   RunSequenceControl(const std::string& n, MotionManager::MC_ID estop_id)
00021     : FileBrowserControl(n,"Runs a motion sequence from a user-specified file",config->motion.root), estopid(estop_id)
00022   {
00023     setFilter("*.mot");
00024   }
00025 
00026   //! this is to help reduce the twitch at the end (estop tries to go back to its position when this is removed)
00027   virtual void processEvent(const EventBase& event) {
00028     erouter->removeListener(this,event);
00029     MMAccessor<EmergencyStopMC> estop(estopid);
00030     estop->takeSnapshot();
00031     estop->setActive(true);
00032   }
00033 
00034 protected:
00035   //!does the actual loading of the MotionSequence
00036   virtual ControlBase* selectedFile(const std::string& f) {
00037     //TimeET timer;
00038     SharedObject< MotionSequenceMC<SequenceSize> > s(f.c_str());
00039     //cout << "Load Time: " << timer.Age() << endl;
00040     MMAccessor<EmergencyStopMC>(estopid)->setActive(false);
00041     MotionManager::MC_ID id=motman->addMotion(s,MotionManager::kEmergencyPriority+1,true);
00042     erouter->addListener(this,EventBase::motmanEGID,id,EventBase::deactivateETID);
00043     return this;
00044   }
00045 
00046   MotionManager::MC_ID estopid; //!< MC_ID of the emergency stop (so we can reset it to the end frame)
00047 };
00048 
00049 /*! @file
00050  * @brief Defines RunSequenceControl, which when activated, loads and runs a motion sequence from a file name read from cin (stored in ms/data/motion)
00051  * @author ejt (Creator)
00052  *
00053  * $Author: ejt $
00054  * $Name: tekkotsu-2_0 $
00055  * $Revision: 1.10 $
00056  * $State: Rel $
00057  * $Date: 2003/07/14 06:55:14 $
00058  */
00059 
00060 #endif

Tekkotsu v2.0
Generated Wed Jan 21 03:20:29 2004 by Doxygen 1.3.4