Skip to content

Commit

Permalink
Merge pull request #145 from rcsoccersim/v19-develop
Browse files Browse the repository at this point in the history
Implement v19 features
  • Loading branch information
hidehisaakiyama authored Mar 24, 2024
2 parents 47b1d4a + e50d00d commit b085a3b
Show file tree
Hide file tree
Showing 32 changed files with 1,140 additions and 625 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ add_executable(RCSSServer
initsenderonlinecoach.cpp
initsenderplayer.cpp
landmarkreader.cpp
leg.cpp
logger.cpp
main.cpp
monitor.cpp
Expand Down Expand Up @@ -94,7 +95,6 @@ target_link_libraries(RCSSServer
RCSS::ConfParser
RCSS::Net
RCSS::GZ
# Boost::filesystem
ZLIB::ZLIB
)

Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rcssserver_SOURCES = \
initsenderonlinecoach.cpp \
initsenderplayer.cpp \
landmarkreader.cpp \
leg.cpp \
logger.cpp \
main.cpp \
monitor.cpp \
Expand Down Expand Up @@ -90,6 +91,7 @@ noinst_HEADERS = \
initsenderonlinecoach.h \
initsenderplayer.h \
landmarkreader.h \
leg.h \
logger.h \
monitor.h \
observer.h \
Expand Down
3 changes: 3 additions & 0 deletions src/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ RegHolder vp15 = AudioSenderPlayer::factory().autoReg( &create< AudioSenderPlaye
RegHolder vp16 = AudioSenderPlayer::factory().autoReg( &create< AudioSenderPlayerv8 >, 16 );
RegHolder vp17 = AudioSenderPlayer::factory().autoReg( &create< AudioSenderPlayerv8 >, 17 );
RegHolder vp18 = AudioSenderPlayer::factory().autoReg( &create< AudioSenderPlayerv8 >, 18 );
RegHolder vp19 = AudioSenderPlayer::factory().autoReg( &create< AudioSenderPlayerv8 >, 19 );

template< typename Sender >
AudioSender::Ptr
Expand All @@ -1011,6 +1012,7 @@ RegHolder vc15 = AudioSenderCoach::factory().autoReg( &create< AudioSenderCoachv
RegHolder vc16 = AudioSenderCoach::factory().autoReg( &create< AudioSenderCoachv7 >, 16 );
RegHolder vc17 = AudioSenderCoach::factory().autoReg( &create< AudioSenderCoachv7 >, 17 );
RegHolder vc18 = AudioSenderCoach::factory().autoReg( &create< AudioSenderCoachv7 >, 18 );
RegHolder vc19 = AudioSenderCoach::factory().autoReg( &create< AudioSenderCoachv7 >, 19 );

template< typename Sender >
AudioSender::Ptr
Expand All @@ -1037,5 +1039,6 @@ RegHolder voc15 = AudioSenderOnlineCoach::factory().autoReg( &create< AudioSende
RegHolder voc16 = AudioSenderOnlineCoach::factory().autoReg( &create< AudioSenderOnlineCoachv7 >, 16 );
RegHolder voc17 = AudioSenderOnlineCoach::factory().autoReg( &create< AudioSenderOnlineCoachv7 >, 17 );
RegHolder voc18 = AudioSenderOnlineCoach::factory().autoReg( &create< AudioSenderOnlineCoachv7 >, 18 );
RegHolder voc19 = AudioSenderOnlineCoach::factory().autoReg( &create< AudioSenderOnlineCoachv7 >, 19 );
}
}
1 change: 1 addition & 0 deletions src/bodysender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ RegHolder vp15 = BodySenderPlayer::factory().autoReg( &create< BodySenderPlayerV
RegHolder vp16 = BodySenderPlayer::factory().autoReg( &create< BodySenderPlayerV14 >, 16 );
RegHolder vp17 = BodySenderPlayer::factory().autoReg( &create< BodySenderPlayerV14 >, 17 );
RegHolder vp18 = BodySenderPlayer::factory().autoReg( &create< BodySenderPlayerV18 >, 18 );
RegHolder vp19 = BodySenderPlayer::factory().autoReg( &create< BodySenderPlayerV18 >, 19 );
}

}
1 change: 1 addition & 0 deletions src/fullstatesender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ RegHolder vp15 = FullStateSenderPlayer::factory().autoReg( &create< FullStateSen
RegHolder vp16 = FullStateSenderPlayer::factory().autoReg( &create< FullStateSenderPlayerV13 >, 16 );
RegHolder vp17 = FullStateSenderPlayer::factory().autoReg( &create< FullStateSenderPlayerV13 >, 17 );
RegHolder vp18 = FullStateSenderPlayer::factory().autoReg( &create< FullStateSenderPlayerV18 >, 18 );
RegHolder vp19 = FullStateSenderPlayer::factory().autoReg( &create< FullStateSenderPlayerV18 >, 19 );
}

}
67 changes: 55 additions & 12 deletions src/heteroplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ HeteroPlayer::HeteroPlayer()

setDefaultObservationParams();

setDefaultGaussianObservationParams();

//
double real_speed_max
= ( SP.maxPower() * M_dash_power_rate * M_effort_max )
Expand Down Expand Up @@ -237,6 +239,9 @@ HeteroPlayer::setDefault()

// v18
setDefaultObservationParams();

// v19
setDefaultGaussianObservationParams();
}

void
Expand All @@ -252,10 +257,22 @@ HeteroPlayer::setDefaultObservationParams()
M_ball_vel_far_length = 20.0;
M_ball_vel_too_far_length = 40.0;
M_ball_max_observation_length = maximum_dist_in_pitch;
M_flag_chg_far_length = 20.0;
M_flag_chg_too_far_length = 40.0;
M_land_vel_far_length = 20.0;
M_land_vel_too_far_length = 40.0;
M_flag_max_observation_length = maximum_dist_in_pitch;
}

void
HeteroPlayer::setDefaultGaussianObservationParams()
{
const ServerParam & SP = ServerParam::instance();

M_dist_noise_rate = SP.distNoiseRate();
M_focus_dist_noise_rate = SP.focusDistNoiseRate();
M_land_dist_noise_rate = SP.landDistNoiseRate();
M_land_focus_dist_noise_rate = SP.landFocusDistNoiseRate();
}

std::ostream &
HeteroPlayer::print( std::ostream & o ) const
{
Expand Down Expand Up @@ -286,10 +303,14 @@ HeteroPlayer::print( std::ostream & o ) const
o << "\tBall Vel Far Length = " << ballVelFarLength() << '\n';
o << "\tBall Vel Too Far Length = " << ballVelTooFarLength() << '\n';
o << "\tBall Max Observation Length = " << ballMaxObservationLength() << '\n';
o << "\tFlag Chg Far Length = " << flagChgFarLength() << '\n';
o << "\tFlag Chg Too Far Length = " << flagChgTooFarLength() << '\n';
o << "\tFlag Max Observation Length = " << flagMaxObservationLength() << std::endl;

o << "\tFlag Chg Far Length = " << landVelFarLength() << '\n';
o << "\tFlag Chg Too Far Length = " << landVelTooFarLength() << '\n';
o << "\tFlag Max Observation Length = " << landMaxObservationLength() << '\n';
o << "\tDist Noise Rate = " << distNoiseRate() << '\n';
o << "\tFocus Dist Noise Rate = " << focusDistNoiseRate() << '\n';
o << "\tLand Dist Noise Rate = " << landDistNoiseRate() << '\n';
o << "\tLand Focus Dist Noise Rate = " << landFocusDistNoiseRate() << std::endl;

return o;
}

