Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed thirds, added communication-based heuristic for seeking #2226

Merged
merged 6 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions rj_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,24 @@ rosidl_generate_interfaces(
msg/AgentResponseVariant.msg

# Agent Request Messages
request/ResetScorerRequest.msg
request/PositionRequest.msg
request/LeaveWallRequest.msg
request/PassRequest.msg
request/SeekerRequest.msg
request/TestRequest.msg
request/BallInTransitRequest.msg
request/JoinWallRequest.msg
request/ScorerRequest.msg
request/IncomingBallRequest.msg
request/PassRequest.msg
request/LeaveWallRequest.msg
request/JoinWallRequest.msg
request/ResetScorerRequest.msg
request/PositionRequest.msg

# Agent Response Messages
response/LeaveWallResponse.msg
response/Acknowledge.msg
response/PassResponse.msg
response/ScorerResponse.msg
response/JoinWallResponse.msg
response/Acknowledge.msg
response/PositionResponse.msg
response/ScorerResponse.msg
response/PassResponse.msg
response/TestResponse.msg

# Services
Expand Down
11 changes: 6 additions & 5 deletions rj_msgs/msg/AgentRequest.msg
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
# 2 -> PositionResponse
# 3 -> PassResponse
# ACKNOWLEDGE REQUEST DOES NOT (AND SHOULD NOT) EXIST
ResetScorerRequest[<=1] reset_scorer_request
PositionRequest[<=1] position_request
LeaveWallRequest[<=1] leave_wall_request
PassRequest[<=1] pass_request
SeekerRequest[<=1] seeker_request
TestRequest[<=1] test_request
BallInTransitRequest[<=1] ball_in_transit_request
JoinWallRequest[<=1] join_wall_request
ScorerRequest[<=1] scorer_request
IncomingBallRequest[<=1] incoming_ball_request
PassRequest[<=1] pass_request
LeaveWallRequest[<=1] leave_wall_request
JoinWallRequest[<=1] join_wall_request
ResetScorerRequest[<=1] reset_scorer_request
PositionRequest[<=1] position_request
6 changes: 3 additions & 3 deletions rj_msgs/msg/AgentResponseVariant.msg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
LeaveWallResponse[<=1] leave_wall_response
Acknowledge[<=1] acknowledge
PassResponse[<=1] pass_response
ScorerResponse[<=1] scorer_response
JoinWallResponse[<=1] join_wall_response
Acknowledge[<=1] acknowledge
PositionResponse[<=1] position_response
ScorerResponse[<=1] scorer_response
PassResponse[<=1] pass_response
TestResponse[<=1] test_response
9 changes: 9 additions & 0 deletions rj_msgs/request/SeekerRequest.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# /**
# * @brief request sent by an agent to one or many agents indicating
# * that it would like to seek
# */
uint32 request_uid
uint8 robot_id
float64 seeking_point_x
float64 seeking_point_y
bool adding
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <rj_common/time.hpp>
#include <rj_convert/ros_convert.hpp>

#include "rj_msgs/msg/acknowledge.hpp"

namespace strategy::communication {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <rj_common/time.hpp>
#include <rj_convert/ros_convert.hpp>

#include "rj_msgs/msg/ball_in_transit_request.hpp"

namespace strategy::communication {
Expand Down
55 changes: 33 additions & 22 deletions soccer/src/soccer/strategy/agent/communication/communication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ u_int32_t request_uid = 0;
std::mutex response_uid_mutex;
u_int32_t response_uid = 0;

bool operator==(const ResetScorerRequest& a, const ResetScorerRequest& b) {
bool operator==(const LeaveWallRequest& a, const LeaveWallRequest& b) {
return a.request_uid == b.request_uid;
}

bool operator==(const PositionRequest& a, const PositionRequest& b) {
bool operator==(const PassRequest& a, const PassRequest& b) {
return a.request_uid == b.request_uid;
}

bool operator==(const SeekerRequest& a, const SeekerRequest& b) {
return a.request_uid == b.request_uid;
}

Expand All @@ -24,47 +28,47 @@ bool operator==(const BallInTransitRequest& a, const BallInTransitRequest& b) {
return a.request_uid == b.request_uid;
}

bool operator==(const ScorerRequest& a, const ScorerRequest& b) {
bool operator==(const JoinWallRequest& a, const JoinWallRequest& b) {
return a.request_uid == b.request_uid;
}

bool operator==(const IncomingBallRequest& a, const IncomingBallRequest& b) {
bool operator==(const ScorerRequest& a, const ScorerRequest& b) {
return a.request_uid == b.request_uid;
}

bool operator==(const PassRequest& a, const PassRequest& b) {
bool operator==(const IncomingBallRequest& a, const IncomingBallRequest& b) {
return a.request_uid == b.request_uid;
}

bool operator==(const LeaveWallRequest& a, const LeaveWallRequest& b) {
bool operator==(const ResetScorerRequest& a, const ResetScorerRequest& b) {
return a.request_uid == b.request_uid;
}

bool operator==(const JoinWallRequest& a, const JoinWallRequest& b) {
bool operator==(const PositionRequest& a, const PositionRequest& b) {
return a.request_uid == b.request_uid;
}

bool operator==(const LeaveWallResponse& a, const LeaveWallResponse& b) {
return a.response_uid == b.response_uid;
}

bool operator==(const Acknowledge& a, const Acknowledge& b) {
bool operator==(const ScorerResponse& a, const ScorerResponse& b) {
return a.response_uid == b.response_uid;
}

bool operator==(const PassResponse& a, const PassResponse& b) {
bool operator==(const JoinWallResponse& a, const JoinWallResponse& b) {
return a.response_uid == b.response_uid;
}

bool operator==(const JoinWallResponse& a, const JoinWallResponse& b) {
bool operator==(const Acknowledge& a, const Acknowledge& b) {
return a.response_uid == b.response_uid;
}

bool operator==(const PositionResponse& a, const PositionResponse& b) {
return a.response_uid == b.response_uid;
}

bool operator==(const ScorerResponse& a, const ScorerResponse& b) {
bool operator==(const PassResponse& a, const PassResponse& b) {
return a.response_uid == b.response_uid;
}

Expand All @@ -76,14 +80,21 @@ bool operator==(const AgentResponse& a, const AgentResponse& b) {
return (a.associated_request == b.associated_request) && (a.response == b.response);
}

void generate_uid(ResetScorerRequest& request) {
void generate_uid(LeaveWallRequest& request) {
request_uid_mutex.lock();
request.request_uid = request_uid;
request_uid++;
request_uid_mutex.unlock();
}

void generate_uid(PositionRequest& request) {
void generate_uid(PassRequest& request) {
request_uid_mutex.lock();
request.request_uid = request_uid;
request_uid++;
request_uid_mutex.unlock();
}

void generate_uid(SeekerRequest& request) {
request_uid_mutex.lock();
request.request_uid = request_uid;
request_uid++;
Expand All @@ -104,35 +115,35 @@ void generate_uid(BallInTransitRequest& request) {
request_uid_mutex.unlock();
}

void generate_uid(ScorerRequest& request) {
void generate_uid(JoinWallRequest& request) {
request_uid_mutex.lock();
request.request_uid = request_uid;
request_uid++;
request_uid_mutex.unlock();
}

void generate_uid(IncomingBallRequest& request) {
void generate_uid(ScorerRequest& request) {
request_uid_mutex.lock();
request.request_uid = request_uid;
request_uid++;
request_uid_mutex.unlock();
}

void generate_uid(PassRequest& request) {
void generate_uid(IncomingBallRequest& request) {
request_uid_mutex.lock();
request.request_uid = request_uid;
request_uid++;
request_uid_mutex.unlock();
}

void generate_uid(LeaveWallRequest& request) {
void generate_uid(ResetScorerRequest& request) {
request_uid_mutex.lock();
request.request_uid = request_uid;
request_uid++;
request_uid_mutex.unlock();
}

void generate_uid(JoinWallRequest& request) {
void generate_uid(PositionRequest& request) {
request_uid_mutex.lock();
request.request_uid = request_uid;
request_uid++;
Expand All @@ -146,21 +157,21 @@ void generate_uid(LeaveWallResponse& response) {
response_uid_mutex.unlock();
}

void generate_uid(Acknowledge& response) {
void generate_uid(ScorerResponse& response) {
response_uid_mutex.lock();
response.response_uid = response_uid;
response_uid++;
response_uid_mutex.unlock();
}

void generate_uid(PassResponse& response) {
void generate_uid(JoinWallResponse& response) {
response_uid_mutex.lock();
response.response_uid = response_uid;
response_uid++;
response_uid_mutex.unlock();
}

void generate_uid(JoinWallResponse& response) {
void generate_uid(Acknowledge& response) {
response_uid_mutex.lock();
response.response_uid = response_uid;
response_uid++;
Expand All @@ -174,7 +185,7 @@ void generate_uid(PositionResponse& response) {
response_uid_mutex.unlock();
}

void generate_uid(ScorerResponse& response) {
void generate_uid(PassResponse& response) {
response_uid_mutex.lock();
response.response_uid = response_uid;
response_uid++;
Expand Down
Loading
Loading