Skip to content

Commit

Permalink
Merge pull request #30 from CLSFramework/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
naderzare authored Oct 12, 2024
2 parents ae81de6 + 36a9f84 commit 098ddc2
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 29 deletions.
56 changes: 53 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,68 @@
# ChangeLog

## [1.0.4] - 2024-10-8

### Added
- self.effort and wm.see_time are added

### Fixed
-

### Changed
-

### Developer
- [SoroushMazloum](https://github.com/SoroushMazloum)


## [1.0.3] - 2024-10-7

### Added
- penalty_kick_state has been added to the proxy in the WorldModel message.

### Fixed
-

### Changed
-

### Developer
- [SadraKhanjari](https://github.com/SK2iP)
- [SoroushMazloum](https://github.com/SoroushMazloum)


## [1.0.2] - 2024-09-15

### Added
- ignore_doforcekick and ignore_doHeardPassRecieve has been added to the proxy in the actions message.
- now users can decide to do the doForceKick and doHeardPassRecieve or not

### Fixed
- now state only generate once per cycle

### Changed
-

### Developer
- [NaderZare](https://github.com/naderzare)
- [SadraKhanjari](https://github.com/SK2iP)

## [1.0.1] - 2024-09-15

### Added
- catch_time has been added to the proxy in the self message.
- kickable_opponent_existance and kickable_teammate_existance has been added to the proxy in the worldmodel message.
- bhv_doforceKick action has been added as a message and to the actions message.

### Fixed
-

### Changed
-

### Engineers
- [SoroushMazloum](https://github.com/)
### Developer
- [SoroushMazloum](https://github.com/SoroushMazloum)
- [SadraKhanjari](https://github.com/SK2iP)

## [1.0.0] - 2024-09-15

Expand All @@ -27,7 +77,7 @@
### Changed
- changed chain_action messages name to planner

### Engineers
### Developer
- [NaderZare](https://github.com/naderzare)
- [SadraKhanjari](https://github.com/SK2iP)

Expand Down
28 changes: 26 additions & 2 deletions idl/grpc/service.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// version 1
// version 1.4

syntax = "proto3";

Expand Down Expand Up @@ -102,6 +102,16 @@ enum CardType {
RED = 2;
}

message PenaltyKickState {
Side on_field_side = 1;
Side current_taker_side = 2;
int32 our_taker_counter = 3;
int32 their_taker_counter = 4;
int32 our_score = 5;
int32 their_score = 6;
bool is_kick_taker = 7;
}

message Player {
RpcVector2D position = 1;
RpcVector2D seen_position = 2;
Expand Down Expand Up @@ -175,6 +185,8 @@ message Self {
float recovery = 37;
float stamina_capacity = 38;
CardType card = 39;
int32 catch_time = 40;
float effort = 41;
}

enum InterceptActionType {
Expand Down Expand Up @@ -282,6 +294,10 @@ message WorldModel {
double their_defense_line_x = 33;
double our_defense_player_line_x = 34;
double their_defense_player_line_x = 35;
bool kickable_teammate_existance = 36;
bool kickable_opponent_existance = 37;
PenaltyKickState penalty_kick_state = 38;
int32 see_time = 39;
}

message State {
Expand Down Expand Up @@ -799,6 +815,10 @@ message HeliosPenalty {}

message HeliosCommunicaion {}

message bhv_doForceKick {}

message bhv_doHeardPassRecieve {}

message PlayerAction {
oneof action {
Dash dash = 1;
Expand Down Expand Up @@ -865,13 +885,17 @@ message PlayerAction {
HeliosSetPlay helios_set_play = 62;
HeliosPenalty helios_penalty = 63;
HeliosCommunicaion helios_communication = 64;
bhv_doForceKick bhv_do_force_kick = 65;
bhv_doHeardPassRecieve bhv_do_heard_pass_recieve = 66;

}
}

message PlayerActions {
repeated PlayerAction actions = 1;
bool ignore_preprocess = 2;
bool ignore_doforcekick = 3;
bool ignore_doHeardPassRecieve = 4;
}

message ChangePlayerType {
Expand Down Expand Up @@ -1299,4 +1323,4 @@ service Game {
rpc Register(RegisterRequest) returns (RegisterResponse) {}
rpc SendByeCommand(RegisterResponse) returns (Empty) {}
rpc GetBestPlannerAction(BestPlannerActionRequest) returns (BestPlannerActionResponse) {}
}
}
34 changes: 29 additions & 5 deletions idl/thrift/soccer_service.thrift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// version 1
// version 1.4

namespace cpp soccer
namespace py soccer
Expand Down Expand Up @@ -105,6 +105,16 @@ enum CardType {
RED = 2
}

struct PenaltyKickState {
1: Side on_field_side,
2: Side current_taker_side,
3: i32 our_taker_counter,
4: i32 their_taker_counter,
5: i32 our_score,
6: i32 their_score,
7: bool is_kick_taker
}

struct Player {
1: RpcVector2D position,
2: RpcVector2D seen_position,
Expand Down Expand Up @@ -177,7 +187,9 @@ struct Self {
36: double kick_rate,
37: double recovery,
38: double stamina_capacity,
39: CardType card
39: CardType card,
40: i32 catch_time,
41: double effort
}

enum InterceptActionType {
Expand Down Expand Up @@ -284,7 +296,11 @@ struct WorldModel {
32: double our_defense_line_x,
33: double their_defense_line_x,
34: double our_defense_player_line_x,
35: double their_defense_player_line_x
35: double their_defense_player_line_x,
36: bool kickable_teammate_existance,
37: bool kickable_opponent_existance,
38: PenaltyKickState penalty_kick_state,
39: i32 see_time
}

struct State {
Expand Down Expand Up @@ -765,6 +781,10 @@ struct HeliosPenalty {}

struct HeliosCommunicaion {}

struct bhv_doForceKick {}

struct bhv_doHeardPassRecieve {}

struct PlayerAction {
1: optional Dash dash,
2: optional Turn turn,
Expand Down Expand Up @@ -829,12 +849,16 @@ struct PlayerAction {
61: optional HeliosBasicMove helios_basic_move,
62: optional HeliosSetPlay helios_set_play,
63: optional HeliosPenalty helios_penalty,
64: optional HeliosCommunicaion helios_communication
64: optional HeliosCommunicaion helios_communication,
65: optional bhv_doForceKick bhv_do_force_kick,
66: optional bhv_doHeardPassRecieve bhv_do_heard_pass_recieve
}

struct PlayerActions {
1: list<PlayerAction> actions,
2: bool ignore_preprocess
2: bool ignore_preprocess,
3: bool ignore_doforcekick,
4: bool ignore_doHeardPassRecieve
}

struct ChangePlayerType {
Expand Down
64 changes: 61 additions & 3 deletions src/grpc-client/grpc_client_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ void GrpcClientPlayer::getActions()
{
auto agent = M_agent;
bool pre_process = checkPreprocess(agent);
bool do_forceKick = checkdoForceKick(agent);
bool do_heardPassReceive = checkdoHeardPassReceive(agent);
State state = generateState();
state.set_need_preprocess(pre_process);
protos::RegisterResponse* response = new protos::RegisterResponse(*M_register_response);
Expand All @@ -134,6 +136,26 @@ void GrpcClientPlayer::getActions()
}
}

if (do_forceKick && !actions.ignore_doforcekick())
{
if (doForceKick(agent))
{
rcsc::dlog.addText( rcsc::Logger::TEAM,
__FILE__": doForceKick done" );
return;
}
}

if (do_heardPassReceive && !actions.ignore_doheardpassrecieve())
{
if (doHeardPassReceive(agent))
{
rcsc::dlog.addText( rcsc::Logger::TEAM,
__FILE__": doHeardPassReceive done" );
return;
}
}

for (int i = 0; i < actions.actions_size(); i++)
{
auto action = actions.actions(i);
Expand Down Expand Up @@ -376,6 +398,10 @@ void GrpcClientPlayer::getActions()
.execute(agent);
agent->debugClient().addMessage("Neck_TurnToBallAndPlayer");
}
else
{
agent->debugClient().addMessage("Neck_TurnToBallAndPlayer null player");
}
}
else if (action.action_case() == PlayerAction::kNeckTurnToBallOrScan) {
const auto &neckTurnToBallOrScan = action.neck_turn_to_ball_or_scan();
Expand Down Expand Up @@ -416,6 +442,10 @@ void GrpcClientPlayer::getActions()
.execute(agent);
agent->debugClient().addMessage("Neck_TurnToPlayerOrScan");
}
else
{
agent->debugClient().addMessage("Neck_TurnToPlayerOrScan null player");
}
}
else if (action.action_case() == PlayerAction::kNeckTurnToPoint) {
const auto &neckTurnToPoint = action.neck_turn_to_point();
Expand Down Expand Up @@ -490,6 +520,28 @@ void GrpcClientPlayer::getActions()
sample_communication->execute(agent);
agent->debugClient().addMessage("sample_communication - execute");
}
else if (action.action_case() == PlayerAction::kBhvDoForceKick)
{
if(doForceKick(agent))
{
agent->debugClient().addMessage("doForceKick");
}
else
{
agent->debugClient().addMessage("doForceKick - false");
}
}
else if (action.action_case() == PlayerAction::kBhvDoHeardPassRecieve)
{
if(doHeardPassReceive(agent))
{
agent->debugClient().addMessage("doHeardPassReceive");
}
else
{
agent->debugClient().addMessage("doHeardPassReceive - false");
}
}
else if (action.action_case() == PlayerAction::kHeliosOffensivePlanner) {
FieldEvaluator::ConstPtr field_evaluator = FieldEvaluator::ConstPtr(new SampleFieldEvaluator);
CompositeActionGenerator *g = new CompositeActionGenerator();
Expand Down Expand Up @@ -785,14 +837,20 @@ void GrpcClientPlayer::addSayMessage(protos::Say sayMessage) const
}
}

State GrpcClientPlayer::generateState() const
protos::State GrpcClientPlayer::generateState()
{
const rcsc::WorldModel &wm = M_agent->world();
if (M_state_update_time == wm.time())
{
return M_state;
}
M_state_update_time = wm.time();
WorldModel *worldModel = StateGenerator::convertWorldModel(wm);
addHomePosition(worldModel);
State state;
protos::State state;
state.set_allocated_world_model(worldModel);
return state;
M_state = state;
return M_state;
}

void GrpcClientPlayer::addHomePosition(protos::WorldModel *res) const
Expand Down
5 changes: 4 additions & 1 deletion src/grpc-client/grpc_client_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class GrpcClientPlayer : public GrpcClient, public RpcPlayerClient
bool GetBestPlannerAction();
void convertResultPairToRpcActionStatePair( google::protobuf::Map<int32_t, protos::RpcActionState> * map);
void addSayMessage(protos::Say sayMessage) const;
State generateState() const;
State generateState();
void addHomePosition(protos::WorldModel *world_model) const;
private:
rcsc::GameTime M_state_update_time;
protos::State M_state;
};
Loading

0 comments on commit 098ddc2

Please sign in to comment.