Expand Down Expand Up @@ -379,16 +400,27 @@ HeteroPlayer::printParamsSExp( std::ostream & o,
to_sexp( o, "ball_vel_far_length", ballVelFarLength() );
to_sexp( o, "ball_vel_too_far_length", ballVelTooFarLength() );
to_sexp( o, "ball_max_observation_length", ballMaxObservationLength() );
to_sexp( o, "flag_chg_far_length", flagChgFarLength() );
to_sexp( o, "flag_chg_too_far_length", flagChgTooFarLength() );
to_sexp( o, "flag_max_observation_length", flagMaxObservationLength() );
to_sexp( o, "flag_chg_far_length", landVelFarLength() );
to_sexp( o, "flag_chg_too_far_length", landVelTooFarLength() );
to_sexp( o, "flag_max_observation_length", landMaxObservationLength() );

if ( version < 19 )
{
return;
}

to_sexp( o, "dist_noise_rate", distNoiseRate() );
to_sexp( o, "focus_dist_noise_rate", focusDistNoiseRate() );
to_sexp( o, "land_dist_noise_rate", landDistNoiseRate() );
to_sexp( o, "land_focus_dist_noise_rate", landFocusDistNoiseRate() );
}


void
HeteroPlayer::printParamsJSON( std::ostream & o,
const unsigned int version ) const
{
o << ',';
to_json_member( o, "player_speed_max", playerSpeedMax() );
o << ',';
to_json_member( o, "stamina_inc_max", staminaIncMax() );
Expand Down Expand Up @@ -438,10 +470,21 @@ HeteroPlayer::printParamsJSON( std::ostream & o,
o << ",";
to_json_member( o, "ball_max_observation_length", ballMaxObservationLength() );
o << ",";
to_json_member( o, "flag_chg_far_length", flagChgFarLength() );
to_json_member( o, "flag_chg_far_length", landVelFarLength() );
o << ",";
to_json_member( o, "flag_chg_too_far_length", landVelTooFarLength() );
o << ",";
to_json_member( o, "flag_max_observation_length", landMaxObservationLength() );
}
if ( version >= 19 )
{
o << ",";
to_json_member( o, "dist_noise_rate", distNoiseRate() );
o << ",";
to_json_member( o, "focus_dist_noise_rate", focusDistNoiseRate() );
o << ",";
to_json_member( o, "flag_chg_too_far_length", flagChgTooFarLength() );
to_json_member( o, "land_dist_noise_rate", landDistNoiseRate() );
o << ",";
to_json_member( o, "flag_max_observation_length", flagMaxObservationLength() );
to_json_member( o, "land_focus_dist_noise_rate", landFocusDistNoiseRate() );
}
}
23 changes: 18 additions & 5 deletions src/heteroplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ class HeteroPlayer {
double ballVelFarLength() const { return M_ball_vel_far_length; }
double ballVelTooFarLength() const { return M_ball_vel_too_far_length; }
double ballMaxObservationLength() const { return M_ball_max_observation_length; }
double flagChgFarLength() const { return M_flag_chg_far_length; }
double flagChgTooFarLength() const { return M_flag_chg_too_far_length; }
double flagMaxObservationLength() const { return M_flag_max_observation_length; }
double landVelFarLength() const { return M_land_vel_far_length; }
double landVelTooFarLength() const { return M_land_vel_too_far_length; }
double landMaxObservationLength() const { return M_flag_max_observation_length; }

double distNoiseRate() const { return M_dist_noise_rate; }
double focusDistNoiseRate() const { return M_focus_dist_noise_rate; }
double landDistNoiseRate() const { return M_land_dist_noise_rate; }
double landFocusDistNoiseRate() const { return M_land_focus_dist_noise_rate; }

std::ostream & print( std::ostream & o ) const;

Expand All @@ -86,6 +91,8 @@ class HeteroPlayer {

void setDefaultObservationParams();

void setDefaultGaussianObservationParams();

double M_player_speed_max;
double M_stamina_inc_max;
double M_player_decay;
Expand All @@ -112,9 +119,15 @@ class HeteroPlayer {
double M_ball_vel_far_length;
double M_ball_vel_too_far_length;
double M_ball_max_observation_length;
double M_flag_chg_far_length;
double M_flag_chg_too_far_length;
double M_land_vel_far_length;
double M_land_vel_too_far_length;
double M_flag_max_observation_length;

// v19
double M_dist_noise_rate;
double M_focus_dist_noise_rate;
double M_land_dist_noise_rate;
double M_land_focus_dist_noise_rate;
};

inline
Expand Down
1 change: 1 addition & 0 deletions src/initsendercoach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ RegHolder vc15 = InitSenderOfflineCoach::factory().autoReg( &create< InitSenderO
RegHolder vc16 = InitSenderOfflineCoach::factory().autoReg( &create< InitSenderOfflineCoachV8 >, 16 );
RegHolder vc17 = InitSenderOfflineCoach::factory().autoReg( &create< InitSenderOfflineCoachV8 >, 17 );
RegHolder vc18 = InitSenderOfflineCoach::factory().autoReg( &create< InitSenderOfflineCoachV8 >, 18 );
RegHolder vc19 = InitSenderOfflineCoach::factory().autoReg( &create< InitSenderOfflineCoachV8 >, 19 );
}

}
21 changes: 11 additions & 10 deletions src/initsenderlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,21 +545,22 @@ InitSenderLoggerJSON::~InitSenderLoggerJSON()
void
InitSenderLoggerJSON::sendHeader()
{
transport() << "JSON\n";
//transport() << "JSON\n";
transport() << "[\n";

transport() << '{'
<< std::quoted( "type" ) << ':' << std::quoted( "header" );
// transport() << '{'
// << std::quoted( "type" ) << ':' << std::quoted( "header" );

transport() << ','
<< std::quoted( "version" ) << ':' << std::quoted( VERSION );
transport() << '{'
<< std::quoted( "version" ) << ':' << std::quoted( VERSION )
<< "}";

transport() << ",\n";
const std::time_t t = stadium().getStartTime();
transport() << ','
transport() << '{'
<< std::quoted( "timestamp" ) << ':'
<< '"' << std::put_time( std::localtime( &t ), "%FT%T%z" ) << '"';

transport() << '}';
<< '"' << std::put_time( std::localtime( &t ), "%FT%T%z" ) << '"'
<< '}';
}


Expand Down Expand Up @@ -610,7 +611,7 @@ RegHolder vl2 = InitSenderLogger::factory().autoReg( &create< InitSenderLoggerV2
RegHolder vl3 = InitSenderLogger::factory().autoReg( &create< InitSenderLoggerV3 >, 3 );
RegHolder vl4 = InitSenderLogger::factory().autoReg( &create< InitSenderLoggerV4 >, 4 );
RegHolder vl5 = InitSenderLogger::factory().autoReg( &create< InitSenderLoggerV5 >, 5 );
RegHolder vl7 = InitSenderLogger::factory().autoReg( &create< InitSenderLoggerV6 >, 6 );
RegHolder vl6 = InitSenderLogger::factory().autoReg( &create< InitSenderLoggerV6 >, 6 );

RegHolder vljson = InitSenderLogger::factory().autoReg( &create< InitSenderLoggerJSON >, -1 );

Expand Down
1 change: 1 addition & 0 deletions src/initsenderonlinecoach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ RegHolder voc15 = InitSenderOnlineCoach::factory().autoReg( &create< InitSenderO
RegHolder voc16 = InitSenderOnlineCoach::factory().autoReg( &create< InitSenderOnlineCoachV8 >, 16 );
RegHolder voc17 = InitSenderOnlineCoach::factory().autoReg( &create< InitSenderOnlineCoachV8 >, 17 );
RegHolder voc18 = InitSenderOnlineCoach::factory().autoReg( &create< InitSenderOnlineCoachV8 >, 18 );
RegHolder voc19 = InitSenderOnlineCoach::factory().autoReg( &create< InitSenderOnlineCoachV8 >, 19 );
}

}
1 change: 1 addition & 0 deletions src/initsenderplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ RegHolder vp15 = InitSenderPlayer::factory().autoReg( &create< InitSenderPlayerV
RegHolder vp16 = InitSenderPlayer::factory().autoReg( &create< InitSenderPlayerV8 >, 16 );
RegHolder vp17 = InitSenderPlayer::factory().autoReg( &create< InitSenderPlayerV8 >, 17 );
RegHolder vp18 = InitSenderPlayer::factory().autoReg( &create< InitSenderPlayerV8 >, 18 );
RegHolder vp19 = InitSenderPlayer::factory().autoReg( &create< InitSenderPlayerV8 >, 19 );
}

}
Loading

0 comments on commit b085a3b

Please sign in to comment.