9 #include <walk_and_kick/wak_plot.h>
10 #include <ros/console.h>
12 #include <Eigen/StdVector>
17 #define TINC 0.040f // System iteration time (relevant for instance for velocities and accelerations)
18 #define LED_PERIOD 1.0f // Time period for the regular updates to the LED state
19 #define INVALID_DIST 100000.0f // Used to signify an invalid distance
22 #define TO_COUNT(time) ((int)((time)/(TINC) + 0.5f)) // This assumes for the rounding that time is always positive!
25 namespace walk_and_kick
36 KT_DEFAULT = KT_MANUAL
38 const std::string KickoffTypeName[KT_COUNT] = {
45 inline bool kickoffTypeValid(
int type) {
return (type > KT_UNKNOWN && type < KT_COUNT); }
46 inline bool kickoffTypeValid(KickoffType type) {
return kickoffTypeValid((
int) type); }
47 inline const std::string& kickoffTypeName(KickoffType type) {
if(kickoffTypeValid(type))
return KickoffTypeName[type];
else return KickoffTypeName[KT_UNKNOWN]; }
59 const std::string ButtonStateName[BTN_COUNT] = {
66 inline bool buttonStateValid(
int state) {
return (state > BTN_UNKNOWN && state < BTN_COUNT); }
67 inline bool buttonStateValid(ButtonState state) {
return buttonStateValid((
int) state); }
68 inline const std::string& buttonStateName(ButtonState state) {
if(buttonStateValid(state))
return ButtonStateName[state];
else return ButtonStateName[BTN_UNKNOWN]; }
79 const std::string GameCommandName[CMD_COUNT] = {
85 inline bool gameCommandValid(
int command) {
return (command > CMD_UNKNOWN && command < CMD_COUNT); }
86 inline bool gameCommandValid(GameCommand command) {
return gameCommandValid((
int) command); }
87 inline const std::string& gameCommandName(GameCommand command) {
if(gameCommandValid(command))
return GameCommandName[command];
else return GameCommandName[CMD_UNKNOWN]; }
96 ROLE_DEFAULT = ROLE_FIELDPLAYER
98 const std::string GameRoleName[ROLE_COUNT] = {
103 inline bool gameRoleValid(
int role) {
return (role > ROLE_UNKNOWN && role < ROLE_COUNT); }
104 inline bool gameRoleValid(GameRole role) {
return gameRoleValid((
int) role); }
105 inline const std::string& gameRoleName(GameRole role) {
if(gameRoleValid(role))
return GameRoleName[role];
else return GameRoleName[ROLE_UNKNOWN]; }
106 inline bool gameRoleIsGoalie(GameRole role) {
return (role == ROLE_GOALIE); }
107 inline bool gameRoleIsFieldPlayer(GameRole role) {
return (gameRoleValid(role) && !gameRoleIsGoalie(role)); }
121 const std::string PlayStateName[PS_COUNT] = {
130 inline bool playStateValid(
int state) {
return (state > PS_UNKNOWN && state < PS_COUNT); }
131 inline bool playStateValid(PlayState state) {
return playStateValid((
int) state); }
132 inline const std::string& playStateName(PlayState state) {
if(playStateValid(state))
return PlayStateName[state];
else return PlayStateName[PS_UNKNOWN]; }
143 const std::string DiveDirectionName[DD_COUNT] = {
149 inline bool diveDirectionValid(
int dirn) {
return (dirn >= DD_NONE && dirn < DD_COUNT); }
150 inline bool diveDirectionValid(DiveDirection dirn) {
return diveDirectionValid((
int) dirn); }
151 inline const std::string& diveDirectionName(DiveDirection dirn) {
if(diveDirectionValid(dirn))
return DiveDirectionName[dirn];
else return DiveDirectionName[DD_NONE]; }
154 typedef Eigen::Vector2f Vec2f;
155 typedef Eigen::Vector3f Vec3f;
156 typedef std::vector<Vec2f, Eigen::aligned_allocator<Vec2f> > Vec2fArray;
157 typedef std::vector<Vec3f, Eigen::aligned_allocator<Vec3f> > Vec3fArray;
163 GoalPost() : vec(0.0f, 0.0f), conf(0.0f) {}
167 typedef std::vector<GoalPost> GoalPostList;
172 Obstacle() { reset(); }
173 void reset() { vec.setZero(); dist = 0.0f; conf = 0.0f;
id = -1; }
174 bool valid()
const {
return (conf > 0.0f &&
id >= 0); }
175 void setVec(
float x,
float y) { vec << x, y; dist = vec.norm(); }
181 typedef std::vector<Obstacle> ObstacleList;
unsigned int cycle_t
Used to count the number of executed state controller cycles.
Definition: state_controller.h:415