Homepage Demos Overview Downloads Tutorials 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 "Shared/ListMemBuf.h"
00006 #include "WalkMC.h"
00007 #include "WaypointEngine.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 template<unsigned int MAX_WAY>
00016 class WaypointWalk : public WalkMC, public WaypointEngine<MAX_WAY> {
00017 public:
00018   static const unsigned int MAX_WAYPOINTS=MAX_WAY; //!< for external access to maximum waypoints
00019   
00020   //!constructor
00021   WaypointWalk()
00022     : WalkMC(), WaypointEngine<MAX_WAYPOINTS>()
00023   {}
00024 
00025   //!constructor
00026   WaypointWalk(char * f)
00027     : WalkMC(), WaypointEngine<MAX_WAYPOINTS>(f)
00028   {}
00029   
00030   //! so we can get our hooks in to modify the target velocity
00031   virtual int updateOutputs() {
00032     cycle();
00033     WalkMC::setTargetVelocity(curVel[0]*1000,curVel[1]*1000,curVel[2]);
00034     //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;
00035     return WalkMC::updateOutputs();
00036   }
00037 
00038   virtual int LoadWaypointFile(const char * f) { return WaypointEngine<MAX_WAYPOINTS>::LoadFile(f); } //!< allows loading a waypoint file
00039   virtual int SaveWaypointFile(const char * f) const { return WaypointEngine<MAX_WAYPOINTS>::SaveFile(f); } //!< allows saving a waypoint file
00040   virtual int LoadWalkMCFile(const char * f) { return WalkMC::LoadFile(f); } //!< allows loading a WalkMC parameter file
00041   virtual int SaveWalkMCFile(const char * f) const { return WalkMC::SaveFile(f); } //!< allows saving a WalkMC parameter file
00042 
00043 };
00044 
00045 typedef WaypointWalk<100> WaypointWalkMC; //!< unless you need more/less waypoints, just use this type
00046 
00047 
00048 /*! @file
00049  * @brief Defines WaypointWalk, which combines a WaypointEngine with a WalkMC so you can walk between a set of waypoints
00050  * @author ejt (Creator)
00051  *
00052  * $Author: ejt $
00053  * $Name: tekkotsu-2_2_2 $
00054  * $Revision: 1.3 $
00055  * $State: Exp $
00056  * $Date: 2004/07/27 14:33:59 $
00057  */
00058 
00059 #endif

Tekkotsu v2.2.2
Generated Tue Jan 4 15:43:16 2005 by Doxygen 1.4.0