📄 environ.h
字号:
/* Optann, a Khepera simulator including a separate GA and ANN (Genetic Algoritm, Artificial Neural Net). Copyright (C) 2000 Johan Carlsson (johanc@ida.his.se) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#ifndef ENVIRON_H#define ENVIRON_H#include <stdlib.h>#include <stdio.h>#include <iostream.h>/* GUI related */#ifdef GUI#include <world.h>#include <callbacks.h>#include <semaphore.h>#include <unistd.h>#endif /* GUI *//* Simlib related */#include "param.h"#include "geom.h"#include "wall.h"#include "obst.h"#include "sobst.h"#include "light.h"#include "robot.h"#include "zone.h"#include "gripperrobot.h"/** * @enum crash_t environ.h * @brief Different types of chrashes */enum crash_t { /** No crash. */ NO_CRASH=0, /** Collision with a wall. */ WALL_CRASH=1, /** Collision with another robot. */ ROBOT_CRASH=2, /** Collision with a round obstacle. */ OBST_CRASH=3, /** Collision with a small round obstacle. */ SOBST_CRASH=4, /** Collision caused by the gripper */ GRIPPER_CRASH=5};/** * @class Environ environ.h * @brief Container for world elements and robots. * * Implements most of the functions for a simulation, such as * check for crashes, sensor generation and such alike. */class Environ{ public: Environ(); ~Environ(); void initWorld(); void resetEnvironment(); void resetRobot(int whichRobot); int checkCrash(float p1, float p2) const; crash_t checkCrash(int whichRobot, int *which) const; int notPlacedOk(int obstNr, float x, float y, float radius) const; void placeSObstStack(float cx, float cy, float rd); void resetObstacle(int whichObstacle); void moveSObst(int relativeRobot); int checkCrash(int whichRobot) const; void setInput(int robotNr); void loadWorld(const char *fileName); void saveWorld(const char *fileName); void printInput(int robotNr, const char* str) const; int zonesVisited(int robotNr) const; void resetZones(); void runGripper(float o1, float o2, int robotNr); int inZoneI(int robotNr, int index) const; float getZoneX(int index) const; float getZoneY(int index) const; void setTaken(int index);#ifdef GUI void redrawWorld(); void drawBots(); void drawSensor(int xs, int ys, double value,int w);#endif /* GUI */ void printWorld() const; void runStep(float o1, float o2, int robotNr); int getNrOfZones() const; int getNrOfSObst() const; int getNrOfWalls() const; int getNrOfLights() const; int getNrOfObst() const; /** Array containing the robots. */ Robot **robot; /** The number of robots in the world. */ int nrOfRobots; /** World charthesian extension */ int dx,dy; private: int inZone(int robotNr) const; void addToInputArray(int robotNr, float *sens); /** Light sources */ Light **light; /** Walls */ Wall **wall; /** Round obstacles */ Obst **obst; /** Small round obstacles */ Sobst **sobst; /** World zones */ Zone **zone; /** Start positions for robots. */ float **start; /** Nr of walls in the world. */ int nrOfWalls; /** Nr of round obstacles in the world (does not include small round obstacles). */ int nrOfObst; /** Nr of small round obstacles. */ int nrOfSObst; /** Nr of light sources in the world. */ int nrOfLights; /** Nr of start positions. */ int nrOfStartPositions; /** Nr of zones in the world. */ int nrOfZones;};#endif /* ENVIRON_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -