00001 /** 00002 * @file GTStandardConverter.h 00003 * 00004 * This file contains a class which wraps the GT2004-WorldModel 00005 * to the representation of the PotentialfieldComposition. 00006 * 00007 * @author <a href="mailto:timlaue@informatik.uni-bremen.de">Tim Laue</a> 00008 */ 00009 00010 #ifndef GT_STANDARD_CONVERTER_H_ 00011 #define GT_STANDARD_CONVERTER_H_ 00012 00013 00014 #include "PotentialfieldComposition.h" 00015 00016 class BallModel; 00017 class RobotPose; 00018 class PlayerPoseCollection; 00019 class ObstaclesModel; 00020 class TeamMessageCollection; 00021 class Pose2D; 00022 class string; 00023 00024 00025 /** 00026 * @class GTStandardConverter 00027 * 00028 * A class to use the PotentialfieldComposition inside the GT2004 architecture 00029 */ 00030 class GTStandardConverter 00031 { 00032 public: 00033 /** 00034 * Constructor. 00035 * @param fileName The name of a file containing a configuration for a PotentialFieldComposition. 00036 */ 00037 GTStandardConverter(const char* fileName); 00038 00039 /** Constructor */ 00040 GTStandardConverter(); 00041 00042 /** Loads a configuration file 00043 * @param filename The name of the file 00044 */ 00045 void load(const char* filename); 00046 00047 /** Calls the potential fields with data from the world model and returns an action 00048 * @param robotPose The robot's pose 00049 * @param ballPosition The position of the ball 00050 * @param playerPoseCollection The positions of all other robots 00051 * @param obstaclesModel Other obstacles 00052 * @param teamMessageCollection The collection of team messages. 00053 * @param result Returns the result 00054 */ 00055 void execute(const RobotPose& robotPose, 00056 const BallModel& ballPosition, 00057 const PlayerPoseCollection& playerPoseCollection, 00058 const ObstaclesModel& obstaclesModel, 00059 const TeamMessageCollection& teamMessageCollection, 00060 PotentialfieldResult& result); 00061 00062 /** Calls the potential fields with data from the world model and returns an action 00063 * @param robotPose The robot's pose 00064 * @param ballPosition The position of the ball 00065 * @param playerPoseCollection The positions of all other robots 00066 * @param obstaclesModel Other obstacles 00067 * @param teamMessageCollection The collection of team messages. 00068 * @param specialDestination1 A destination, e.g. for go-to-point skills 00069 * @param specialDestination2 A second destination 00070 * @param numberOfSpecialDestinations The number of used special destinations 0,1 or 2 00071 * @param teamMessageCollection Information from other robots 00072 * @param result Returns the result 00073 */ 00074 void execute(const RobotPose& robotPose, 00075 const BallModel& ballPosition, 00076 const PlayerPoseCollection& playerPoseCollection, 00077 const ObstaclesModel& obstaclesModel, 00078 const TeamMessageCollection& teamMessageCollection, 00079 const Pose2D& specialDestination1, 00080 const Pose2D& specialDestination2, 00081 const int& numberOfSpecialDestinations, 00082 PotentialfieldResult& result); 00083 00084 /** Computes an array of field values, used by visualization 00085 * @param robotPose The pose of the robot 00086 * @param ballPosition The position of the ball 00087 * @param playerPoseCollection The positions of all other robots 00088 * @param obstaclesModel The obstacles 00089 * @param teamMessageCollection The collection of team messages. 00090 * @param fieldname The name of the potential field 00091 * @param x1 Minimum x-coordinate to compute 00092 * @param y1 Minimum y-coordinate to compute 00093 * @param x2 Maximum x-coordinate to compute 00094 * @param y2 Maximum y-coordinate to compute 00095 * @param xSteps The computation steps in x-direction 00096 * @param ySteps The computation steps in y-direction 00097 * @param value An array containing all computed values, memory has to be allocated BEFORE calling the function 00098 * @param max Returns the maximum value 00099 * @param teamMessageCollection Information from other robots 00100 */ 00101 void getValueArray(const RobotPose& robotPose, 00102 const BallModel& ballPosition, 00103 const PlayerPoseCollection& playerPoseCollection, 00104 const ObstaclesModel& obstaclesModel, 00105 const TeamMessageCollection& teamMessageCollection, 00106 const std::string& fieldname, double x1, double y1, 00107 double x2, double y2, int xSteps, int ySteps, double value[], double& max); 00108 00109 /** Computes an array of gradient directions, used by visualization 00110 * @param robotPose The pose of the robot 00111 * @param ballPosition The position of the ball 00112 * @param playerPoseCollection The positions of all other robots 00113 * @param obstaclesModel The obstacles 00114 * @param teamMessageCollection The collection of team messages. 00115 * @param fieldname The name of the potential field 00116 * @param x1 Minimum x-coordinate to compute 00117 * @param y1 Minimum y-coordinate to compute 00118 * @param x2 Maximum x-coordinate to compute 00119 * @param y2 Maximum y-coordinate to compute 00120 * @param xSteps The computation steps in x-direction 00121 * @param ySteps The computation steps in y-direction 00122 * @param directions An array containing all computed gradients, memory has to be allocated BEFORE calling the function 00123 * @param teamMessageCollection Information from other robots 00124 */ 00125 void getDirectionArray(const RobotPose& robotPose, 00126 const BallModel& ballPosition, 00127 const PlayerPoseCollection& playerPoseCollection, 00128 const ObstaclesModel& obstaclesModel, 00129 const TeamMessageCollection& teamMessageCollection, 00130 const std::string& fieldname, double x1, double y1, 00131 double x2, double y2, int xSteps, int ySteps, PfVec directions[]); 00132 00133 00134 /** Returns the names of all fields within the potential field composition 00135 * @param fieldNames The names 00136 */ 00137 void getFieldNames(std::vector<std::string>& fieldNames); 00138 00139 private: 00140 /** An instance of the potential field implementation*/ 00141 PotentialfieldComposition potentialfields; 00142 /** Information about the ball*/ 00143 ObjectStateDescription seenBallDesc, ballDesc; 00144 /** Information about the robot, needed by some behaviors*/ 00145 ObjectStateDescription selfDesc; 00146 /** Information about the own team*/ 00147 ObjectStateDescription goalieDesc, player2Desc, player3Desc, player4Desc; 00148 ObjectStateDescription unknownTeammate1Desc, unknownTeammate2Desc, 00149 unknownTeammate3Desc, unknownTeammate4Desc; 00150 /** Information about the other team*/ 00151 ObjectStateDescription opponent1Desc, opponent2Desc, opponent3Desc, 00152 opponent4Desc, opponent5Desc, opponent6Desc; 00153 /** Information about special destinations*/ 00154 ObjectStateDescription destination1Desc, destination2Desc; 00155 /** Information about obstacles*/ 00156 ObjectStateDescription obstacleFrontDesc, obstacleLeftDesc, obstacleRightDesc, 00157 obstacleFrontLeftDesc, obstacleFrontRightDesc; 00158 /** Information about the free part of the goal*/ 00159 ObjectStateDescription freeGoalDesc; 00160 /** Position to look be looked at by goalie*/ 00161 ObjectStateDescription goalieLookingPositionDesc; 00162 /** The goalie position*/ 00163 ObjectStateDescription goaliePositionDesc; 00164 /** Angles to obstacles*/ 00165 double angleToFrontObstacle, angleToLeftObstacle, angleToRightObstacle, 00166 angleToFrontLeftObstacle, angleToFrontRightObstacle; 00167 /** Opening angle of an obstacle sector*/ 00168 double openingAngle; 00169 00170 /** Updates the potentialfields with data from the world model 00171 * @param robotPose The robot's pose 00172 * @param ballPosition The position of the ball 00173 * @param playerPoseCollection The positions of all other robots 00174 * @param obstaclesModel The obstacles 00175 * @param teamMessageCollection The collection of team messages. 00176 */ 00177 void setData(const RobotPose& robotPose, 00178 const BallModel& ballPosition, 00179 const PlayerPoseCollection& playerPoseCollection, 00180 const ObstaclesModel& obstaclesModel, 00181 const TeamMessageCollection& teamMessageCollection); 00182 }; 00183 00184 00185 #endif //GT_STANDARD_CONVERTER_H_ 00186 00187 00188 /* 00189 * $Log: GTStandardConverter.h,v $ 00190 * Revision 1.4 2004/09/09 11:37:39 wachter 00191 * - Fixed some more doxygen-errors 00192 * 00193 * Revision 1.3 2004/09/09 10:15:57 spranger 00194 * fixed doxygen-errors 00195 * 00196 * Revision 1.2 2004/06/17 16:20:30 tim 00197 * improved ;-) 00198 * 00199 * Revision 1.1 2004/05/24 13:45:10 tim 00200 * added potential field viewer again 00201 * 00202 */