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 result Returns the result 00072 */ 00073 void execute(const RobotPose& robotPose, 00074 const BallModel& ballPosition, 00075 const PlayerPoseCollection& playerPoseCollection, 00076 const ObstaclesModel& obstaclesModel, 00077 const TeamMessageCollection& teamMessageCollection, 00078 const Pose2D& specialDestination1, 00079 const Pose2D& specialDestination2, 00080 const int& numberOfSpecialDestinations, 00081 PotentialfieldResult& result); 00082 00083 /** Computes an array of field values, used by visualization 00084 * @param robotPose The pose of the robot 00085 * @param ballPosition The position of the ball 00086 * @param playerPoseCollection The positions of all other robots 00087 * @param obstaclesModel The obstacles 00088 * @param teamMessageCollection The collection of team messages. 00089 * @param fieldname The name of the potential field 00090 * @param x1 Minimum x-coordinate to compute 00091 * @param y1 Minimum y-coordinate to compute 00092 * @param x2 Maximum x-coordinate to compute 00093 * @param y2 Maximum y-coordinate to compute 00094 * @param xSteps The computation steps in x-direction 00095 * @param ySteps The computation steps in y-direction 00096 * @param value An array containing all computed values, memory has to be allocated BEFORE calling the function 00097 * @param max Returns the maximum value 00098 */ 00099 void getValueArray(const RobotPose& robotPose, 00100 const BallModel& ballPosition, 00101 const PlayerPoseCollection& playerPoseCollection, 00102 const ObstaclesModel& obstaclesModel, 00103 const TeamMessageCollection& teamMessageCollection, 00104 const std::string& fieldname, double x1, double y1, 00105 double x2, double y2, int xSteps, int ySteps, double value[], double& max); 00106 00107 /** Computes an array of gradient directions, used by visualization 00108 * @param robotPose The pose of the robot 00109 * @param ballPosition The position of the ball 00110 * @param playerPoseCollection The positions of all other robots 00111 * @param obstaclesModel The obstacles 00112 * @param teamMessageCollection The collection of team messages. 00113 * @param fieldname The name of the potential field 00114 * @param x1 Minimum x-coordinate to compute 00115 * @param y1 Minimum y-coordinate to compute 00116 * @param x2 Maximum x-coordinate to compute 00117 * @param y2 Maximum y-coordinate to compute 00118 * @param xSteps The computation steps in x-direction 00119 * @param ySteps The computation steps in y-direction 00120 * @param directions An array containing all computed gradients, memory has to be allocated BEFORE calling the function 00121 */ 00122 void getDirectionArray(const RobotPose& robotPose, 00123 const BallModel& ballPosition, 00124 const PlayerPoseCollection& playerPoseCollection, 00125 const ObstaclesModel& obstaclesModel, 00126 const TeamMessageCollection& teamMessageCollection, 00127 const std::string& fieldname, double x1, double y1, 00128 double x2, double y2, int xSteps, int ySteps, PfVec directions[]); 00129 00130 00131 /** Returns the names of all fields within the potential field composition 00132 * @param fieldNames The names 00133 */ 00134 void getFieldNames(std::vector<std::string>& fieldNames); 00135 00136 private: 00137 /** An instance of the potential field implementation*/ 00138 PotentialfieldComposition potentialfields; 00139 /** Information about the ball*/ 00140 ObjectStateDescription seenBallDesc, ballDesc; 00141 /** Information about the robot, needed by some behaviors*/ 00142 ObjectStateDescription selfDesc; 00143 /** Information about the own team*/ 00144 ObjectStateDescription goalieDesc, player2Desc, player3Desc, player4Desc; 00145 ObjectStateDescription unknownTeammate1Desc, unknownTeammate2Desc, 00146 unknownTeammate3Desc, unknownTeammate4Desc; 00147 /** Information about the other team*/ 00148 ObjectStateDescription opponent1Desc, opponent2Desc, opponent3Desc, 00149 opponent4Desc, opponent5Desc, opponent6Desc; 00150 /** Information about special destinations*/ 00151 ObjectStateDescription destination1Desc, destination2Desc; 00152 /** Information about obstacles*/ 00153 ObjectStateDescription obstacleFrontDesc, obstacleLeftDesc, obstacleRightDesc, 00154 obstacleFrontLeftDesc, obstacleFrontRightDesc; 00155 /** Information about the free part of the goal*/ 00156 ObjectStateDescription freeGoalDesc; 00157 /** Position to look be looked at by goalie*/ 00158 ObjectStateDescription goalieLookingPositionDesc; 00159 /** The goalie position*/ 00160 ObjectStateDescription goaliePositionDesc; 00161 /** Angles to obstacles*/ 00162 double angleToFrontObstacle, angleToLeftObstacle, angleToRightObstacle, 00163 angleToFrontLeftObstacle, angleToFrontRightObstacle; 00164 /** Opening angle of an obstacle sector*/ 00165 double openingAngle; 00166 00167 /** Updates the potentialfields with data from the world model 00168 * @param robotPose The robot's pose 00169 * @param ballPosition The position of the ball 00170 * @param playerPoseCollection The positions of all other robots 00171 * @param obstaclesModel The obstacles 00172 * @param teamMessageCollection The collection of team messages. 00173 */ 00174 void setData(const RobotPose& robotPose, 00175 const BallModel& ballPosition, 00176 const PlayerPoseCollection& playerPoseCollection, 00177 const ObstaclesModel& obstaclesModel, 00178 const TeamMessageCollection& teamMessageCollection); 00179 }; 00180 00181 00182 #endif //GT_STANDARD_CONVERTER_H_
1.3.6