From aa7b50a0f9b62b185d2c10876bd983b90c649eeb Mon Sep 17 00:00:00 2001 From: naderzare Date: Tue, 12 Nov 2024 22:44:20 -0400 Subject: [PATCH 1/5] just run the first main action --- src/grpc-client/grpc_client_player.cpp | 845 +++++++++++++++++++------ src/player/role_goalie.cpp | 20 +- src/player/role_goalie.h | 4 +- 3 files changed, 681 insertions(+), 188 deletions(-) diff --git a/src/grpc-client/grpc_client_player.cpp b/src/grpc-client/grpc_client_player.cpp index 627d4e5e..460bc021 100644 --- a/src/grpc-client/grpc_client_player.cpp +++ b/src/grpc-client/grpc_client_player.cpp @@ -214,6 +214,8 @@ void GrpcClientPlayer::getActions() { // reset intention agent->setIntention( static_cast< rcsc::SoccerIntention * >( 0 ) ); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": shoot in preprocess performed" ); return; } } @@ -222,6 +224,8 @@ void GrpcClientPlayer::getActions() { if ( agent->doIntention() ) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doIntention performed" ); return; } } @@ -231,7 +235,7 @@ void GrpcClientPlayer::getActions() if (doForceKick(agent)) { rcsc::dlog.addText( rcsc::Logger::TEAM, - __FILE__": doForceKick done" ); + __FILE__": doForceKick performed" ); return; } } @@ -241,7 +245,7 @@ void GrpcClientPlayer::getActions() if (doHeardPassReceive(agent)) { rcsc::dlog.addText( rcsc::Logger::TEAM, - __FILE__": doHeardPassReceive done" ); + __FILE__": doHeardPassReceive performed" ); return; } } @@ -302,10 +306,14 @@ void GrpcClientPlayer::getActions() if (planner_action_index != -1) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": updateChainByPlannerAction" ); updateChainByPlannerAction(wm, actions.actions(planner_action_index)); } else { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": updateChainByDefault" ); updateChainByDefault(wm); } @@ -341,232 +349,551 @@ void GrpcClientPlayer::getActions() // return; // } - + bool action_performed = false; for (int i = 0; i < actions.actions_size(); i++) { auto action = actions.actions(i); - if (action.action_case() == PlayerAction::kDash) { - agent->doDash(action.dash().power(), action.dash().relative_direction()); + if (action.action_case() == PlayerAction::kDash && !action_performed) { + if (agent->doDash(action.dash().power(), action.dash().relative_direction())) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doDash performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doDash failed" ); + } } - else if (action.action_case() == PlayerAction::kKick) { - agent->doKick(action.kick().power(), action.kick().relative_direction()); + else if (action.action_case() == PlayerAction::kKick && !action_performed) { + if (agent->doKick(action.kick().power(), action.kick().relative_direction())) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doKick performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doKick failed" ); + } } - else if (action.action_case() == PlayerAction::kTurn) { - agent->doTurn(action.turn().relative_direction()); + else if (action.action_case() == PlayerAction::kTurn && !action_performed) { + if (agent->doTurn(action.turn().relative_direction())) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTurn performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTurn failed" ); + } } - else if (action.action_case() == PlayerAction::kTackle) { - agent->doTackle(action.tackle().power_or_dir(), action.tackle().foul()); + else if (action.action_case() == PlayerAction::kTackle && !action_performed) { + if (agent->doTackle(action.tackle().power_or_dir(), action.tackle().foul())) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTackle performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTackle failed" ); + } } - else if (action.action_case() == PlayerAction::kCatch) { - agent->doCatch(); + else if (action.action_case() == PlayerAction::kCatch && !action_performed) { + if (agent->doCatch()) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doCatch performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doCatch failed" ); + } } - else if (action.action_case() == PlayerAction::kMove) { - agent->doMove(action.move().x(), action.move().y()); + else if (action.action_case() == PlayerAction::kMove && !action_performed) { + if (agent->doMove(action.move().x(), action.move().y())) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doMove performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doMove failed" ); + } } else if (action.action_case() == PlayerAction::kTurnNeck) { - agent->doTurnNeck(action.turn_neck().moment()); + if (agent->doTurnNeck(action.turn_neck().moment())) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTurnNeck performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTurnNeck failed" ); + } } else if (action.action_case() == PlayerAction::kChangeView) { const rcsc::ViewWidth view_width = GrpcClient::convertViewWidth(action.change_view().view_width()); - agent->doChangeView(view_width); + if (agent->doChangeView(view_width)) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doChangeView performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doChangeView failed" ); + } } else if (action.action_case() == PlayerAction::kSay) { addSayMessage(action.say()); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": addSayMessage called" ); } else if (action.action_case() == PlayerAction::kPointTo) { - agent->doPointto(action.point_to().x(), action.point_to().y()); + if (agent->doPointto(action.point_to().x(), action.point_to().y())) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doPointto performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doPointto failed" ); + } } else if (action.action_case() == PlayerAction::kPointToOf) { - - agent->doPointtoOff(); + if (agent->doPointtoOff()) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doPointtoOff performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doPointtoOff failed" ); + } } else if (action.action_case() == PlayerAction::kAttentionTo) { const rcsc::SideID side = GrpcClient::convertSideID(action.attention_to().side()); - agent->doAttentionto(side, action.attention_to().unum()); + if (agent->doAttentionto(side, action.attention_to().unum())) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doAttentionto performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doAttentionto failed" ); + } } else if (action.action_case() == PlayerAction::kAttentionToOf) { - agent->doAttentiontoOff(); + if (agent->doAttentiontoOff()) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doAttentiontoOff performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doAttentiontoOff failed" ); + } } else if (action.action_case() == PlayerAction::kLog) { addDlog(action.log()); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": addDlog called" ); } - else if (action.action_case() == PlayerAction::kBodyGoToPoint) { + else if (action.action_case() == PlayerAction::kBodyGoToPoint && !action_performed) { const auto &bodyGoToPoint = action.body_go_to_point(); const auto &targetPoint = GrpcClient::convertVector2D(bodyGoToPoint.target_point()); - Body_GoToPoint(targetPoint, bodyGoToPoint.distance_threshold(), bodyGoToPoint.max_dash_power()).execute(agent); - agent->debugClient().addMessage("Body_GoToPoint"); + if (Body_GoToPoint(targetPoint, bodyGoToPoint.distance_threshold(), bodyGoToPoint.max_dash_power()).execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_GoToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_GoToPoint failed" ); + } } - else if (action.action_case() == PlayerAction::kBodySmartKick) { + else if (action.action_case() == PlayerAction::kBodySmartKick && !action_performed) { const auto &bodySmartKick = action.body_smart_kick(); const auto &targetPoint = GrpcClient::convertVector2D(bodySmartKick.target_point()); - Body_SmartKick(targetPoint, bodySmartKick.first_speed(), bodySmartKick.first_speed_threshold(), bodySmartKick.max_steps()).execute(agent); - agent->debugClient().addMessage("Body_SmartKick"); + if (Body_SmartKick(targetPoint, bodySmartKick.first_speed(), bodySmartKick.first_speed_threshold(), bodySmartKick.max_steps()).execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_SmartKick performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_SmartKick failed" ); + } } - else if (action.action_case() == PlayerAction::kBhvBeforeKickOff) { + else if (action.action_case() == PlayerAction::kBhvBeforeKickOff && !action_performed) { const auto &bhvBeforeKickOff = action.bhv_before_kick_off(); const auto &point = GrpcClient::convertVector2D(bhvBeforeKickOff.point()); - Bhv_BeforeKickOff(point).execute(agent); - agent->debugClient().addMessage("Bhv_BeforeKickOff"); + if (Bhv_BeforeKickOff(point).execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BeforeKickOff performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BeforeKickOff failed" ); + } } - else if (action.action_case() == PlayerAction::kBhvBodyNeckToBall) { - Bhv_BodyNeckToBall().execute(agent); - agent->debugClient().addMessage("Bhv_BodyNeckToBall"); + else if (action.action_case() == PlayerAction::kBhvBodyNeckToBall && !action_performed) { + if (Bhv_BodyNeckToBall().execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BodyNeckToBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BodyNeckToBall failed" ); + } } - else if (action.action_case() == PlayerAction::kBhvBodyNeckToPoint) { + else if (action.action_case() == PlayerAction::kBhvBodyNeckToPoint && !action_performed) { const auto &bhvBodyNeckToPoint = action.bhv_body_neck_to_point(); const auto &targetPoint = GrpcClient::convertVector2D(bhvBodyNeckToPoint.point()); - Bhv_BodyNeckToPoint(targetPoint).execute(agent); - agent->debugClient().addMessage("Bhv_BodyNeckToPoint"); + if (Bhv_BodyNeckToPoint(targetPoint).execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BodyNeckToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BodyNeckToPoint failed" ); + } } else if (action.action_case() == PlayerAction::kBhvEmergency) { - Bhv_Emergency().execute(agent); - agent->debugClient().addMessage("Bhv_Emergency"); - + if (Bhv_Emergency().execute(agent)) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_Emergency performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_Emergency failed" ); + } } - else if (action.action_case() == PlayerAction::kBhvGoToPointLookBall) { + else if (action.action_case() == PlayerAction::kBhvGoToPointLookBall && !action_performed) { const auto &bhvGoToPointLookBall = action.bhv_go_to_point_look_ball(); const auto &targetPoint = GrpcClient::convertVector2D(bhvGoToPointLookBall.target_point()); - Bhv_GoToPointLookBall(targetPoint, bhvGoToPointLookBall.distance_threshold(), bhvGoToPointLookBall.max_dash_power()).execute(agent); - agent->debugClient().addMessage("Bhv_GoToPointLookBall"); + if (Bhv_GoToPointLookBall(targetPoint, bhvGoToPointLookBall.distance_threshold(), bhvGoToPointLookBall.max_dash_power()).execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_GoToPointLookBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_GoToPointLookBall failed" ); + } } - else if (action.action_case() == PlayerAction::kBhvNeckBodyToBall) { + else if (action.action_case() == PlayerAction::kBhvNeckBodyToBall && !action_performed) { const auto &bhvNeckBodyToBall = action.bhv_neck_body_to_ball(); - Bhv_NeckBodyToBall(bhvNeckBodyToBall.angle_buf()).execute(agent); - agent->debugClient().addMessage("Bhv_NeckBodyToBall"); + if (Bhv_NeckBodyToBall(bhvNeckBodyToBall.angle_buf()).execute(agent)) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_NeckBodyToBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_NeckBodyToBall failed" ); + } } - else if (action.action_case() == PlayerAction::kBhvNeckBodyToPoint) { + else if (action.action_case() == PlayerAction::kBhvNeckBodyToPoint && !action_performed) { const auto &bhvNeckBodyToPoint = action.bhv_neck_body_to_point(); const auto &targetPoint = GrpcClient::convertVector2D(bhvNeckBodyToPoint.point()); - Bhv_NeckBodyToPoint(targetPoint, bhvNeckBodyToPoint.angle_buf()).execute(agent); - agent->debugClient().addMessage("Bhv_NeckBodyToPoint"); + if (Bhv_NeckBodyToPoint(targetPoint, bhvNeckBodyToPoint.angle_buf()).execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_NeckBodyToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_NeckBodyToPoint failed" ); + } } - else if (action.action_case() == PlayerAction::kBhvScanField) { - Bhv_ScanField().execute(agent); - agent->debugClient().addMessage("Bhv_ScanField"); + else if (action.action_case() == PlayerAction::kBhvScanField && !action_performed) { + if (Bhv_ScanField().execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_ScanField performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_ScanField failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyAdvanceBall) { - Body_AdvanceBall().execute(agent); - agent->debugClient().addMessage("Body_AdvanceBall"); + else if (action.action_case() == PlayerAction::kBodyAdvanceBall && !action_performed) { + if (Body_AdvanceBall().execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_AdvanceBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_AdvanceBall failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyClearBall) { - Body_ClearBall().execute(agent); - agent->debugClient().addMessage("Body_ClearBall"); + else if (action.action_case() == PlayerAction::kBodyClearBall && !action_performed) { + if (Body_ClearBall().execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_ClearBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_ClearBall failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyDribble) { + else if (action.action_case() == PlayerAction::kBodyDribble && !action_performed) { const auto &bodyDribble = action.body_dribble(); const auto &targetPoint = GrpcClient::convertVector2D(bodyDribble.target_point()); - Body_Dribble( + if (Body_Dribble( targetPoint, bodyDribble.distance_threshold(), bodyDribble.dash_power(), bodyDribble.dash_count(), bodyDribble.dodge()) - .execute(agent); - agent->debugClient().addMessage("Body_Dribble"); + .execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_Dribble performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_Dribble failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyGoToPointDodge) { + else if (action.action_case() == PlayerAction::kBodyGoToPointDodge && !action_performed) { const auto &bodyGoToPointDodge = action.body_go_to_point_dodge(); const auto &targetPoint = GrpcClient::convertVector2D(bodyGoToPointDodge.target_point()); - Body_GoToPointDodge( + if (Body_GoToPointDodge( targetPoint, bodyGoToPointDodge.dash_power()) - .execute(agent); - agent->debugClient().addMessage("Body_GoToPointDodge"); + .execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_GoToPointDodge performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_GoToPointDodge failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyHoldBall) { + else if (action.action_case() == PlayerAction::kBodyHoldBall && !action_performed) { const auto &bodyHoldBall = action.body_hold_ball(); const auto &turnTargetPoint = GrpcClient::convertVector2D(bodyHoldBall.turn_target_point()); const auto &kickTargetPoint = GrpcClient::convertVector2D(bodyHoldBall.kick_target_point()); - Body_HoldBall( + if (Body_HoldBall( bodyHoldBall.do_turn(), turnTargetPoint, kickTargetPoint) - .execute(agent); - agent->debugClient().addMessage("Body_HoldBall"); + .execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_HoldBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_HoldBall failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyIntercept) { + else if (action.action_case() == PlayerAction::kBodyIntercept && !action_performed) { const auto &bodyIntercept = action.body_intercept(); const auto &facePoint = GrpcClient::convertVector2D(bodyIntercept.face_point()); - Body_Intercept( + if (Body_Intercept( bodyIntercept.save_recovery(), facePoint) - .execute(agent); - agent->debugClient().addMessage("Body_Intercept"); + .execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_Intercept performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_Intercept failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyKickOneStep) { + else if (action.action_case() == PlayerAction::kBodyKickOneStep && !action_performed) { const auto &bodyKickOneStep = action.body_kick_one_step(); const auto &targetPoint = GrpcClient::convertVector2D(bodyKickOneStep.target_point()); - Body_KickOneStep( + if (Body_KickOneStep( targetPoint, bodyKickOneStep.first_speed(), bodyKickOneStep.force_mode()) - .execute(agent); - agent->debugClient().addMessage("Body_KickOneStep"); + .execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_KickOneStep performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_KickOneStep failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyStopBall) { - Body_StopBall().execute(agent); - agent->debugClient().addMessage("Body_StopBall"); + else if (action.action_case() == PlayerAction::kBodyStopBall && !action_performed) { + if (Body_StopBall().execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_StopBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_StopBall failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyStopDash) { + else if (action.action_case() == PlayerAction::kBodyStopDash && !action_performed) { const auto &bodyStopDash = action.body_stop_dash(); - Body_StopDash( + if (Body_StopDash( bodyStopDash.save_recovery()) - .execute(agent); - agent->debugClient().addMessage("Body_StopDash"); + .execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_StopDash performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_StopDash failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyTackleToPoint) { + else if (action.action_case() == PlayerAction::kBodyTackleToPoint && !action_performed) { const auto &bodyTackleToPoint = action.body_tackle_to_point(); const auto &targetPoint = GrpcClient::convertVector2D(bodyTackleToPoint.target_point()); - Body_TackleToPoint( + if (Body_TackleToPoint( targetPoint, bodyTackleToPoint.min_probability(), bodyTackleToPoint.min_speed()) - .execute(agent); - agent->debugClient().addMessage("Body_TackleToPoint"); + .execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TackleToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TackleToPoint failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyTurnToAngle) { + else if (action.action_case() == PlayerAction::kBodyTurnToAngle && !action_performed) { const auto &bodyTurnToAngle = action.body_turn_to_angle(); - Body_TurnToAngle( + if (Body_TurnToAngle( bodyTurnToAngle.angle()) - .execute(agent); - agent->debugClient().addMessage("Body_TurnToAngle"); + .execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToAngle performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToAngle failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyTurnToBall) { + else if (action.action_case() == PlayerAction::kBodyTurnToBall && !action_performed) { const auto &bodyTurnToBall = action.body_turn_to_ball(); - Body_TurnToBall( + if (Body_TurnToBall( bodyTurnToBall.cycle()) - .execute(agent); - agent->debugClient().addMessage("Body_TurnToBall"); + .execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToBall failed" ); + } } - else if (action.action_case() == PlayerAction::kBodyTurnToPoint) { + else if (action.action_case() == PlayerAction::kBodyTurnToPoint && !action_performed) { const auto &bodyTurnToPoint = action.body_turn_to_point(); const auto &targetPoint = GrpcClient::convertVector2D(bodyTurnToPoint.target_point()); - Body_TurnToPoint( + if (Body_TurnToPoint( targetPoint, bodyTurnToPoint.cycle()) - .execute(agent); - agent->debugClient().addMessage("Body_TurnToPoint"); + .execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToPoint failed" ); + } } else if (action.action_case() == PlayerAction::kFocusMoveToPoint) { const auto &focusMoveToPoint = action.focus_move_to_point(); const auto &targetPoint = GrpcClient::convertVector2D(focusMoveToPoint.target_point()); - rcsc::Focus_MoveToPoint( + if (rcsc::Focus_MoveToPoint( targetPoint) - .execute(agent); - agent->debugClient().addMessage("Focus_MoveToPoint"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Focus_MoveToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Focus_MoveToPoint failed" ); + } } else if (action.action_case() == PlayerAction::kFocusReset) { - rcsc::Focus_Reset().execute(agent); - agent->debugClient().addMessage("Focus_Reset"); + if (rcsc::Focus_Reset().execute(agent)) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Focus_Reset performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Focus_Reset failed" ); + } } else if (action.action_case() == PlayerAction::kNeckScanField) { - Neck_ScanField().execute(agent); - agent->debugClient().addMessage("Neck_ScanField"); + if (Neck_ScanField().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_ScanField performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_ScanField failed" ); + } } else if (action.action_case() == PlayerAction::kNeckScanPlayers) { - Neck_ScanPlayers().execute(agent); - agent->debugClient().addMessage("Neck_ScanPlayers"); + if (Neck_ScanPlayers().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_ScanPlayers performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_ScanPlayers failed" ); + } } else if (action.action_case() == PlayerAction::kNeckTurnToBallAndPlayer) { const auto &neckTurnToBallAndPlayer = action.neck_turn_to_ball_and_player(); @@ -578,39 +905,67 @@ void GrpcClientPlayer::getActions() player = agent->world().theirPlayer(neckTurnToBallAndPlayer.uniform_number()); } if (player != nullptr){ - Neck_TurnToBallAndPlayer( + if (Neck_TurnToBallAndPlayer( player, neckTurnToBallAndPlayer.count_threshold()) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToBallAndPlayer"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToBallAndPlayer performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToBallAndPlayer failed" ); + } } else { - agent->debugClient().addMessage("Neck_TurnToBallAndPlayer null player"); + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToBallAndPlayer failed (no player)" ); } } else if (action.action_case() == PlayerAction::kNeckTurnToBallOrScan) { const auto &neckTurnToBallOrScan = action.neck_turn_to_ball_or_scan(); - Neck_TurnToBallOrScan( - neckTurnToBallOrScan.count_threshold()) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToBallOrScan"); + if (Neck_TurnToBallOrScan(neckTurnToBallOrScan.count_threshold()).execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToBallOrScan performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToBallOrScan failed" ); + } } else if (action.action_case() == PlayerAction::kNeckTurnToBall) { - Neck_TurnToBall().execute(agent); - agent->debugClient().addMessage("Neck_TurnToBall"); + if (Neck_TurnToBall().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToBall failed" ); + } } else if (action.action_case() == PlayerAction::kNeckTurnToGoalieOrScan) { const auto &neckTurnToGoalieOrScan = action.neck_turn_to_goalie_or_scan(); - Neck_TurnToGoalieOrScan( + if (Neck_TurnToGoalieOrScan( neckTurnToGoalieOrScan.count_threshold()) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToGoalieOrScan"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToGoalieOrScan performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToGoalieOrScan failed" ); + } } else if (action.action_case() == PlayerAction::kNeckTurnToLowConfTeammate) { const auto &neckTurnToLowConfTeammate = action.neck_turn_to_low_conf_teammate(); - Neck_TurnToLowConfTeammate().execute(agent); - agent->debugClient().addMessage("Neck_TurnToLowConfTeammate"); + if (Neck_TurnToLowConfTeammate().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToLowConfTeammate performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToLowConfTeammate failed" ); + } } else if (action.action_case() == PlayerAction::kNeckTurnToPlayerOrScan) { const auto &neckTurnToPlayerOrScan = action.neck_turn_to_player_or_scan(); @@ -622,141 +977,271 @@ void GrpcClientPlayer::getActions() player = agent->world().theirPlayer(neckTurnToPlayerOrScan.uniform_number()); } if (player != nullptr){ - Neck_TurnToPlayerOrScan( + if (Neck_TurnToPlayerOrScan( player, neckTurnToPlayerOrScan.count_threshold()) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToPlayerOrScan"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToPlayerOrScan performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToPlayerOrScan failed" ); + } } else { - agent->debugClient().addMessage("Neck_TurnToPlayerOrScan null player"); + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToPlayerOrScan failed (no player)" ); } } else if (action.action_case() == PlayerAction::kNeckTurnToPoint) { const auto &neckTurnToPoint = action.neck_turn_to_point(); const auto &targetPoint = GrpcClient::convertVector2D(neckTurnToPoint.target_point()); - Neck_TurnToPoint( + if (Neck_TurnToPoint( targetPoint) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToPoint"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToPoint failed" ); + } } else if (action.action_case() == PlayerAction::kNeckTurnToRelative) { const auto &neckTurnToRelative = action.neck_turn_to_relative(); - Neck_TurnToRelative( + if (Neck_TurnToRelative( neckTurnToRelative.angle()) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToRelative"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToRelative performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToRelative failed" ); + } } else if (action.action_case() == PlayerAction::kViewChangeWidth) { const auto &viewChangeWidth = action.view_change_width(); const rcsc::ViewWidth view_width = GrpcClient::convertViewWidth(viewChangeWidth.view_width()); - View_ChangeWidth( + if (View_ChangeWidth( view_width) - .execute(agent); - agent->debugClient().addMessage("View_ChangeWidth"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": View_ChangeWidth performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": View_ChangeWidth failed" ); + } } else if (action.action_case() == PlayerAction::kViewNormal) { - View_Normal().execute(agent); - agent->debugClient().addMessage("View_Normal"); + if (View_Normal().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": View_Normal performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": View_Normal failed" ); + } } else if (action.action_case() == PlayerAction::kViewWide) { - View_Wide().execute(agent); - agent->debugClient().addMessage("View_Wide"); + if (View_Wide().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": View_Wide performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": View_Wide failed" ); + } } else if (action.action_case() == PlayerAction::kViewSynch) { - View_Synch().execute(agent); - agent->debugClient().addMessage("View_Synch"); + if (View_Synch().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": View_Synch performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": View_Synch failed" ); + } } - else if (action.action_case() == PlayerAction::kHeliosGoalie) { + else if (action.action_case() == PlayerAction::kHeliosGoalie && !action_performed) { RoleGoalie roleGoalie = RoleGoalie(); - roleGoalie.execute(agent); - agent->debugClient().addMessage("RoleGoalie - execute"); + if (roleGoalie.execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie failed" ); + } } - else if (action.action_case() == PlayerAction::kHeliosGoalieMove) { + else if (action.action_case() == PlayerAction::kHeliosGoalieMove && !action_performed) { RoleGoalie roleGoalie = RoleGoalie(); - roleGoalie.doMove(agent); - agent->debugClient().addMessage("RoleGoalie - do Move"); + if (roleGoalie.doMove(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie doMove performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie doMove failed" ); + } } - else if (action.action_case() == PlayerAction::kHeliosGoalieKick) { + else if (action.action_case() == PlayerAction::kHeliosGoalieKick && !action_performed) { RoleGoalie roleGoalie = RoleGoalie(); - roleGoalie.doKick(agent); - agent->debugClient().addMessage("RoleGoalie - do Kick"); + if (roleGoalie.doKick(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie doKick performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie doKick failed" ); + } } - else if (action.action_case() == PlayerAction::kHeliosShoot) { + else if (action.action_case() == PlayerAction::kHeliosShoot && !action_performed) { const rcsc::WorldModel &wm = agent->world(); if (wm.gameMode().type() != rcsc::GameMode::IndFreeKick_ && wm.time().stopped() == 0 && wm.self().isKickable() && Bhv_StrictCheckShoot().execute(agent)) - { + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_StrictCheckShoot performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_StrictCheckShoot failed" ); } } - else if (action.action_case() == PlayerAction::kHeliosBasicMove) { - Bhv_BasicMove().execute(agent); - agent->debugClient().addMessage("Bhv_BasicMove"); + else if (action.action_case() == PlayerAction::kHeliosBasicMove && !action_performed) { + if (Bhv_BasicMove().execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BasicMove performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BasicMove failed" ); + } } - else if (action.action_case() == PlayerAction::kHeliosSetPlay) { - Bhv_SetPlay().execute(agent); - agent->debugClient().addMessage("Bhv_SetPlay"); + else if (action.action_case() == PlayerAction::kHeliosSetPlay && !action_performed) { + if (Bhv_SetPlay().execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_SetPlay performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_SetPlay failed" ); + } } - else if (action.action_case() == PlayerAction::kHeliosPenalty) { - Bhv_PenaltyKick().execute(agent); - agent->debugClient().addMessage("Bhv_PenaltyKick"); + else if (action.action_case() == PlayerAction::kHeliosPenalty && !action_performed) { + if (Bhv_PenaltyKick().execute(agent)) { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PenaltyKick performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PenaltyKick failed" ); + } } else if (action.action_case() == PlayerAction::kHeliosCommunication) { - sample_communication->execute(agent); - agent->debugClient().addMessage("sample_communication - execute"); + if (sample_communication->execute(agent)) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": sample_communication performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": sample_communication failed" ); + } } - else if (action.action_case() == PlayerAction::kBhvDoForceKick) + else if (action.action_case() == PlayerAction::kBhvDoForceKick && !action_performed) { if(doForceKick(agent)) { - agent->debugClient().addMessage("doForceKick"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doForceKick performed" ); } else { - agent->debugClient().addMessage("doForceKick - false"); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doForceKick failed" ); } } - else if (action.action_case() == PlayerAction::kBhvDoHeardPassRecieve) + else if (action.action_case() == PlayerAction::kBhvDoHeardPassRecieve && !action_performed) { if(doHeardPassReceive(agent)) { - agent->debugClient().addMessage("doHeardPassReceive"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doHeardPassReceive performed" ); } else { - agent->debugClient().addMessage("doHeardPassReceive - false"); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doHeardPassReceive failed" ); } } - else if (action.action_case() == PlayerAction::kHeliosOffensivePlanner) { + else if (action.action_case() == PlayerAction::kHeliosOffensivePlanner && !action_performed) { if (action.helios_offensive_planner().server_side_decision()) { if (GetBestPlannerAction()) { - agent->debugClient().addMessage("GetBestPlannerAction"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": GetBestPlannerAction performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": GetBestPlannerAction failed" ); } } else { if (Bhv_PlannedAction().execute(agent)) { - agent->debugClient().addMessage("PlannedAction"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PlannedAction performed" ); } else { - Body_HoldBall().execute(agent); - agent->setNeckAction(new Neck_ScanField()); + if (Body_HoldBall().execute(agent)) + { + action_performed = true; + agent->setNeckAction(new Neck_ScanField()); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PlannedAction failed (Hold Ball performed)" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PlannedAction failed (Hold Ball Failed)" ); + } } } - } else { #ifdef DEBUG_CLIENT_PLAYER std::cout << "Unkown action"<setNeckAction(new Neck_ScanField()); + + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Unkown action or another main action performed"); } } } diff --git a/src/player/role_goalie.cpp b/src/player/role_goalie.cpp index 2b96c8a1..1ebaeb88 100644 --- a/src/player/role_goalie.cpp +++ b/src/player/role_goalie.cpp @@ -103,26 +103,34 @@ RoleGoalie::execute( PlayerAgent * agent ) /*! */ -void +bool RoleGoalie::doKick( PlayerAgent * agent ) { - Body_ClearBall().execute( agent ); - agent->setNeckAction( new Neck_ScanField() ); + if (Body_ClearBall().execute( agent )) + { + agent->setNeckAction( new Neck_ScanField() ); + return true; + } + else + { + agent->setNeckAction( new Neck_ScanField() ); + return false; + } } /*-------------------------------------------------------------------*/ /*! */ -void +bool RoleGoalie::doMove( PlayerAgent * agent ) { if ( Bhv_GoalieChaseBall::is_ball_chase_situation( agent ) ) { - Bhv_GoalieChaseBall().execute( agent ); + return Bhv_GoalieChaseBall().execute( agent ); } else { - Bhv_GoalieBasicMove().execute( agent ); + return Bhv_GoalieBasicMove().execute( agent ); } } diff --git a/src/player/role_goalie.h b/src/player/role_goalie.h index 12547244..5f0b3d31 100644 --- a/src/player/role_goalie.h +++ b/src/player/role_goalie.h @@ -66,8 +66,8 @@ class RoleGoalie } public: - void doKick( rcsc::PlayerAgent * agent ); - void doMove( rcsc::PlayerAgent * agent ); + bool doKick( rcsc::PlayerAgent * agent ); + bool doMove( rcsc::PlayerAgent * agent ); }; From 20a09fae270b19e881794f0a71ae06d3fb98314c Mon Sep 17 00:00:00 2001 From: naderzare Date: Tue, 12 Nov 2024 22:46:39 -0400 Subject: [PATCH 2/5] Update ChangeLog for version 1.1.0 with new features and changes --- ChangeLog.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 2cc29e43..b3407e8a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,21 @@ # ChangeLog +## [1.1.0] - 2024-11-12 + +### Added +- + +### Fixed +- + +### Changed +- If the server sends some main actions to the proxy like doForceKick, dash, smartkick, etc, the proxy will just run the first action and ignore the rest of the main actions. + +### Developers +- [NaderZare](https://github.com/naderzare) + +======= + ## [1.0.7] - 2024-11-11 ### Added From 8342c6e3ba4a742ce98dbcdbef8d9c4c83017622 Mon Sep 17 00:00:00 2001 From: SK2iP Date: Sun, 17 Nov 2024 21:10:20 +0330 Subject: [PATCH 3/5] Refactor code structure for improved readability and maintainability --- src/thrift-client/thrift_client_player.cpp | 954 ++++++++++++++++----- 1 file changed, 737 insertions(+), 217 deletions(-) diff --git a/src/thrift-client/thrift_client_player.cpp b/src/thrift-client/thrift_client_player.cpp index 501e9d65..0e645fbc 100644 --- a/src/thrift-client/thrift_client_player.cpp +++ b/src/thrift-client/thrift_client_player.cpp @@ -204,6 +204,8 @@ void ThriftClientPlayer::getActions() { // reset intention agent->setIntention( static_cast< rcsc::SoccerIntention * >( 0 ) ); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": shoot in preprocess done" ); return; } } @@ -212,6 +214,8 @@ void ThriftClientPlayer::getActions() { if ( agent->doIntention() ) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doIntention performed" ); return; } } @@ -220,7 +224,7 @@ void ThriftClientPlayer::getActions() { if(doForceKick(agent)){ rcsc::dlog.addText( rcsc::Logger::TEAM, - __FILE__": doForceKick done" ); + __FILE__": doForceKick performed" ); return; } } @@ -228,7 +232,7 @@ void ThriftClientPlayer::getActions() { if(doHeardPassReceive(agent)){ rcsc::dlog.addText( rcsc::Logger::TEAM, - __FILE__": doHeardPassReceive done" ); + __FILE__": doHeardPassReceive performed" ); return; } } @@ -246,280 +250,610 @@ void ThriftClientPlayer::getActions() if (planner_action_index != -1) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": updateChainByPlannerAction" ); updateChainByPlannerAction(wm, actions.actions[planner_action_index]); } else { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": updateChainByDefault" ); updateChainByDefault(wm); } - std::cout<<"action size:"<doDash(action.dash.power, action.dash.relative_direction); + if (agent->doDash(action.dash.power, action.dash.relative_direction)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doDash performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doDash failed" ); + } } - else if (action.__isset.kick) + else if (action.__isset.kick && !action_performed) { - agent->doKick(action.kick.power, action.kick.relative_direction); + if (agent->doKick(action.kick.power, action.kick.relative_direction)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doKick performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doKick failed" ); + } } - else if (action.__isset.turn) + else if (action.__isset.turn && !action_performed) { - agent->doTurn(action.turn.relative_direction); + if (agent->doTurn(action.turn.relative_direction)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTurn performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTurn failed" ); + } } - else if (action.__isset.tackle) + else if (action.__isset.tackle && !action_performed) { - agent->doTackle(action.tackle.power_or_dir, action.tackle.foul); + if (agent->doTackle(action.tackle.power_or_dir, action.tackle.foul)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTackle performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTackle failed" ); + } } - else if (action.__isset.catch_action) + else if (action.__isset.catch_action && !action_performed) { - agent->doCatch(); + if (agent->doCatch()) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doCatch performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doCatch failed" ); + } } - else if (action.__isset.move) + else if (action.__isset.move && !action_performed) { - agent->doMove(action.move.x, action.move.y); + if (agent->doMove(action.move.x, action.move.y)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doMove performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doMove failed" ); + } } - else if (action.__isset.turn_neck) + else if (action.__isset.turn_neck && !action_performed) { - agent->doTurnNeck(action.turn_neck.moment); + if (agent->doTurnNeck(action.turn_neck.moment)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTurnNeck performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doTurnNeck failed" ); + } } - else if (action.__isset.change_view) + else if (action.__isset.change_view && !action_performed) { const rcsc::ViewWidth view_width = ThriftAgent::convertViewWidth(action.change_view.view_width); - agent->doChangeView(view_width); + if (agent->doChangeView(view_width)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doChangeView performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doChangeView failed" ); + } } - else if (action.__isset.say) + else if (action.__isset.say && !action_performed) { addSayMessage(action.say); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": addSayMessage called" ); } - else if (action.__isset.point_to) + else if (action.__isset.point_to && !action_performed) { - agent->doPointto(action.point_to.x, action.point_to.y); + if (agent->doPointto(action.point_to.x, action.point_to.y)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doPointto performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doPointto failed" ); + } } - else if (action.__isset.point_to_of) + else if (action.__isset.point_to_of && !action_performed) { - agent->doPointtoOff(); + if (agent->doPointtoOff()) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doPointtoOff performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doPointtoOff failed" ); + } } - else if (action.__isset.attention_to) + else if (action.__isset.attention_to && !action_performed) { const rcsc::SideID side = ThriftAgent::convertSideID(action.attention_to.side); - agent->doAttentionto(side, action.attention_to.unum); + if (agent->doAttentionto(side, action.attention_to.unum)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doAttentionto performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__ ": doAttentionto failed" ); + } } - else if (action.__isset.attention_to_of) + else if (action.__isset.attention_to_of && !action_performed) { - agent->doAttentiontoOff(); + if (agent->doAttentiontoOff()) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doAttentiontoOff performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doAttentiontoOff failed" ); + } } else if (action.__isset.log) { addDlog(action.log); } - else if (action.__isset.body_go_to_point) + else if (action.__isset.body_go_to_point && !action_performed) { const auto &bodyGoToPoint = action.body_go_to_point; const auto &targetPoint = ThriftAgent::convertVector2D(bodyGoToPoint.target_point); - Body_GoToPoint(targetPoint, bodyGoToPoint.distance_threshold, bodyGoToPoint.max_dash_power).execute(agent); - agent->debugClient().addMessage("Body_GoToPoint"); + if (Body_GoToPoint(targetPoint, bodyGoToPoint.distance_threshold, bodyGoToPoint.max_dash_power).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_GoToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_GoToPoint failed" ); + } } - else if (action.__isset.body_smart_kick) + else if (action.__isset.body_smart_kick && !action_performed) { const auto &bodySmartKick = action.body_smart_kick; const auto &targetPoint = ThriftAgent::convertVector2D(bodySmartKick.target_point); - Body_SmartKick(targetPoint, bodySmartKick.first_speed, bodySmartKick.first_speed_threshold, - bodySmartKick.max_steps).execute(agent); - agent->debugClient().addMessage("Body_SmartKick"); + if (Body_SmartKick(targetPoint, bodySmartKick.first_speed, bodySmartKick.first_speed_threshold, + bodySmartKick.max_steps).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_SmartKick performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_SmartKick failed" ); + } } - else if (action.__isset.bhv_before_kick_off) + else if (action.__isset.bhv_before_kick_off && !action_performed) { const auto &bhvBeforeKickOff = action.bhv_before_kick_off; const auto &point = ThriftAgent::convertVector2D(bhvBeforeKickOff.point); - Bhv_BeforeKickOff(point).execute(agent); - agent->debugClient().addMessage("Bhv_BeforeKickOff"); + if (Bhv_BeforeKickOff(point).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BeforeKickOff performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BeforeKickOff failed" ); + } } - else if (action.__isset.bhv_body_neck_to_ball) + else if (action.__isset.bhv_body_neck_to_ball && !action_performed) { - Bhv_BodyNeckToBall().execute(agent); - agent->debugClient().addMessage("Bhv_BodyNeckToBall"); + if (Bhv_BodyNeckToBall().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BodyNeckToBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BodyNeckToBall failed" ); + } } - else if (action.__isset.bhv_body_neck_to_point) + else if (action.__isset.bhv_body_neck_to_point && !action_performed) { const auto &bhvBodyNeckToPoint = action.bhv_body_neck_to_point; const auto &targetPoint = ThriftAgent::convertVector2D(bhvBodyNeckToPoint.point); - Bhv_BodyNeckToPoint(targetPoint).execute(agent); - agent->debugClient().addMessage("Bhv_BodyNeckToPoint"); + if (Bhv_BodyNeckToPoint(targetPoint).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BodyNeckToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BodyNeckToPoint failed" ); + } } - else if (action.__isset.bhv_emergency) + else if (action.__isset.bhv_emergency && !action_performed) { - Bhv_Emergency().execute(agent); - agent->debugClient().addMessage("Bhv_Emergency"); + if (Bhv_Emergency().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_Emergency performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_Emergency failed" ); + } } - else if (action.__isset.bhv_go_to_point_look_ball) + else if (action.__isset.bhv_go_to_point_look_ball && !action_performed) { const auto &bhvGoToPointLookBall = action.bhv_go_to_point_look_ball; const auto &targetPoint = ThriftAgent::convertVector2D(bhvGoToPointLookBall.target_point); - Bhv_GoToPointLookBall(targetPoint, bhvGoToPointLookBall.distance_threshold, bhvGoToPointLookBall.max_dash_power).execute(agent); - agent->debugClient().addMessage("Bhv_GoToPointLookBall"); + if (Bhv_GoToPointLookBall(targetPoint, bhvGoToPointLookBall.distance_threshold, bhvGoToPointLookBall.max_dash_power).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_GoToPointLookBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_GoToPointLookBall failed" ); + } } - else if (action.__isset.bhv_neck_body_to_ball) + else if (action.__isset.bhv_neck_body_to_ball && !action_performed) { const auto &bhvNeckBodyToBall = action.bhv_neck_body_to_ball; - Bhv_NeckBodyToBall(bhvNeckBodyToBall.angle_buf).execute(agent); - agent->debugClient().addMessage("Bhv_NeckBodyToBall"); + if (Bhv_NeckBodyToBall(bhvNeckBodyToBall.angle_buf).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_NeckBodyToBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_NeckBodyToBall failed" ); + } } - else if (action.__isset.bhv_neck_body_to_point) + else if (action.__isset.bhv_neck_body_to_point && !action_performed) { const auto &bhvNeckBodyToPoint = action.bhv_neck_body_to_point; const auto &targetPoint = ThriftAgent::convertVector2D(bhvNeckBodyToPoint.point); - Bhv_NeckBodyToPoint(targetPoint, bhvNeckBodyToPoint.angle_buf).execute(agent); - agent->debugClient().addMessage("Bhv_NeckBodyToPoint"); + if (Bhv_NeckBodyToPoint(targetPoint, bhvNeckBodyToPoint.angle_buf).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_NeckBodyToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_NeckBodyToPoint failed" ); + } } - else if (action.__isset.bhv_scan_field) + else if (action.__isset.bhv_scan_field && !action_performed) { - Bhv_ScanField().execute(agent); - agent->debugClient().addMessage("Bhv_ScanField"); + if (Bhv_ScanField().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_ScanField performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_ScanField failed" ); + } } - else if (action.__isset.body_advance_ball) + else if (action.__isset.body_advance_ball && !action_performed) { - Body_AdvanceBall().execute(agent); - agent->debugClient().addMessage("Body_AdvanceBall"); + if (Body_AdvanceBall().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_AdvanceBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_AdvanceBall failed" ); + } } - else if (action.__isset.body_clear_ball) + else if (action.__isset.body_clear_ball && !action_performed) { - Body_ClearBall().execute(agent); - agent->debugClient().addMessage("Body_ClearBall"); + if (Body_ClearBall().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_ClearBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_ClearBall failed" ); + } } - else if (action.__isset.body_dribble) + else if (action.__isset.body_dribble && !action_performed) { const auto &bodyDribble = action.body_dribble; const auto &targetPoint = ThriftAgent::convertVector2D(bodyDribble.target_point); - Body_Dribble( - targetPoint, - bodyDribble.distance_threshold, - bodyDribble.dash_power, - bodyDribble.dash_count, - bodyDribble.dodge) - .execute(agent); - agent->debugClient().addMessage("Body_Dribble"); + if (Body_Dribble(targetPoint, bodyDribble.distance_threshold, bodyDribble.dash_power,bodyDribble.dash_count,bodyDribble.dodge).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_Dribble performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_Dribble failed" ); + } } - else if (action.__isset.body_go_to_point_dodge) + else if (action.__isset.body_go_to_point_dodge && !action_performed) { const auto &bodyGoToPointDodge = action.body_go_to_point_dodge; const auto &targetPoint = ThriftAgent::convertVector2D(bodyGoToPointDodge.target_point); - Body_GoToPointDodge( - targetPoint, - bodyGoToPointDodge.dash_power) - .execute(agent); - agent->debugClient().addMessage("Body_GoToPointDodge"); + if (Body_GoToPointDodge(targetPoint, bodyGoToPointDodge.dash_power).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_GoToPointDodge performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_GoToPointDodge failed" ); + } } - else if (action.__isset.body_hold_ball) + else if (action.__isset.body_hold_ball && !action_performed) { const auto &bodyHoldBall = action.body_hold_ball; const auto &turnTargetPoint = ThriftAgent::convertVector2D(bodyHoldBall.turn_target_point); const auto &kickTargetPoint = ThriftAgent::convertVector2D(bodyHoldBall.kick_target_point); - Body_HoldBall( - bodyHoldBall.do_turn, - turnTargetPoint, - kickTargetPoint) - .execute(agent); - agent->debugClient().addMessage("Body_HoldBall"); + if (Body_HoldBall(bodyHoldBall.do_turn, turnTargetPoint, kickTargetPoint).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_HoldBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_HoldBall failed" ); + } } - else if (action.__isset.body_intercept) + else if (action.__isset.body_intercept && !action_performed) { const auto &bodyIntercept = action.body_intercept; const auto &facePoint = ThriftAgent::convertVector2D(bodyIntercept.face_point); - Body_Intercept( - bodyIntercept.save_recovery, - facePoint) - .execute(agent); - agent->debugClient().addMessage("Body_Intercept"); + if (Body_Intercept(bodyIntercept.save_recovery, facePoint).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_Intercept performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_Intercept failed" ); + } } - else if (action.__isset.body_kick_one_step) + else if (action.__isset.body_kick_one_step && !action_performed) { const auto &bodyKickOneStep = action.body_kick_one_step; const auto &targetPoint = ThriftAgent::convertVector2D(bodyKickOneStep.target_point); - Body_KickOneStep( - targetPoint, - bodyKickOneStep.first_speed, - bodyKickOneStep.force_mode) - .execute(agent); - agent->debugClient().addMessage("Body_KickOneStep"); + if (Body_KickOneStep(targetPoint, bodyKickOneStep.first_speed, bodyKickOneStep.force_mode).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_KickOneStep performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_KickOneStep failed" ); + } } - else if (action.__isset.body_stop_ball) + else if (action.__isset.body_stop_ball && !action_performed) { - Body_StopBall().execute(agent); - agent->debugClient().addMessage("Body_StopBall"); + if (Body_StopBall().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_StopBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_StopBall failed" ); + } } - else if (action.__isset.body_stop_dash) + else if (action.__isset.body_stop_dash && !action_performed) { const auto &bodyStopDash = action.body_stop_dash; - Body_StopDash( - bodyStopDash.save_recovery) - .execute(agent); - agent->debugClient().addMessage("Body_StopDash"); + if (Body_StopDash(bodyStopDash.save_recovery).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_StopDash performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_StopDash failed" ); + } } - else if (action.__isset.body_tackle_to_point) + else if (action.__isset.body_tackle_to_point && !action_performed) { const auto &bodyTackleToPoint = action.body_tackle_to_point; const auto &targetPoint = ThriftAgent::convertVector2D(bodyTackleToPoint.target_point); - Body_TackleToPoint( - targetPoint, - bodyTackleToPoint.min_probability, - bodyTackleToPoint.min_speed) - .execute(agent); - agent->debugClient().addMessage("Body_TackleToPoint"); + if (Body_TackleToPoint(targetPoint, bodyTackleToPoint.min_probability, bodyTackleToPoint.min_speed).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TackleToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TackleToPoint failed" ); + } } - else if (action.__isset.body_turn_to_angle) + else if (action.__isset.body_turn_to_angle && !action_performed) { const auto &bodyTurnToAngle = action.body_turn_to_angle; - Body_TurnToAngle( - bodyTurnToAngle.angle) - .execute(agent); - agent->debugClient().addMessage("Body_TurnToAngle"); + if (Body_TurnToAngle(bodyTurnToAngle.angle).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToAngle performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToAngle failed" ); + } } - else if (action.__isset.body_turn_to_ball) + else if (action.__isset.body_turn_to_ball && !action_performed) { const auto &bodyTurnToBall = action.body_turn_to_ball; - Body_TurnToBall( - bodyTurnToBall.cycle) - .execute(agent); - agent->debugClient().addMessage("Body_TurnToBall"); + if (Body_TurnToBall(bodyTurnToBall.cycle).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToBall failed" ); + } } - else if (action.__isset.body_turn_to_point) + else if (action.__isset.body_turn_to_point && !action_performed) { const auto &bodyTurnToPoint = action.body_turn_to_point; const auto &targetPoint = ThriftAgent::convertVector2D(bodyTurnToPoint.target_point); - Body_TurnToPoint( - targetPoint, - bodyTurnToPoint.cycle) - .execute(agent); - agent->debugClient().addMessage("Body_TurnToPoint"); + if (Body_TurnToPoint(targetPoint, bodyTurnToPoint.cycle).execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Body_TurnToPoint failed" ); + } } + else if (action.__isset.focus_move_to_point) { const auto &focusMoveToPoint = action.focus_move_to_point; const auto &targetPoint = ThriftAgent::convertVector2D(focusMoveToPoint.target_point); - rcsc::Focus_MoveToPoint( - targetPoint) - .execute(agent); - agent->debugClient().addMessage("Focus_MoveToPoint"); + if (rcsc::Focus_MoveToPoint(targetPoint).execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Focus_MoveToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Focus_MoveToPoint failed" ); + } } else if (action.__isset.focus_reset) { - rcsc::Focus_Reset().execute(agent); - agent->debugClient().addMessage("Focus_Reset"); + if (rcsc::Focus_Reset().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Focus_Reset performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Focus_Reset failed" ); + } } else if (action.__isset.neck_scan_field) { - Neck_ScanField().execute(agent); - agent->debugClient().addMessage("Neck_ScanField"); + if (Neck_ScanField().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_ScanField performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_ScanField failed" ); + } } else if (action.__isset.neck_scan_players) { - Neck_ScanPlayers().execute(agent); - agent->debugClient().addMessage("Neck_ScanPlayers"); + if (Neck_ScanPlayers().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_ScanPlayers performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_ScanPlayers failed" ); + } } else if (action.__isset.neck_turn_to_ball_and_player) { @@ -535,44 +869,83 @@ void ThriftClientPlayer::getActions() } if (player != nullptr) { - Neck_TurnToBallAndPlayer( + if (Neck_TurnToBallAndPlayer( player, - neckTurnToBallAndPlayer.count_threshold) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToBallAndPlayer"); + neckTurnToBallAndPlayer.count_threshold).execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToBallAndPlayer performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToBallAndPlayer failed" ); + } } else { - agent->debugClient().addMessage("Neck_TurnToBallAndPlayer null player"); + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToBallAndPlayer failed (no player)" ); } } else if (action.__isset.neck_turn_to_ball_or_scan) { const auto &neckTurnToBallOrScan = action.neck_turn_to_ball_or_scan; - Neck_TurnToBallOrScan( + if (Neck_TurnToBallOrScan( neckTurnToBallOrScan.count_threshold) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToBallOrScan"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToBallOrScan performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToBallOrScan failed" ); + } } else if (action.__isset.neck_turn_to_ball) { - Neck_TurnToBall().execute(agent); - agent->debugClient().addMessage("Neck_TurnToBall"); + if (Neck_TurnToBall().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToBall performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToBall failed" ); + } } else if (action.__isset.neck_turn_to_goalie_or_scan) { const auto &neckTurnToGoalieOrScan = action.neck_turn_to_goalie_or_scan; - Neck_TurnToGoalieOrScan( + if (Neck_TurnToGoalieOrScan( neckTurnToGoalieOrScan.count_threshold) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToGoalieOrScan"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToGoalieOrScan performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToGoalieOrScan failed" ); + } } else if (action.__isset.neck_turn_to_low_conf_teammate) { const auto &neckTurnToLowConfTeammate = action.neck_turn_to_low_conf_teammate; - Neck_TurnToLowConfTeammate().execute(agent); - agent->debugClient().addMessage("Neck_TurnToLowConfTeammate"); + if (Neck_TurnToLowConfTeammate().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToLowConfTeammate performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToLowConfTeammate failed" ); + } } else if (action.__isset.neck_turn_to_player_or_scan) { @@ -588,150 +961,296 @@ void ThriftClientPlayer::getActions() } if (player != nullptr) { - Neck_TurnToPlayerOrScan( + if (Neck_TurnToPlayerOrScan( player, neckTurnToPlayerOrScan.count_threshold) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToPlayerOrScan"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToPlayerOrScan performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToPlayerOrScan failed" ); + } } else { - agent->debugClient().addMessage("Neck_TurnToPlayerOrScan null player"); + rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Neck_TurnToPlayerOrScan failed (no player)" ); } } else if (action.__isset.neck_turn_to_point) { const auto &neckTurnToPoint = action.neck_turn_to_point; const auto &targetPoint = ThriftAgent::convertVector2D(neckTurnToPoint.target_point); - Neck_TurnToPoint( + if (Neck_TurnToPoint( targetPoint) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToPoint"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToPoint performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToPoint failed" ); + } } else if (action.__isset.neck_turn_to_relative) { const auto &neckTurnToRelative = action.neck_turn_to_relative; - Neck_TurnToRelative( + if (Neck_TurnToRelative( neckTurnToRelative.angle) - .execute(agent); - agent->debugClient().addMessage("Neck_TurnToRelative"); + .execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToRelative performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Neck_TurnToRelative failed" ); + } } else if (action.__isset.view_change_width) { const auto &viewChangeWidth = action.view_change_width; const rcsc::ViewWidth view_width = ThriftAgent::convertViewWidth(viewChangeWidth.view_width); - View_ChangeWidth( - view_width) - .execute(agent); - agent->debugClient().addMessage("View_ChangeWidth"); + if (View_ChangeWidth(view_width).execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": View_ChangeWidth performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": View_ChangeWidth failed" ); + } } else if (action.__isset.view_normal) { - View_Normal().execute(agent); - agent->debugClient().addMessage("View_Normal"); + if(View_Normal().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": View_Normal performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": View_Normal failed" ); + } } else if (action.__isset.view_wide) { - View_Wide().execute(agent); - agent->debugClient().addMessage("View_Wide"); + if(View_Wide().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": View_Wide performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": View_Wide failed" ); + } } else if (action.__isset.view_synch) { - View_Synch().execute(agent); - agent->debugClient().addMessage("View_Synch"); + if(View_Synch().execute(agent)) + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": View_Synch performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": View_Synch failed" ); + } } - else if (action.__isset.helios_goalie) + else if (action.__isset.helios_goalie && !action_performed) { RoleGoalie roleGoalie = RoleGoalie(); - roleGoalie.execute(agent); - agent->debugClient().addMessage("RoleGoalie - execute"); + if(roleGoalie.execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie failed" ); + } } - else if (action.__isset.helios_goalie_move) + else if (action.__isset.helios_goalie_move && !action_performed) { RoleGoalie roleGoalie = RoleGoalie(); - roleGoalie.doMove(agent); - agent->debugClient().addMessage("RoleGoalie - do Move"); + if(roleGoalie.doMove(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie doMove performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie doMove failed" ); + } } - else if (action.__isset.helios_goalie_kick) + else if (action.__isset.helios_goalie_kick && !action_performed) { RoleGoalie roleGoalie = RoleGoalie(); - roleGoalie.doKick(agent); - agent->debugClient().addMessage("RoleGoalie - do Kick"); + if (roleGoalie.doKick(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie doKick performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": RoleGoalie doKick failed" ); + } } - else if (action.__isset.helios_shoot) + else if (action.__isset.helios_shoot && !action_performed) { const rcsc::WorldModel &wm = agent->world(); if (wm.gameMode().type() != rcsc::GameMode::IndFreeKick_ && wm.time().stopped() == 0 && wm.self().isKickable() && Bhv_StrictCheckShoot().execute(agent)) { - agent->debugClient().addMessage("Bhv_StrictCheckShoot"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_StrictCheckShoot performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_StrictCheckShoot failed" ); } - } - else if (action.__isset.helios_basic_move) + else if (action.__isset.helios_basic_move && !action_performed) { - Bhv_BasicMove().execute(agent); - agent->debugClient().addMessage("Bhv_BasicMove"); + if(Bhv_BasicMove().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BasicMove performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_BasicMove failed" ); + } } - else if (action.__isset.helios_set_play) + else if (action.__isset.helios_set_play && !action_performed) { - Bhv_SetPlay().execute(agent); - agent->debugClient().addMessage("Bhv_SetPlay"); + if(Bhv_SetPlay().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_SetPlay performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_SetPlay failed" ); + } } - else if (action.__isset.helios_penalty) + else if (action.__isset.helios_penalty && !action_performed) { - Bhv_PenaltyKick().execute(agent); - agent->debugClient().addMessage("Bhv_PenaltyKick"); + if(Bhv_PenaltyKick().execute(agent)) + { + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PenaltyKick performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PenaltyKick failed" ); + } } else if (action.__isset.helios_communication) { - sample_communication->execute(agent); - agent->debugClient().addMessage("sample_communication - execute"); + if (sample_communication->execute(agent)) { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": sample_communication performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": sample_communication failed" ); + } } - else if (action.__isset.bhv_do_force_kick) + else if (action.__isset.bhv_do_force_kick && !action_performed) { - if (doForceKick(agent)) + if(doForceKick(agent)) { - agent->debugClient().addMessage("doForceKick"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doForceKick performed" ); } - else + else { - agent->debugClient().addMessage("doForceKick - false"); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doForceKick failed" ); } } - else if (action.__isset.bhv_do_heard_pass_recieve) + else if (action.__isset.bhv_do_heard_pass_recieve && !action_performed) { - if (doHeardPassReceive(agent)) + if(doHeardPassReceive(agent)) { - agent->debugClient().addMessage("doHeardPassReceive"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doHeardPassReceive performed" ); } - else + else { - agent->debugClient().addMessage("doHeardPassReceive - false"); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": doHeardPassReceive failed" ); } } - else if (action.__isset.helios_offensive_planner) + else if (action.__isset.helios_offensive_planner && !action_performed) { if (action.helios_offensive_planner.server_side_decision) { if (GetBestPlannerAction()) { - agent->debugClient().addMessage("GetBestPlannerAction"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": GetBestPlannerAction performed" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": GetBestPlannerAction failed" ); } } else { if (Bhv_PlannedAction().execute(agent)) { - agent->debugClient().addMessage("PlannedAction"); + action_performed = true; + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PlannedAction performed" ); } else { - Body_HoldBall().execute(agent); - agent->setNeckAction(new Neck_ScanField()); + if (Body_HoldBall().execute(agent)) + { + action_performed = true; + agent->setNeckAction(new Neck_ScanField()); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PlannedAction failed (Hold Ball performed)" ); + } + else + { + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Bhv_PlannedAction failed (Hold Ball Failed)" ); + } } } } @@ -740,8 +1259,9 @@ void ThriftClientPlayer::getActions() #ifdef DEBUG_CLIENT_PLAYER std::cout << "Unkown action"<setNeckAction(new Neck_ScanField()); + + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": Unkown action or another main action performed"); } } } From d7700e7d661987182e1dc1a7211eed7013f85049 Mon Sep 17 00:00:00 2001 From: SK2iP Date: Sun, 17 Nov 2024 21:52:30 +0330 Subject: [PATCH 4/5] change action_performed problem --- src/grpc-client/grpc_client_player.cpp | 1 + src/thrift-client/thrift_client_player.cpp | 25 +++++++++------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/grpc-client/grpc_client_player.cpp b/src/grpc-client/grpc_client_player.cpp index 460bc021..cc466183 100644 --- a/src/grpc-client/grpc_client_player.cpp +++ b/src/grpc-client/grpc_client_player.cpp @@ -600,6 +600,7 @@ void GrpcClientPlayer::getActions() const auto &bhvNeckBodyToBall = action.bhv_neck_body_to_ball(); if (Bhv_NeckBodyToBall(bhvNeckBodyToBall.angle_buf()).execute(agent)) { + action_performed = true; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Bhv_NeckBodyToBall performed" ); } diff --git a/src/thrift-client/thrift_client_player.cpp b/src/thrift-client/thrift_client_player.cpp index 0e645fbc..9dcdb313 100644 --- a/src/thrift-client/thrift_client_player.cpp +++ b/src/thrift-client/thrift_client_player.cpp @@ -350,11 +350,10 @@ void ThriftClientPlayer::getActions() __FILE__": doMove failed" ); } } - else if (action.__isset.turn_neck && !action_performed) + else if (action.__isset.turn_neck) { if (agent->doTurnNeck(action.turn_neck.moment)) { - action_performed = true; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": doTurnNeck performed" ); } @@ -364,12 +363,11 @@ void ThriftClientPlayer::getActions() __FILE__": doTurnNeck failed" ); } } - else if (action.__isset.change_view && !action_performed) + else if (action.__isset.change_view) { const rcsc::ViewWidth view_width = ThriftAgent::convertViewWidth(action.change_view.view_width); if (agent->doChangeView(view_width)) { - action_performed = true; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": doChangeView performed" ); } @@ -379,17 +377,16 @@ void ThriftClientPlayer::getActions() __FILE__": doChangeView failed" ); } } - else if (action.__isset.say && !action_performed) + else if (action.__isset.say) { addSayMessage(action.say); rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": addSayMessage called" ); } - else if (action.__isset.point_to && !action_performed) + else if (action.__isset.point_to) { if (agent->doPointto(action.point_to.x, action.point_to.y)) { - action_performed = true; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": doPointto performed" ); } @@ -399,11 +396,10 @@ void ThriftClientPlayer::getActions() __FILE__": doPointto failed" ); } } - else if (action.__isset.point_to_of && !action_performed) + else if (action.__isset.point_to_of) { if (agent->doPointtoOff()) { - action_performed = true; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": doPointtoOff performed" ); } @@ -413,12 +409,11 @@ void ThriftClientPlayer::getActions() __FILE__": doPointtoOff failed" ); } } - else if (action.__isset.attention_to && !action_performed) + else if (action.__isset.attention_to) { const rcsc::SideID side = ThriftAgent::convertSideID(action.attention_to.side); if (agent->doAttentionto(side, action.attention_to.unum)) { - action_performed = true; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": doAttentionto performed" ); } @@ -428,11 +423,10 @@ void ThriftClientPlayer::getActions() __FILE__ ": doAttentionto failed" ); } } - else if (action.__isset.attention_to_of && !action_performed) + else if (action.__isset.attention_to_of) { if (agent->doAttentiontoOff()) { - action_performed = true; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": doAttentiontoOff performed" ); } @@ -445,6 +439,8 @@ void ThriftClientPlayer::getActions() else if (action.__isset.log) { addDlog(action.log); + rcsc::dlog.addText( rcsc::Logger::TEAM, + __FILE__": addDlog called" ); } else if (action.__isset.body_go_to_point && !action_performed) { @@ -525,11 +521,10 @@ void ThriftClientPlayer::getActions() __FILE__": Bhv_BodyNeckToPoint failed" ); } } - else if (action.__isset.bhv_emergency && !action_performed) + else if (action.__isset.bhv_emergency) { if (Bhv_Emergency().execute(agent)) { - action_performed = true; rcsc::dlog.addText( rcsc::Logger::TEAM, __FILE__": Bhv_Emergency performed" ); } From c68893b729c20d67453d2ee568acac64f5adf91d Mon Sep 17 00:00:00 2001 From: Nader Zare Date: Sun, 17 Nov 2024 14:33:47 -0400 Subject: [PATCH 5/5] Update ChangeLog.md --- ChangeLog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index b3407e8a..04f4dfcd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,6 @@ # ChangeLog -## [1.1.0] - 2024-11-12 +## [1.1.0] - 2024-11-17 ### Added - @@ -13,6 +13,7 @@ ### Developers - [NaderZare](https://github.com/naderzare) +- [Sadra Khanjari](https://github.com/sk2ip) =======