Skip to content

Commit b37302f

Browse files
authored
Merge pull request #29 from CLSFramework/develop_issues
Develop issues
2 parents e2d57f6 + 519da99 commit b37302f

File tree

7 files changed

+112
-9
lines changed

7 files changed

+112
-9
lines changed

ChangeLog.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# ChangeLog
22

3+
## [1.0.4] - 2024-10-8
4+
5+
### Added
6+
- self.effort and wm.see_time are added
7+
8+
### Fixed
9+
-
10+
11+
### Changed
12+
-
13+
14+
### Engineers
15+
- [NaderZare](https://github.com/naderzare)
16+
- [SadraKhanjari](https://github.com/SK2iP)
17+
- [SoroushMazloum](https://github.com/SoroushMazloum)
18+
19+
=======
20+
21+
## [1.0.3] - 2024-10-7
22+
23+
### Added
24+
- penalty_kick_state has been added to the proxy in the WorldModel message.
25+
26+
### Fixed
27+
-
28+
29+
### Changed
30+
-
31+
32+
### Engineers
33+
- [NaderZare](https://github.com/naderzare)
34+
- [SadraKhanjari](https://github.com/SK2iP)
35+
- [SoroushMazloum](https://github.com/SoroushMazloum)
36+
37+
=======
38+
339
## [1.0.2] - 2024-09-15
440

541
### Added

idl/grpc/service.proto

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// version 1.2
1+
// version 1.4
22

33
syntax = "proto3";
44

@@ -102,6 +102,16 @@ enum CardType {
102102
RED = 2;
103103
}
104104

105+
message PenaltyKickState {
106+
Side on_field_side = 1;
107+
Side current_taker_side = 2;
108+
int32 our_taker_counter = 3;
109+
int32 their_taker_counter = 4;
110+
int32 our_score = 5;
111+
int32 their_score = 6;
112+
bool is_kick_taker = 7;
113+
}
114+
105115
message Player {
106116
RpcVector2D position = 1;
107117
RpcVector2D seen_position = 2;
@@ -176,6 +186,7 @@ message Self {
176186
float stamina_capacity = 38;
177187
CardType card = 39;
178188
int32 catch_time = 40;
189+
float effort = 41;
179190
}
180191

181192
enum InterceptActionType {
@@ -285,6 +296,8 @@ message WorldModel {
285296
double their_defense_player_line_x = 35;
286297
bool kickable_teammate_existance = 36;
287298
bool kickable_opponent_existance = 37;
299+
PenaltyKickState penalty_kick_state = 38;
300+
int32 see_time = 39;
288301
}
289302

290303
message State {

idl/thrift/soccer_service.thrift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// version 1.2
1+
// version 1.4
22

33
namespace cpp soccer
44
namespace py soccer
@@ -105,6 +105,16 @@ enum CardType {
105105
RED = 2
106106
}
107107

108+
struct PenaltyKickState {
109+
1: Side on_field_side,
110+
2: Side current_taker_side,
111+
3: i32 our_taker_counter,
112+
4: i32 their_taker_counter,
113+
5: i32 our_score,
114+
6: i32 their_score,
115+
7: bool is_kick_taker
116+
}
117+
108118
struct Player {
109119
1: RpcVector2D position,
110120
2: RpcVector2D seen_position,
@@ -178,7 +188,8 @@ struct Self {
178188
37: double recovery,
179189
38: double stamina_capacity,
180190
39: CardType card,
181-
40: i32 catch_time
191+
40: i32 catch_time,
192+
41: double effort
182193
}
183194

184195
enum InterceptActionType {
@@ -287,7 +298,9 @@ struct WorldModel {
287298
34: double our_defense_player_line_x,
288299
35: double their_defense_player_line_x,
289300
36: bool kickable_teammate_existance,
290-
37: bool kickable_opponent_existance
301+
37: bool kickable_opponent_existance,
302+
38: PenaltyKickState penalty_kick_state,
303+
39: i32 see_time
291304
}
292305

293306
struct State {

src/grpc-client/state_generator.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protos::Self *StateGenerator::convertSelf(const rcsc::SelfObject &self, const rc
173173
res->set_stamina_capacity(static_cast<float>(self.staminaCapacity()));
174174
res->set_card(convertCardType(self.card()));
175175
res->set_catch_time(self.catchTime().cycle());
176-
176+
res->set_effort(static_cast<float>(self.effort()));
177177
return res;
178178
}
179179

@@ -236,6 +236,20 @@ protos::InterceptTable *StateGenerator::convertInterceptTable(const rcsc::Interc
236236
return res;
237237
}
238238

239+
protos::PenaltyKickState *StateGenerator::convertPenaltyKickState(const rcsc::WorldModel &wm, const rcsc::PenaltyKickState *state)
240+
{
241+
auto res = new protos::PenaltyKickState();
242+
res->set_on_field_side(convertSide(state->onfieldSide()));
243+
res->set_current_taker_side(convertSide(state->currentTakerSide()));
244+
res->set_our_taker_counter(state->ourTakerCounter());
245+
res->set_their_taker_counter(state->theirTakerCounter());
246+
res->set_our_score(state->ourScore());
247+
res->set_their_score(state->theirScore());
248+
res->set_is_kick_taker(state->isKickTaker(wm.ourSide(), wm.self().unum()));
249+
250+
return res;
251+
}
252+
239253
/**
240254
* Updates the player object with the given player information.
241255
*
@@ -514,6 +528,11 @@ protos::WorldModel *StateGenerator::convertWorldModel(const rcsc::WorldModel &wm
514528
res->set_their_defense_line_x(static_cast<float>(wm.theirDefenseLineX()));
515529
res->set_our_defense_player_line_x(static_cast<float>(wm.ourDefensePlayerLineX()));
516530
res->set_their_defense_player_line_x(static_cast<float>(wm.theirDefensePlayerLineX()));
531+
if(wm.gameMode().isPenaltyKickMode())
532+
{
533+
res->set_allocated_penalty_kick_state(convertPenaltyKickState(wm, wm.penaltyKickState()));
534+
}
535+
res->set_see_time(wm.seeTime().cycle());
517536
return res;
518537
}
519538

@@ -559,4 +578,4 @@ protos::WorldModel *StateGenerator::convertCoachWorldModel(const rcsc::CoachWorl
559578
res->set_their_team_score(wm.ourSide() == rcsc::SideID::LEFT ? wm.gameMode().scoreRight() : wm.gameMode().scoreLeft());
560579
res->set_is_penalty_kick_mode(wm.gameMode().isPenaltyKickMode());
561580
return res;
562-
}
581+
}

src/grpc-client/state_generator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "../grpc-generated/service.pb.h"
22
#include <rcsc/player/player_agent.h>
3+
#include <rcsc/player/penalty_kick_state.h>
34
#include <rcsc/coach/coach_agent.h>
45
#include <rcsc/trainer/trainer_agent.h>
56
#include <rcsc/player/world_model.h>
@@ -22,6 +23,7 @@ class StateGenerator
2223
static protos::Self *convertSelf(const rcsc::SelfObject &self, const rcsc::WorldModel &wm);
2324
static protos::InterceptActionType convertInterceptActionType(rcsc::Intercept::ActionType actionType);
2425
static protos::InterceptTable *convertInterceptTable(const rcsc::InterceptTable &interceptTable);
26+
static protos::PenaltyKickState *convertPenaltyKickState(const rcsc::WorldModel &wm, const rcsc::PenaltyKickState *state);
2527
static void updatePlayerObject(protos::Player *p, const rcsc::PlayerObject *player);
2628
static void updatePlayerObject(protos::Player *p, const rcsc::CoachPlayerObject *player);
2729
static void updateAbstractPlayerObject(protos::Player *p, const rcsc::AbstractPlayerObject *player);

src/thrift-client/thrift_state_generator.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ soccer::Self ThriftStateGenerator::convertSelf(const rcsc::SelfObject &self, con
178178
res.stamina_capacity = static_cast<float>(self.staminaCapacity());
179179
res.card = convertCardType(self.card());
180180
res.catch_time = self.catchTime().cycle();
181-
181+
res.effort = static_cast<float>(self.effort());
182182
return res;
183183
}
184184

@@ -245,6 +245,20 @@ soccer::InterceptTable ThriftStateGenerator::convertInterceptTable(const rcsc::I
245245
return res;
246246
}
247247

248+
soccer::PenaltyKickState ThriftStateGenerator::convertPenaltyKickState(const rcsc::WorldModel &wm, const rcsc::PenaltyKickState *state)
249+
{
250+
auto res = soccer::PenaltyKickState();
251+
res.on_field_side = convertSide(state->onfieldSide());
252+
res.current_taker_side = convertSide(state->currentTakerSide());
253+
res.our_taker_counter = state->ourTakerCounter();
254+
res.their_taker_counter = state->theirTakerCounter();
255+
res.our_score = state->ourScore();
256+
res.their_score = state->theirScore();
257+
res.is_kick_taker = state->isKickTaker(wm.ourSide(), wm.self().unum());
258+
259+
return res;
260+
}
261+
248262
/**
249263
* Updates the player object with the given player information.
250264
*
@@ -542,7 +556,11 @@ soccer::WorldModel ThriftStateGenerator::convertWorldModel(const rcsc::WorldMode
542556
res.their_defense_line_x = static_cast<float>(wm.theirDefenseLineX());
543557
res.our_defense_player_line_x = static_cast<float>(wm.ourDefensePlayerLineX());
544558
res.their_defense_player_line_x = static_cast<float>(wm.theirDefensePlayerLineX());
545-
559+
if(wm.gameMode().isPenaltyKickMode())
560+
{
561+
res.penalty_kick_state = convertPenaltyKickState(wm, wm.penaltyKickState());
562+
}
563+
res.see_time = wm.seeTime().cycle();
546564
return res;
547565
}
548566

@@ -593,4 +611,4 @@ soccer::WorldModel ThriftStateGenerator::convertCoachWorldModel(const rcsc::Coac
593611
res.their_team_score = wm.ourSide() == rcsc::SideID::LEFT ? wm.gameMode().scoreRight() : wm.gameMode().scoreLeft();
594612
res.is_penalty_kick_mode = wm.gameMode().isPenaltyKickMode();
595613
return res;
596-
}
614+
}

src/thrift-client/thrift_state_generator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//#include "service.pb.h"
22

33
#include <rcsc/player/player_agent.h>
4+
#include <rcsc/player/penalty_kick_state.h>
45
#include <rcsc/coach/coach_agent.h>
56
#include <rcsc/trainer/trainer_agent.h>
67
#include <rcsc/player/world_model.h>
@@ -31,6 +32,7 @@ class ThriftStateGenerator
3132
static soccer::Self convertSelf(const rcsc::SelfObject &self, const rcsc::WorldModel &wm);
3233
static soccer::InterceptActionType::type convertInterceptActionType(rcsc::Intercept::ActionType actionType);
3334
static soccer::InterceptTable convertInterceptTable(const rcsc::InterceptTable &interceptTable);
35+
static soccer::PenaltyKickState convertPenaltyKickState(const rcsc::WorldModel &wm, const rcsc::PenaltyKickState *state);
3436
static void updatePlayerObject(soccer::Player &p, const rcsc::PlayerObject *player);
3537
static void updatePlayerObject(soccer::Player &p, const rcsc::CoachPlayerObject *player);
3638
static void updateAbstractPlayerObject(soccer::Player &p, const rcsc::AbstractPlayerObject *player);

0 commit comments

Comments
 (0)