cycle_data.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hidehisa AKIYAMA
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
00028  */
00029 
00031 
00032 #ifndef RCSC_COACH_CYCLE_DATA_H
00033 #define RCSC_COACH_CYCLE_DATA_H
00034 
00035 #include <rcsc/geom/vector_2d.h>
00036 #include <rcsc/game_time.h>
00037 #include <rcsc/game_mode.h>
00038 #include <rcsc/types.h>
00039 
00040 #include <vector>
00041 
00042 namespace rcsc {
00043 
00044 class GlobalVisualSensor;
00045 
00050 class CycleData {
00051 public:
00052 
00053     // all positional data from server is left-hand oriented
00054 
00059     struct BallT {
00060         Vector2D pos_; 
00061         Vector2D vel_; 
00062 
00066         void reverse()
00067           {
00068               pos_ *= -1.0;
00069               vel_ *= -1.0;
00070           }
00071     };
00072 
00077     struct PlayerT {
00078         int unum_; 
00079         Vector2D pos_; 
00080         Vector2D vel_; 
00081         double body_; 
00082         double neck_; 
00083         Vector2D pointto_pos_; 
00084         bool goalie_; 
00085         bool tackle_; 
00086 
00090         PlayerT()
00091             : unum_( 0 )
00092             , pos_( Vector2D::INVALID )
00093             , vel_( Vector2D::INVALID )
00094             , body_( 0.0 )
00095             , neck_( 0.0 )
00096             , pointto_pos_( Vector2D::INVALID )
00097             , goalie_( false )
00098             , tackle_( false )
00099           { }
00100 
00106         std::ostream & print( std::ostream & os ) const;
00107     };
00108 
00109 
00110     typedef std::vector< PlayerT > PlayerCont;
00111 
00112 private:
00113 
00115     GameTime M_time;
00116 
00118     GameMode M_game_mode;
00119 
00121     BallT M_ball;
00122 
00124     PlayerCont M_players_left;
00125 
00127     PlayerCont M_players_right;
00128 
00129 
00130 public:
00131 
00135     CycleData()
00136         : M_time( -1, 0 )
00137       { }
00138 
00140 
00147     void assign( const GlobalVisualSensor & see_global,
00148                  const GameMode & game_mode,
00149                  const GameTime & current );
00150 
00152 
00157     const
00158     GameTime & time() const
00159       {
00160           return M_time;
00161       }
00162 
00167     const
00168     GameMode & gameMode() const
00169       {
00170           return M_game_mode;
00171       }
00172 
00177     const
00178     BallT & ball() const
00179       {
00180           return M_ball;
00181       }
00182 
00187     const
00188     PlayerCont & playersLeft() const
00189       {
00190           return M_players_left;
00191       }
00192 
00197     const
00198     PlayerCont & playersRight() const
00199       {
00200           return M_players_right;
00201       }
00202 
00204 
00209     double getOffsideLineForLeft() const;
00210 
00215     double getOffsideLineForRight() const;
00216 
00221     double getOffsideLineX( const SideID my_side ) const;
00222 
00227     BallStatus getBallStatus() const;
00228 
00235     const
00236     PlayerT * getPlayerNearestTo( const PlayerCont & players,
00237                                   const Vector2D & point ) const;
00238 
00244     const
00245     PlayerT * getLeftPlayerNearestTo( const Vector2D & point ) const
00246       {
00247           return getPlayerNearestTo( M_players_left, point );
00248       }
00249 
00255     const
00256     PlayerT * getRightPlayerNearestTo( const Vector2D & point ) const
00257       {
00258           return getPlayerNearestTo( M_players_right, point );
00259       }
00260 
00266     std::ostream & print( std::ostream & os ) const;
00267 };
00268 
00269 }
00270 
00271 #endif

librcscに対してThu May 1 15:41:20 2008に生成されました。  doxygen 1.5.0