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

Tools/Actorics/Kinematics.h

Go to the documentation of this file.
00001 /**
00002 * @file Kinematics.h
00003 *
00004 * Class Kinematics provides methods for robots kinematic calculations
00005 *
00006 * @author Max Risler
00007 * @author Uwe Düffert
00008 */
00009 
00010 #ifndef __Kinematics_h_
00011 #define __Kinematics_h_
00012 
00013 #include "Tools/Actorics/RobotVertices.h"
00014 #include "Representations/Motion/JointData.h"
00015 #include "Representations/Perception/SensorData.h"
00016 #include "Representations/Perception/CameraMatrix.h"
00017 
00018 #define LEFTLEG(leg) ((leg==Kinematics::fl)||(leg==Kinematics::hl))
00019 #define FORELEG(leg) ((leg==Kinematics::fr)||(leg==Kinematics::fl)||(leg==Kinematics::basefront))
00020 #define LEGBASE(leg) ((leg==Kinematics::basefront)||(leg==Kinematics::basehind))
00021 
00022 /**
00023 * @class Kinematics
00024 * Provides Methods for robots kinematic calculations
00025 * @author Max Risler
00026 */
00027 class Kinematics
00028 {
00029 public:
00030   enum LegIndex
00031   {
00032     fr,fl,hr,hl,basefront,basehind
00033   };
00034 
00035   enum GroundMode
00036   {
00037     constantMode, dynamicMode, staticMode, superMode, flyMode
00038   };
00039 
00040   /**
00041   * Calculates leg positon relative to the legs shoulder from given leg joint angles
00042   * @param leg The leg the that we will calculate with.
00043   * @param j1,j2,j3 Leg joint angles in rad
00044   * @param x,y,z Reference to variables for leg position
00045   * @param correctCalculation shall we calculate correctly and assume that knee is not in x-middle of leg?
00046   */
00047   static void legPositionFromJoints(LegIndex leg, double j1, double j2, double j3, double &x, double &y, double &z, bool correctCalculation=true);
00048 
00049   /**
00050   * Calculates knee positon relative to the legs shoulder from given leg joint angles
00051   * @param leg The leg the that we will calculate with.
00052   * @param j1,j2 Leg joint angles in rad
00053   * @param x,y,z Reference to variables for leg position
00054   * @param correctCalculation shall we calculate correctly and assume that knee is not in x-middle of leg?
00055   */
00056   static void kneePositionFromJoints(LegIndex leg, double j1, double j2, double &x, double &y, double &z, bool correctCalculation=true);
00057 
00058   /**
00059   * Calculates joint angles from given leg position
00060   * @param leg The leg the that we will calculate with.
00061   * @param x,y,z Leg position
00062   * @param j1,j2,j3 Reference to variables for leg joint angles in rad
00063   * @param bodyTilt The pre-calculated desired tilt of the robots body
00064   * @param correctCalculation shall we calculate correctly and assume that knee is not in x-middle of leg?
00065   * @return false if no possible joint position could be calculated
00066   */
00067   static bool jointsFromLegPosition(LegIndex leg, double x, double y, double z, double &j1, double &j2, double &j3, double bodyTilt=0, bool correctCalculation=true);
00068 
00069   /**
00070   * Calculates all robot vertices relative to the neck from given leg joint angles
00071   * @param robotVertices the data struct to be filled
00072   * @param jointData the source joint angles
00073   */
00074   static void getRelativeRobotVertices(RobotVertices& robotVertices, const JointData& jointData);
00075 
00076   /**
00077   * Calculates the transformation of relativeRobotVertices needed to make the robot stand on the grond
00078   * @param tilt The tilt angle to be calculated
00079   * @param roll The roll angle to be calculated
00080   * @param relativeRobotVertices vertices of the robot relative to the neck, e.g. calculated by getRelativeRobotVertices()
00081   * @param mode Mode of assumption about kind of ground contact
00082   * @param expectedBodyTilt You may provide an expected tilt angle of the body
00083   * @param expectedBodyRoll You may provide an expected roll angle of the body
00084   */
00085   static void getRobotTransformation(double& tilt,double& roll, const RobotVertices& relativeRobotVertices, const GroundMode mode, double expectedBodyTilt=0, double expectedBodyRoll=0);
00086 
00087   /**
00088   * Calculates all robot vertices to ground from given leg joint angles
00089   * @param robotVertices the data struct to be filled
00090   * @param mode Mode of assumption about kind of ground contact
00091   * @param jointData the source joint angles
00092   * @param expectedBodyTilt You may provide an expected tilt angle of the body
00093   * @param expectedBodyRoll You may provide an expected roll angle of the body
00094   */
00095   static void getAbsoluteRobotVertices(RobotVertices& robotVertices, const GroundMode mode, const JointData& jointData, double expectedBodyTilt=0, double expectedBodyRoll=0);
00096 
00097   /**
00098   * The function calculates the relative positions of possible floor contact points.
00099   * In contrast to getRelativeRobotVertices(), it works correctly.
00100   * All coordinates are relative to the neck joint.
00101   * @param rob The robot vertices that are calculated.
00102   * @param sensorData The joint positions of the robot.
00103   */
00104   static void calcRelativeRobotVertices(RobotVertices& rob, const SensorData& sensorData);
00105 
00106   /**
00107   * The function calculates the body tilt and the position of the feet and the neck of the robot.
00108   * bodyRoll == 0 is assumed.
00109   * @param sensorData The joint positions of the robot.
00110     * @param rob The position of the feet, knees, and the neck.
00111   */
00112   static void calcNeckAndLegPositions(const SensorData& sensorData, RobotVertices& rob);
00113 
00114   /**
00115   * The function calculates the camera matrix based on sensor data and the position of the neck.
00116   * @param tilt head tilt arc.
00117   * @param pan head pan arc.
00118   * @param roll head roll or tilt2 arc.
00119   * @param bodyTilt The height of the neck.
00120   * @param neckHeight The height of the neck.
00121   * @param cameraMatrix The resulting camera matrix.
00122   */
00123   static void calculateCameraMatrix(const double tilt, const double pan, const double roll, const double bodyTilt, const double neckHeight, CameraMatrix& cameraMatrix);
00124 
00125   /**
00126   * The function calculates the height of the Tilt2Center based on the sensor data.
00127   * @param headHeight The resulting headheight
00128   * @param bodyTilt The bodytilt the headheight is calculated for
00129   * @param neckHeight The neckheight the headheight is calculated for
00130   * @param sensorData The joint angles the headheight is calculated for.
00131   */
00132   static void calcHeadHeight(double& headHeight, const double bodyTilt, const double neckHeight, const SensorData& sensorData);
00133 
00134   /**
00135   * The function calculates the height of the nose based on the sensor data.
00136   * @param noseHeight The resulting noseheight
00137   * @param absHeadTilt The absolute headtilt the noseheight is calculated for
00138   * @param headHeight The headheight the noseheight is calculated for
00139   * @param bodyTilt The bodytilt the noseheight is calculated for
00140   * @param headRoll The headRoll the noseheight is calculated for
00141   */
00142   static void calcNoseHeight(double& noseHeight, const double absHeadTilt, const double headHeight, const double bodyTilt, const double headRoll);
00143 
00144   /**
00145   * The function calculates the absolute roll (Tilt in the head) based on the sensor data.
00146   * @param absRoll The resulting absolute roll
00147   * @param bodyTilt The bodytilt the tilt is calculated for.
00148   * @param sensorData The joint angles the tikt is calculated for.
00149   */
00150   static void calcAbsRoll(double& absRoll, const double bodyTilt, const SensorData& sensorData);
00151 
00152   /**
00153   * The function calculates the highest possible necktilt to reach the absolute headtilt.
00154   * @param absRoll The wanted absolute headroll
00155   * @param bodyTilt The bodytilt the tilt is calculated for.
00156   */
00157   static double calcHighestPossibleTilt(const double absRoll, const double bodyTilt);
00158 
00159   /**
00160   * The function calculates the lowest possible necktilt to reach the absolute headtilt.
00161   * @param absRoll The absolute roll
00162   * @param bodyTilt The bodytilt the tilt is calculated for.
00163   */
00164   static double calcLowestPossibleTilt(const double absRoll, const double bodyTilt);
00165 
00166     /**
00167     * The function calculates joints so that the head has a @param absRoll 
00168     * @param neckTilt The best fitting headTilt to reach absRoll
00169     * @param absRoll The resulting absolute headRoll
00170     * @param bodyTilt The body tilt.
00171   */
00172   static void calcAbsRollJoints(double& neckTilt, double& absRoll, const double bodyTilt);
00173 
00174 private:
00175   static char *stringFromLeg(LegIndex leg);
00176   static void transformToLegBase(LegIndex leg,double &x, double &y, double &z, double &lowerleg);
00177   static void calcLegPosition(Vector3<double>& kneePosition, Vector3<double>& footPosition,
00178     long joint1, long joint2, long joint3,
00179     const Vector3<double> shoulder,
00180     const Vector3<double>& upper, const Vector3<double>& lower);
00181 };
00182 
00183 #endif // __Kinematics_h_
00184 
00185 /*
00186 * Change log :
00187 * 
00188 * $Log: Kinematics.h,v $
00189 * Revision 1.5  2004/09/09 10:15:58  spranger
00190 * fixed doxygen-errors
00191 *
00192 * Revision 1.4  2004/05/26 17:40:31  dueffert
00193 * HeadState is replaced by BodyPosture and MotionInfo
00194 *
00195 * Revision 1.3  2004/05/26 17:32:17  dueffert
00196 * better data types used
00197 *
00198 * Revision 1.2  2004/05/26 15:54:02  dueffert
00199 * camera matrix calculation cleaned up
00200 *
00201 * Revision 1.1.1.1  2004/05/22 17:35:57  cvsadm
00202 * created new repository GT2004_WM
00203 *
00204 * Revision 1.11  2004/03/22 15:56:14  hodie
00205 * Fixed calcAbsRollJoints
00206 *
00207 * Revision 1.10  2004/03/20 09:55:27  roefer
00208 * Preparation for improved odometry
00209 *
00210 * Revision 1.9  2004/03/18 18:07:21  hodie
00211 * Some more absolute HeadControlModes
00212 * Absolute HeadPathPlanner
00213 *
00214 * Revision 1.8  2004/03/17 16:21:12  hodie
00215 * Some more absolute HeadControlModes
00216 * Absolute HeadPathPlanner
00217 *
00218 * Revision 1.7  2004/03/15 15:09:46  hodie
00219 * new absRoll and absStraightRoll
00220 * some new functions and tools
00221 * modified lookArounds
00222 *
00223 * Revision 1.6  2004/03/04 15:56:22  hodie
00224 * added calc -AbsTilt, -HeadHeight, and -NoseHeight
00225 *
00226 * Revision 1.5  2004/02/04 13:41:33  roefer
00227 * Some place holders for BB2004 modules added
00228 *
00229 * Revision 1.4  2004/01/28 21:55:50  roefer
00230 * RobotDimensions revised
00231 *
00232 * Revision 1.3  2003/12/19 15:55:13  dueffert
00233 * added default parameter for correct kinematics, so old version can still be used
00234 *
00235 * Revision 1.2  2003/12/09 14:21:48  dueffert
00236 * flyMode added to visualize theoretical footPositions in RadarViewer better
00237 *
00238 * Revision 1.1  2003/10/07 10:13:21  cvsadm
00239 * Created GT2004 (M.J.)
00240 *
00241 * Revision 1.3  2003/09/30 10:51:11  dueffert
00242 * typos fixed
00243 *
00244 * Revision 1.2  2003/09/26 15:28:10  juengel
00245 * Renamed DataTypes to representations.
00246 *
00247 * Revision 1.1  2003/09/26 11:40:40  juengel
00248 * - sorted tools
00249 * - clean-up in DataTypes
00250 *
00251 * Revision 1.4  2003/09/16 14:57:41  dueffert
00252 * tilt calculation in forward kinematics added
00253 *
00254 * Revision 1.3  2003/09/16 11:08:52  dueffert
00255 * doxygen comments improved
00256 *
00257 * Revision 1.2  2003/09/15 20:38:08  dueffert
00258 * forward kinematics improved
00259 *
00260 * Revision 1.1.1.1  2003/07/02 09:40:28  cvsadm
00261 * created new repository for the competitions in Padova from the 
00262 * tamara CVS (Tuesday 2:00 pm)
00263 *
00264 * removed unused solutions
00265 *
00266 * Revision 1.8  2003/03/03 17:34:57  risler
00267 * legPositionFromJoints adjusted to changed leg coordinate system
00268 *
00269 * Revision 1.7  2003/01/17 16:23:06  dueffert
00270 * started to add ground based calculations
00271 *
00272 * Revision 1.6  2002/11/27 13:52:17  dueffert
00273 * doxygen docu corrected
00274 *
00275 * Revision 1.5  2002/11/25 12:32:56  dueffert
00276 * bodyTilt should be used to calculate leg positions from joints and vice versa
00277 *
00278 * Revision 1.4  2002/11/19 15:43:03  dueffert
00279 * doxygen comments corrected
00280 *
00281 * Revision 1.3  2002/10/14 13:14:24  dueffert
00282 * doxygen comments corrected
00283 *
00284 * Revision 1.2  2002/09/22 18:40:53  risler
00285 * added new math functions, removed GTMath library
00286 *
00287 * Revision 1.1  2002/09/10 15:53:58  cvsadm
00288 * Created new project GT2003 (M.L.)
00289 * - Cleaned up the /Src/DataTypes directory
00290 * - Removed challenge related source code
00291 * - Removed processing of incoming audio data
00292 * - Renamed AcousticMessage to SoundRequest
00293 *
00294 * Revision 1.1.1.1  2002/05/10 12:40:32  cvsadm
00295 * Moved GT2002 Project from ute to tamara.
00296 *
00297 * Revision 1.1  2002/04/04 11:02:16  risler
00298 * added class Kinematics
00299 *
00300 *
00301 */

Generated on Thu Sep 23 19:57:37 2004 for GT2004 by doxygen 1.3.6