Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

WaypointWalkMC.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_WaypointWalk_h_
00003 #define INCLUDED_WaypointWalk_h_
00004 
00005 #include "IPC/ListMemBuf.h"
00006 #include "WaypointEngine.h"
00007 #include "WalkMC.h"
00008 
00009 //! Combines a WaypointEngine with a WalkMC so you can walk between a set of waypoints
00010 /*! Note the use of a template so we can have dedicate more or less
00011  *  space without modifying the class.
00012  *  
00013  *  But for everyday use, you can just use the ::WaypointWalkMC typedef
00014  *  which will default to a maximum of 100 waypoints */
00015 class WaypointWalkMC : public WalkMC, public WaypointEngine {
00016 public:
00017   
00018   //!constructor
00019   WaypointWalkMC()
00020     : WalkMC(), WaypointEngine()
00021   {}
00022 
00023   //!constructor
00024   WaypointWalkMC(char * f)
00025     : WalkMC(), WaypointEngine(f)
00026   {}
00027   
00028   void setDirty() { dirty = true; }
00029 
00030   //! so we can get our hooks in to modify the target velocity
00031   virtual int updateOutputs() {
00032     //std::cout << "WaypointWalkMC::updateOutputs()  " << WaypointEngine::curVel[0] << " " << WaypointEngine::curVel[1] << " " << WaypointEngine::curVel[2] << " isRunning=" << isRunning << " dirty=" << dirty << std::endl;
00033 #ifdef TGT_HAS_WHEELEDWALK
00034     dirty = true;  // necessary so the null case with no waypoints still generates a LocomotionEvent
00035 #endif
00036     if ( WaypointEngine::cycle() )
00037       WalkMC::setTargetVelocity(WaypointEngine::curVel[0],WaypointEngine::curVel[1],WaypointEngine::curVel[2]);
00038     //cout << get_time()-waypointTime << " Cur: ("<<curPos[0]<<','<<curPos[1]<<','<<curPos[2]<<")  Ideal: ("<<idealPos[0]<<','<<idealPos[1]<<','<<idealPos[2]<<','<<idealPos[3]<<")  Vel: ("<<curVel[0]<<','<<curVel[1]<<','<<curVel[2]<<")" << endl;
00039     return WalkMC::updateOutputs();
00040   }
00041 
00042   virtual int LoadWaypointFile(const char * f) { return WaypointEngine::loadFile(f); } //!< allows loading a waypoint file
00043   virtual int SaveWaypointFile(const char * f) const { return WaypointEngine::saveFile(f); } //!< allows saving a waypoint file
00044   virtual int LoadWalkMCFile(const char * f) { return WalkMC::loadFile(f); } //!< allows loading a WalkMC parameter file
00045   virtual int SaveWalkMCFile(const char * f) const { return WalkMC::saveFile(f); } //!< allows saving a WalkMC parameter file
00046 
00047 };
00048 
00049 /*! @file
00050  * @brief Defines WaypointWalk, which combines a WaypointEngine with a WalkMC so you can walk between a set of waypoints
00051  * @author ejt (Creator)
00052  */
00053 
00054 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:52 2016 by Doxygen 1.6.3