📄 sensory.h
字号:
/*
Copyright (C) 2001 Tsinghuaeolus
Authors : ChenJiang, YaoJinyi, CaiYunpeng, Lishi
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
If you make any changes or have any comments we would appreciate a
message to yjy01@mails.tsinghua.edu.cn.
*/
#ifndef _sensory
#define _sensory
#include "netif.h"
#include "Params.h"
#include "Types.h"
class SenseBodyInfo{
public:
Time time;
float stamina;
float effort;
float speed;
AngleDeg rel_spd_angle;
AngleDeg head_angle;
VIEWWIDTH view_width;
VIEWQUALITY view_qual;
int kicks;
int dashes;
int turns;
int says;
int turn_necks;
void setvalues(VIEWWIDTH viewidth, VIEWQUALITY viewqual, float stamina,float effort,float speed,AngleDeg rel_spd_angle,AngleDeg head_angle,int kicks,
int dashes,int turns,int says,int turn_necks,Time time){
view_width = viewidth;
view_qual = viewqual;
this->stamina = stamina;
this->effort = effort;
this->speed = speed;
this->rel_spd_angle= rel_spd_angle;
this->head_angle = head_angle;
this->kicks = kicks;
this->dashes = dashes;
this->says = says;
this->turn_necks = turn_necks;
this->turns = turns;
this->time = time;
}
};
class Sensory{
private:
MarkerType MyGoal;
MarkerType TheirGoal;
/******** SenseBodyInfo ********************/
int latestsenseinfo;
SenseBodyInfo sensebodyinfo[2]; /* store latest two sense infomation*/
float dir_conf[CP_num_divisions];
Time dir_time;
TimedDataArray<MarkerType, CP_num_stored_markerinfos> ClosestMarker;
public:
Sensory();
/*************************************************************/
Time LatestTime;
Time PrevInterruptTime;
Time LastSightTime;
Time PrevSightTime;
Time LastSenseTime;
Time LastSoundTime;
Time PrevSenseTime;
SenseType LastSenseType;
VIEWQUALITY ViewQuality;
VIEWWIDTH ViewWidth;
VIEWWIDTH LastViewWidth;
VIEWWIDTH NextViewWidth;
bool NewSight;
bool NewSenseInfo;
bool NewSound;
bool TwiceSight;
/******************** SYNC *******************************************/
inline bool LastMsgIsSense(){return bool(LastSenseType==Sense_Msg);}
inline bool LastMsgIsSight(){return bool(LastSenseType==See_Msg);}
/******************** Parse *******************************************/
void Parse(char* SensoryInfo);
void Parse_Sense(Time time,char* SensoryInfo);
void Parse_Sight(Time time,char* SensoryInfo);
void Parse_Sound(Time time,char* SensoryInfo);
void Parse_ServerParams(char* SensoryInfo);
void Parse_PlayerParams(char* SensoryInfo);
void Parse_PlayerTypes(char* SensoryInfo);
void Parse_Referee_Sound(char *RefereeSound);
void Parse_Trainer_Sound(char *msg);
void Parse_My_Coach_Sound(Time time, char *msg){};
void Parse_Their_Coach_Sound(Time time, char *msg){};
void Parse_initialize_message(char *recvbuf);
/******************* Visual Information ********************************/
void SetMySensedInfo(VIEWWIDTH viewidth, VIEWQUALITY viewqual, float stamina,float effort,float speed,AngleDeg rel_spd_angle,
AngleDeg head_angle,int kicks,int dashes,int turns,int says,int turn_necks,Time time);
SenseBodyInfo& GetSenseBodyInfo(Time time);
void SeeMarker(MarkerType marker,AngleDeg ang,Time time);
void SeeMarker(MarkerType marker,float dist,AngleDeg ang,Time time);
void SeeLine(SideLine line,AngleDeg ang,Time time);
void SeeLine(SideLine line,float dist,AngleDeg ang,Time time);
void SeeBall(AngleDeg ang,Time time);
void SeeBall(float dist,AngleDeg ang,Time time);
void SeeBall(float dist,AngleDeg ang,float distChng,float dirChng,Time time);
void SeePlayer(AngleDeg ang,Time time);
void SeePlayer(float dist,AngleDeg ang,Time time);
void SeePlayer(char player_side,AngleDeg ang,Time time);
void SeePlayer(char player_side,float dist,AngleDeg ang,Time time);
void SeePlayer(char player_side,UNum NO,AngleDeg ang,Time time,bool IsGoalie);
void SeePlayer(char player_side,UNum NO,float dist,AngleDeg ang,Time time,bool IsGoalie);
void SeePlayer(char player_side,UNum NO,float dist,AngleDeg ang,float distChng,
float dirChng,AngleDeg facedir,AngleDeg neckdir,Time time,bool IsGoalie);
void IdentifyMyGoalie(UNum No,bool IsGoalie);
void IdentifyTheirGoalie(UNum No,bool IsGoalie);
/********************** Seen Objects ********************************/
Timed2D_Array<MarkerType, SP_num_markers+1, CP_num_stored_markerinfos> SeenMarkers;
TimedDataArray<int, CP_num_stored_markerinfos> num_seenmarkers;
Timed2D_Array<SideLine, SP_num_lines+1, CP_num_stored_markerinfos> SeenLines;
TimedDataArray<int, CP_num_stored_markerinfos> num_seenlines;
/********************** ******************* ***************************/
int MySightInterval();
AngleDeg MyViewWidth(VIEWWIDTH view_width);
AngleDeg MyViewAngle(VIEWWIDTH view_width);
AngleDeg MyViewWidth(VWTime time = VWT_Current);
AngleDeg MyViewAngle(VWTime time = VWT_Current);
float DirConf(AngleDeg dir);
/********************** Update Infomation ****************************/
void Update();
void Update_others(Time time);
void Update_dirconf(Time time, bool NewSight);
void Reset();
/************************************************************************/
inline bool SensedInfKnown(Time time){return bool(time == LastSenseTime||time == PrevSenseTime);}
/************************************************************************/
MarkerType LastClosestMarker;
MarkerType ClosestGoal();
MarkerType ClosestFlag();
MarkerType GetClosestMarker(Time time){ return ClosestMarker.IsDataKnown(time) ? ClosestMarker.Data(time) : No_Marker;}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -