⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smonitor_dev.c

📁 robocup rcssmonitor-11.1.1.zip
💻 C
📖 第 1 页 / 共 5 页
字号:
  Int16 spareshort8;  Int16 spareshort9;  Int16 spareshort10;} server_params_t;typedef struct {    Int16 player_types;    Int16 subs_max;    Int16 pt_max;    Int32 player_speed_max_delta_min;    Int32 player_speed_max_delta_max;    Int32 stamina_inc_max_delta_factor;    Int32 player_decay_delta_min;    Int32 player_decay_delta_max;    Int32 inertia_moment_delta_factor;    Int32 dash_power_rate_delta_min;    Int32 dash_power_rate_delta_max;    Int32 player_size_delta_factor;    Int32 kickable_margin_delta_min;    Int32 kickable_margin_delta_max;    Int32 kick_rand_delta_factor;    Int32 extra_stamina_delta_min;    Int32 extra_stamina_delta_max;    Int32 effort_max_delta_factor;    Int32 effort_min_delta_factor;    Int32 sparelong1;    Int32 sparelong2;    Int32 sparelong3;    Int32 sparelong4;    Int32 sparelong5;    Int32 sparelong6;    Int32 sparelong7;    Int32 sparelong8;    Int32 sparelong9;    Int32 sparelong10;  Int16 spareshort1;  Int16 spareshort2;  Int16 spareshort3;  Int16 spareshort4;  Int16 spareshort5;  Int16 spareshort6;  Int16 spareshort7;  Int16 spareshort8;  Int16 spareshort9;  Int16 spareshort10;} player_params_t;typedef struct {  Int16 mode;  union {      showinfo_t2 		show;      msginfo_t 		msg;      player_type_t		ptinfo;      server_params_t		sparams;      player_params_t		pparams;  } body;} dispinfo_t2 ;}/******************************************************************************/std::ostream & operator<< (std::ostream & o, const RGBcolor & col) {  const char numbers[16]= {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};  o << numbers[col.red/16] << numbers[col.red%16]    << numbers[col.green/16] <<numbers[ col.green%16]    << numbers[col.blue/16] << numbers[col.blue%16];  return o;}class PlayerTypes {  struct _player_type {    _player_type() { valid= false; }    bool valid;    double player_radius;    double kickable_margin;  };  static double ball_radius;  static const int NUM_TYPES= 7;  static _player_type std_type;  static _player_type types[NUM_TYPES];public:  static bool use_std_type;  static void init(double std_ball_radius, double std_player_radius, double std_kickable_margin) {    ball_radius= std_ball_radius;    std_type.valid= true;    std_type.player_radius= std_player_radius;    std_type.kickable_margin= std_kickable_margin;    use_std_type= true;  }  static void set_type(int type, double player_radius, double kickable_margin) {    if (type < 0 || type >= NUM_TYPES) {      WARNING_OUT << "\nwrong player type number" << type << " (ignoring)";      return;    }    types[type].valid= true;    types[type].player_radius= player_radius;    types[type].kickable_margin= kickable_margin;  }  static double get_player_radius(int type) {    if (type == -1 || use_std_type) // default type      return std_type.player_radius;    if (type < 0 || type >= NUM_TYPES) {      WARNING_OUT << "\nwrong player type number" << type << " (using std type)";      return std_type.player_radius;    }    if ( !types[ type ].valid ) {      WARNING_OUT << "\nplayer type " << type << " not valid (using std type)";      return std_type.player_radius;    }    return types[type].player_radius;  }  static double get_kick_radius(int type) {    double def_result= std_type.player_radius + std_type.kickable_margin + ball_radius;    if (type == -1 || use_std_type) // default type      return def_result;    if (type < 0 || type >= NUM_TYPES) {      WARNING_OUT << "\nwrong player type number" << type << " (using std type)";      return def_result;    }    if ( !types[ type ].valid ) {      WARNING_OUT << "\nplayer type " << type << " not valid (using std type)";      return def_result;    }    return types[type].player_radius + types[type].kickable_margin + ball_radius;  }};//definition of the static internal data of PlayerTypesdouble PlayerTypes::ball_radius;PlayerTypes::_player_type PlayerTypes::std_type;PlayerTypes::_player_type PlayerTypes::types[PlayerTypes::NUM_TYPES];bool PlayerTypes::use_std_type;/******************************************************************************/const int VisualPlayersViewArea::LOW= 0;const int VisualPlayersViewArea::HIGH= 1;const int VisualPlayersViewArea::FEEL_RANGE= 2;VisualPlayersViewArea::VisualPlayersViewArea() {}void VisualPlayersViewArea::init(int my_key, int my_layer, const RGBcolor & my_exact, const RGBcolor & my_fuzzy) {  key= my_key;  layer= my_layer;  c_fuzzy= my_fuzzy;  c_exact= my_exact;  circlearc1.set_color(c_fuzzy);  circlearc1.filled= true;  circle.set_color(c_fuzzy);  circle.filled= true;  circle.rel.radius= 3.0; //feel range  circlearc2.set_color(c_exact);  circlearc2.filled= true;  view_quality= -1;  view_width= -1.0;  set_view_mode(FEEL_RANGE,0.5*M_PI);}void VisualPlayersViewArea::draw(DisplayBase * disp, const Area2d & area, const Frame2d & p_frame, bool chg) {  circlearc1.draw(disp,area,p_frame,chg);  circle.draw(disp,area,p_frame,chg);  circlearc2.draw(disp,area,p_frame,chg);}void VisualPlayersViewArea::actualize(const Frame2d& f, bool chg) {  circlearc1.actualize(f,chg);  circle.actualize(f,chg);  circlearc2.actualize(f,chg);}void VisualPlayersViewArea::set_view_mode( int quality, double width ) {  if (quality != view_quality) {    view_quality= quality;    switch (view_quality) {    case LOW:      circlearc1.rel.radius= 40;      circlearc1.changed= true;      circlearc1.visible= true;      circlearc2.rel.radius= 20;      circlearc2.changed= true;      circlearc2.visible= false;      break;    case HIGH:      circlearc1.rel.radius= 60;      circlearc1.changed= true;      circlearc1.visible= true;      circlearc2.rel.radius= 40;      circlearc2.changed= true;      circlearc2.visible= true;      break;    case FEEL_RANGE:      circlearc1.visible= false;      circlearc2.visible= false;      break;    default:      ERROR_OUT << "wrong view_quality " << view_width;    }  }  if ( fabs(width - view_width) > 0.01 ) {    view_width= width;    Angle a= 0.5* view_width;    circlearc1.rel.ang1= -a;    circlearc1.rel.ang2=  a;    circlearc1.changed= true;    circlearc2.rel.ang1= -a;    circlearc2.rel.ang2=  a;    circlearc2.changed= true;  }}/******************************************************************************/const int VisualBall::MAX_LINE_MARKERS_NUM= 50;const int VisualBall::MAX_LABEL_LEN= 20;VisualBall::VisualBall() {}void VisualBall::init(int my_key, int my_layer, double my_small_r, double my_large_r,		      const RGBcolor & my_c_ball,		      const RGBcolor & my_c_line_until_ball_stops,		      const RGBcolor & my_c_line_markers,		      const RGBcolor & my_c_font) {  ball_decay= 0.94;  key= my_key;  layer= my_layer;  c_ball= my_c_ball;  c_line_until_ball_stops= my_c_line_until_ball_stops;  c_line_markers= my_c_line_markers;  c_font= my_c_font;  show_vel= false;  show_vel_string= false;  changed= true;  double small_r= my_small_r;  double large_r= my_large_r;  ball_point.use_intersects_area= false;  ball_point.set_color(c_ball);  ball_circle.rel.radius= small_r;  ball_circle.use_intersects_area= false;  ball_circle.set_color(c_ball);  ball_circle.filled= true;  ball_margin.rel.radius= large_r;  ball_margin.use_intersects_area= false;  ball_margin.set_color(c_ball);  ball_margin.filled= false;  line_until_ball_stops.use_intersects_area= false;  line_until_ball_stops.set_color(c_line_until_ball_stops);  line_markers.set_max_size(MAX_LINE_MARKERS_NUM);  line_markers.set_cur_size(0);  line_markers.use_intersects_area= false;  line_markers.set_color(c_line_markers);  label.content.set_max_size(MAX_LABEL_LEN);  label.content.set_cur_size(0);  //label.content.tab[0]= 'b';  label.set_color(c_font);}void VisualBall::draw(DisplayBase * disp, const Area2d & area, const Frame2d & p_frame, bool chg) {  changed= changed || chg;  ball_point.actualize(p_frame,changed);  if ( ! ball_point.intersects_area(area) )    return;  if ( show_vel ) {    line_until_ball_stops.draw(disp,area,p_frame,changed);    line_markers.draw(disp,area,p_frame * vel_frame, changed);  }  ball_point.draw(disp,area,p_frame,false); //already actualized!  ball_circle.draw(disp,area,p_frame,changed);  ball_margin.draw(disp,area,p_frame,changed);  if ( show_vel_string ) {    label.draw(disp,area,p_frame,changed);  }  changed= false;}void VisualBall::actualize(const Frame2d& f, bool chg) {  changed= changed || chg;  ball_point.actualize(f,changed);  ball_circle.actualize(f,changed);  ball_margin.actualize(f,changed);  line_until_ball_stops.actualize(f,changed);  line_markers.actualize(f,changed);  label.actualize(f,changed);  changed= false;}void VisualBall::set_show_vel( const Point2d & vel_as_point ) {  show_vel= true;  Vector2d vel= Vector2d(vel_as_point.x, vel_as_point.y);  double norm= vel.norm();  line_until_ball_stops.rel.p2.x=  vel.x / ( 1.0 - ball_decay);  line_until_ball_stops.rel.p2.y=  vel.y / ( 1.0 - ball_decay);  line_until_ball_stops.changed= true;  vel_frame.set_angle( vel );  line_markers.changed= true;  if ( norm < 0.5 ) {    line_markers.set_cur_size(0);    return;  }  double distance= 0.0;  line_markers.set_cur_size(MAX_LINE_MARKERS_NUM);  for (int i=0; i< MAX_LINE_MARKERS_NUM; i++) {    distance += norm;    line_markers.rel.tab[i].p1.x= distance;    line_markers.rel.tab[i].p1.y= -0.5*norm;    line_markers.rel.tab[i].p2.x= distance;    line_markers.rel.tab[i].p2.y=  0.5*norm;    norm *= ball_decay;    if ( norm < 0.5 ) {      line_markers.set_cur_size(i+1);      break;    }  }}void VisualBall::set_show_vel_string( const Point2d & vel ) {  //sprintf( label.content.tab,"(%.2lf,%.2lf)  ", vel.x, vel.y);  show_vel_string= true;  sprintf( label.content.tab,"(%.2f,%.2f)", vel.x, vel.y);  label.content.cur_size= strlen(label.content.tab);  label.changed= true;  //cout << "\nlabel= " << label.content.tab << flush;}/******************************************************************************/const int VisualPlayer::MAX_LABEL_LEN= 20;VisualPlayer::VisualPlayer() {    c_black  = RGBcolor( 0, 0, 0 );    c_white  = RGBcolor( 255, 255, 255 );    c_red    = RGBcolor( 255, 0, 0 );    c_blue   = RGBcolor( 0, 0, 255 );    c_orange = RGBcolor( 255, 165, 0 );    c_pink   = RGBcolor( 255, 192, 203 );    c_olive  = RGBcolor( 128, 128, 0 );}void VisualPlayer::init(int my_key, int my_layer, char p_char,			const RGBcolor & my_c_invalid,			const RGBcolor & my_c_player,			const RGBcolor & my_c_goalie,			const RGBcolor & my_c_font) {  key= my_key;  layer= my_layer;  c_invalid= my_c_invalid;  c_player= my_c_player;  c_goalie= my_c_goalie;  c_font= my_c_font;  type= -1;  use_number= true;  show_kick= false;  show_kick_fault = false;  show_tackle = false;  show_tackle_fault = false;  show_catch_fault = false;  ball_collision= false;  is_active= false;  is_goalie= false;  changed= true;  double small_r= PlayerTypes::get_player_radius(type);  double large_r= PlayerTypes::get_kick_radius(type);  body_bg.rel.radius= large_r;  body_bg.use_intersects_area= false;  body_bg.set_color(c_invalid);  body_bg.filled= true;  body.rel.radius= small_r;  body.use_intersects_area= false;  body.set_color(c_black);  body_margin.rel.radius= large_r;  body_margin.use_intersects_area= false;  body_margin.set_color(c_black);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -