Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Modules/WalkingEngine/GT2004WalkingEngine.h

Go to the documentation of this file.

    00001 /**
    00002 * @file GT2004WalkingEngine.h
    00003 *
    00004 * Definition of class GT2004WalkingEngine
    00005 *
    00006 * @author Uwe Düffert
    00007 */
    00008
    00009 #ifndef __GT2004WalkingEngine_h_
    00010 #define __GT2004WalkingEngine_h_
    00011
    00012 #include "WalkingEngine.h"
    00013 #include "InvKinWalkingEngine.h"
    00014 #include "GT2004ParameterSet.h"
    00015 #include "Tools/Actorics/Kinematics.h"
    00016 #include "Tools/Evolution/Individual.h"
    00017
    00018
    00019 /**
    00020 * @class GT2004WalkingEngine
    00021 *
    00022 * Walking engine based on
    00023 * calculation of rectangular foot movement and
    00024 * inverse kinematics
    00025 *
    00026 * @author Uwe Dueffert
    00027 */
    00028 class GT2004WalkingEngine : public WalkingEngine
    00029 {
    00030 public:
    00031 /**
    00032 * Constructor.
    00033 * @param interfaces The paramters of the WalkingEngine module.
    00034   */
    00035   GT2004WalkingEngine(const WalkingEngineInterfaces& interfaces);
    00036
    00037   /**
    00038   * Destructor
    00039   */
    00040   ~GT2004WalkingEngine();
    00041
    00042   /** Executes the engine */
    00043   virtual bool executeParameterized(JointData& jointData, const WalkRequest& walkRequest, double positionInWalkingCycle);
    00044
    00045   /**
    00046   * Called from a MessageQueue to distribute messages
    00047   * @param message The message that can be read.
    00048   * @return true if the message was read (handled).
    00049   */
    00050   virtual bool handleMessage(InMessage& message);
    00051
    00052   /**
    00053   * find correct table entry to update (in turnOnly and withWalk):
    00054   * find the entry most similar to nextParameters, copy the old
    00055   * value to lastParameters, set parametersToChange and start
    00056   * interpolation
    00057   * @param steps Number of interpolation steps from old to new parameters
    00058   */
    00059   void setNextParameters(int steps);
    00060
    00061 private:
    00062   /** a set of GT2004Parameters optimized for different requests */
    00063   GT2004ParametersSet paramSet;
    00064
    00065   //!@name parameter set interpolation
    00066   //!@{
    00067   /** Points to parameter set currently in use */
    00068   GT2004Parameters* currentParameters;
    00069
    00070   /** Fixed parameter set for InvKin compatibility */
    00071   GT2004Parameters fixedParameters;
    00072
    00073   /** Pointer to the parameter set that shall be changed by interpolation */
    00074   GT2004Parameters *parametersToChange;
    00075
    00076   /** Next parameters of this walk, target of current interpolation */
    00077   GT2004Parameters nextParameters;
    00078
    00079   /** Last parameters of this walk, origin of current interpolation */
    00080   GT2004Parameters lastParameters;
    00081
    00082   /** Counts parameter set interpolation steps */
    00083   int paramInterpolCount;
    00084
    00085   /** Stores the length of the current parameter set interpolation */
    00086   int paramInterpolLength;
    00087
    00088   /** Stores precise version of currentStep for all kinds of interpolation */
    00089   double currentStepPercentage;
    00090
    00091   /** Initialize interpolation of WalkingParameterSets */
    00092   void initParametersInterpolation(int changeSteps);
    00093
    00094   /** Calculate next step in parameterset interpolation and increase currentStep if walk is true*/
    00095   void nextParametersInterpolation(bool walk);
    00096
    00097   //!@}
    00098   //!@name fixed gait parameters resulting from merged parameter set
    00099   //!@{
    00100   int groundTime[2];      ///< number of ticks foot is on ground
    00101   int liftTime[2];        ///< number of ticks for lifting foot
    00102   int loweringTime[2];    ///< number of ticks for lowering foot
    00103   int airTime[2];         ///< number of ticks foot is in air
    00104   int stepLift[2];        ///< time index for lifting foot
    00105   int stepAir[2];         ///< time index when foot is fully lifted
    00106   int stepLower[2];       ///< time index for lowering foot
    00107   int legPhaseIndex[4];   ///< leg phases, time indexes for lifting each leg
    00108   int firstStep;          ///< time index for first time all feet are on ground
    00109   //!@}
    00110
    00111   /** decides whether we use merging of rotationOnly and withWalk or fixedParameters */
    00112   bool useFixedParameters;
    00113
    00114   /** true if stuff like legSpeed has to be recalculated because of changed request or parameterset */
    00115   bool recalcEngineParameters;
    00116
    00117   unsigned long lastParametersFromPackageTimeStamp;
    00118
    00119   /** neck height in mm while walking */
    00120   double neckHeight;
    00121
    00122   /** body tilt angle */
    00123   double bodyTilt;
    00124
    00125   //!@name current walk values
    00126   //!@{
    00127   Vector2<double> legSpeed[4]; ///< speed of leg on ground (step size in mm)
    00128   // int currentStep;             ///< current step
    00129   Vector3<double> footPos[4];  ///< foot positions
    00130   //!@}
    00131
    00132   /** currently executed motion request
    00133   * speeds in mm/s
    00134   */
    00135   Pose2D currentRequest;
    00136
    00137   /** odometry resulting from current request
    00138   * speed in mm/tick
    00139   */
    00140   Pose2D odometry;
    00141
    00142   /** initialise fixed parameters */
    00143   void init();
    00144
    00145   /** calculate all engine wide parameters like neckHeight from currentParameters
    00146   * this is essential after every change in currentParameters!
    00147   */
    00148   void calculateParams();
    00149
    00150   /** smooth motion request
    00151   * current request is adjusted according to motion request
    00152   * eliminating quick changes */
    00153   void smoothMotionRequest(const Pose2D& request, Pose2D& currentRequest);
    00154
    00155   /** calculates new leg speeds according to current motion request */
    00156   void calculateLegSpeeds();
    00157
    00158   /** calculate relative foot position for one leg
    00159   * rx is relative to current step size (range -1.0..1.0)
    00160   * ry is an absolute offset to y foot position
    00161   * rz is relative to step lift parameter (range 0..1.0)
    00162   */
    00163   void calculateRelativeFootPosition(int step, int leg, double &rx, double &ry, double &rz);
    00164
    00165   /** calculate angles for one leg in current step */
    00166   int calculateLegJoints(Kinematics::LegIndex leg,
    00167     double &j1, double &j2, double &j3,
    00168     double bodyTilt=0);
    00169
    00170   /** calculate current joint data values */
    00171   void calculateData(JointData &j);
    00172
    00173   /** calculate current foot positions */
    00174   void calculateFootPositions();
    00175 };
    00176
    00177 #endif// __InvKinWalkingEngine_h_