Skip to content

Commit dd5a402

Browse files
committed
Add client handles implementation
2 parents 498f016 + 5f393e5 commit dd5a402

File tree

11 files changed

+127
-148
lines changed

11 files changed

+127
-148
lines changed

.github/workflows/remove-stale-branches.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Preview stale branches
2222
uses: fpicalausa/remove-stale-branches@v2.4.0
2323
with:
24-
dry-run: true
24+
dry-run: false
2525
# curr threshold is >= 2 years
2626
days-before-branch-stale: 730
2727
days-before-branch-delete: 2

docs/source/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ or virtual machine running Ubuntu 22.04, and the second is to use Docker.
77
.. Note::
88
If you elect to use Docker, you need to ensure your system has sufficient
99
memory as Docker is not the greatest with RAM management. In particular, it's
10-
recommended that you have at least 16 GB of RAM allocated.
10+
recommended that you have at least 8 GB of RAM allocated.
1111

1212

1313
Native/Virtual Machine Setup

docs/source/tutorial.rst

Lines changed: 80 additions & 109 deletions
Large diffs are not rendered by default.

install/setup.bash

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ _colcon_prefix_chain_bash_source_script() {
1717
fi
1818
}
1919

20+
# source chained prefixes
21+
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
22+
COLCON_CURRENT_PREFIX="/opt/ros/humble"
23+
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash"
24+
2025
# source this prefix
2126
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
2227
COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)"

install/setup.zsh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ _colcon_prefix_chain_zsh_source_script() {
1717
fi
1818
}
1919

20+
# source chained prefixes
21+
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
22+
COLCON_CURRENT_PREFIX="/opt/ros/humble"
23+
_colcon_prefix_chain_zsh_source_script "$COLCON_CURRENT_PREFIX/local_setup.zsh"
24+
2025
# source this prefix
2126
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
2227
COLCON_CURRENT_PREFIX="$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && pwd)"

makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ coverage:
160160
--gcov-options '\-lp'
161161

162162
clean:
163-
((rm build-debug -rf); (rm build-release -rf); (rm build-release-debug -rf)) || true
163+
rm -rf build install log
164164
git clean -f -X -d cmake-*
165-
rm -rf install/bin install/lib install/share install/include
166165

167166
static-analysis:
168167
mkdir -p build/static-analysis

src/rj_strategy/include/rj_strategy/agent/position.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class AgentActionClient;
5050
namespace strategy {
5151

5252
struct ClientHandles {
53-
std::unique_ptr<KickerPickerClient> kickerPickerClient;
54-
std::unique_ptr<MarkingClient> markingClient;
53+
std::unique_ptr<KickerPickerClient> kicker_picker;
54+
std::unique_ptr<MarkingClient> marking;
5555
};
5656

5757
/*
@@ -238,7 +238,9 @@ class Position {
238238
*/
239239
virtual void set_goalie_id(int goalie_id);
240240

241-
// Allow external code (e.g., RobotFactoryPosition) to inject shared client handles
241+
/**
242+
* @brief allows RobotFactoryPosition to synchronize with its client handles
243+
*/
242244
void set_client_handles(std::shared_ptr<ClientHandles> client_handles);
243245

244246
protected:

src/rj_strategy/include/rj_strategy/agent/position/robot_factory_position.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "rj_strategy/agent/position/smartidling.hpp"
3333
#include "rj_strategy/agent/position/solo_offense.hpp"
3434
#include "rj_strategy/agent/position/zoner.hpp"
35-
#include "rj_strategy/coordinator/kicker_picker_client.hpp"
3635

3736
namespace strategy {
3837

src/rj_strategy/src/agent/position.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace strategy {
44

5-
Position::Position(int r_id)
6-
: robot_id_(r_id), client_handles_(std::make_shared<ClientHandles>()) {}
5+
Position::Position(int r_id) : robot_id_(r_id) {
6+
client_handles_ = std::make_shared<ClientHandles>();
7+
}
78

89
Position::Position(int r_id, std::string position_name)
9-
: position_name_{std::move(position_name)},
10-
robot_id_{r_id},
11-
client_handles_(std::make_shared<ClientHandles>()){};
10+
: position_name_{std::move(position_name)}, robot_id_{r_id} {
11+
client_handles_ = std::make_shared<ClientHandles>();
12+
};
1213

1314
std::optional<RobotIntent> Position::get_task(WorldState& world_state,
1415
FieldDimensions& field_dimensions,
@@ -39,10 +40,6 @@ void Position::set_goal_canceled() { goal_canceled_ = true; }
3940

4041
void Position::set_goalie_id(int goalie_id) { goalie_id_ = goalie_id; }
4142

42-
void Position::set_client_handles(std::shared_ptr<ClientHandles> client_handles) {
43-
client_handles_ = std::move(client_handles);
44-
}
45-
4643
bool Position::check_is_done() {
4744
if (is_done_) {
4845
is_done_ = false;
@@ -85,6 +82,10 @@ bool Position::assert_world_state_valid() {
8582
return true;
8683
}
8784

85+
void Position::set_client_handles(std::shared_ptr<ClientHandles> client_handles) {
86+
client_handles_ = client_handles;
87+
}
88+
8889
std::deque<communication::PosAgentRequestWrapper> Position::send_communication_request() {
8990
// Return and reset this member
9091
return std::exchange(communication_requests_, {});

src/rj_strategy/src/agent/position/defense.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Defense::State Defense::update_state() {
3636
return IDLING;
3737
}
3838

39-
if (client_handles_->markingClient->am_i_member() &&
40-
client_handles_->markingClient->am_i_marking()) {
39+
if (client_handles_->marking->am_i_member() &&
40+
client_handles_->marking->am_i_marking()) {
4141
return MARKING;
4242
} else {
4343
return IDLING;
@@ -98,8 +98,8 @@ Defense::State Defense::update_state() {
9898
}
9999
break;
100100
case MARKING:
101-
if (!client_handles_->markingClient->am_i_member() ||
102-
!client_handles_->markingClient->am_i_marking()) {
101+
if (!client_handles_->marking->am_i_member() ||
102+
!client_handles_->marking->am_i_marking()) {
103103
next_state = IDLING;
104104
}
105105
break;
@@ -110,7 +110,7 @@ Defense::State Defense::update_state() {
110110
sent_join_marking_group_request_ = true;
111111
request_time_ = RJ::now();
112112

113-
client_handles_->markingClient->join_group(
113+
client_handles_->marking->join_group(
114114
[this](const bool is_member) {
115115
if (is_member) {
116116
pending_marking_state_ = true;
@@ -122,7 +122,7 @@ Defense::State Defense::update_state() {
122122
// reset flag
123123
sent_join_marking_group_request_ = false;
124124
// ensure not in coordinator group
125-
client_handles_->markingClient->leave_group();
125+
client_handles_->marking->leave_group();
126126
SPDLOG_INFO("Robot {}: Timeout on join group, IDLING now", robot_id_);
127127
next_state = IDLING;
128128
}
@@ -200,7 +200,7 @@ std::optional<RobotIntent> Defense::state_to_task(RobotIntent intent) {
200200
return intent;
201201
} else if (current_state_ == MARKING) {
202202
rj_geometry::Point targetPoint =
203-
last_world_state_->get_robot(false, client_handles_->markingClient->who_am_i_marking())
203+
last_world_state_->get_robot(false, client_handles_->marking->who_am_i_marking())
204204
.pose.position();
205205

206206
rj_geometry::Point ballPoint = last_world_state_->ball.position;

0 commit comments

Comments
 (0)