📄 wall.h
字号:
/* YAKS, 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 WALL_H#define WALL_H#include <stdio.h>#include "param.h"#include "geom.h"/** * @class Wall wall.h * @brief This class implements walls. * * All walls share the same lookup table so they all look the same. * A robot CAN only see a wall if there exist a perpendicular vector * from the wall to the robot, that is there exist a line from the wall * so that the angle between the wall and the line is 90 degrees. * In order to project an edge of a wall on the robot sensors it is best * to place a round obstacle at the beginning and the end of the line. */class Wall{ public: Wall(FILE *fp); Wall(char *str); ~Wall(); void init(char *fileName); float *sensorVal(float x, float y, float kangle, float radius); double distR(float x, float y); void print(); /** The left side \a x coordinate of the wall */ float x1; /** The right side \a x coordinate of the wall */ float x2; /** The left side \a y coordinate of the wall */ float y1; /** The right side \a y coordinate of the wall */ float y2; /** The wall angle */ float angle; private: /** Shared lookup tanble for sensor readings*/ static float wall[20][180][8]; /** The \a t for the last call to distR() */ float t; /** Precalced delta x \f$ dx=x2-x1 \f$ */ float dx; /** Precalced delta y \f$ dy=y2-y1 \f$ */ float dy; /** Precacled \f$ ddxy = dx^2+dy^2 \f$ */ float ddxy; /** Shared step size, resolution for sensor values */ static float Step; /** Shared obstacle range for sensors */ static float MaxObstacleDistans; /** Shared distance from which obstacles gives maximum sensor values */ static float MinObstacleDistans;};#endif /* WALL_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -