Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8b1aa38
first steps
shourikb Apr 21, 2025
ef5bc01
added required messages for marking
shourikb Apr 21, 2025
74e7956
more setup
shourikb Apr 21, 2025
a5487ae
fixed some stuff
shourikb Apr 21, 2025
dfe621e
added a dangerous score array to keep track of valid targets
shourikb Apr 21, 2025
01e4436
made some progress
shourikb Apr 22, 2025
6301a5b
danger score calcs
Squid5678 Apr 26, 2025
c85f542
more marking stuff
Squid5678 Apr 26, 2025
e83d402
update naming
Squid5678 Apr 26, 2025
b501fe6
can leave marking
Squid5678 Apr 26, 2025
ded69ac
fixed linker error
Squid5678 Apr 26, 2025
20b41d0
started client
Squid5678 Apr 26, 2025
787f99b
marking client should be done
Squid5678 Apr 26, 2025
32f8860
started on danger score calculation
petergarud Apr 27, 2025
64ef7d4
marking coordaintor should be done'
petergarud Apr 28, 2025
15f1b61
Struct of coordinators: compiles but fails to run at all
petergarud Apr 30, 2025
267f9bd
Fix issue with not running
petergarud Sep 1, 2025
30e54f6
starting implementing coordaintor with defense
petergarud Sep 1, 2025
86e538a
added some more stuff to implement marking into the defense state mac…
shourikb Sep 3, 2025
c740b5e
some debugging done. marks now, but sim crashes
shourikb Sep 3, 2025
68ce933
stuff
petergarud Sep 8, 2025
245cfd4
fixed it so it compiles
shourikb Sep 14, 2025
1d6c90d
Stuff
petergarud Sep 15, 2025
a6c207a
rebase to ros2 to have colcon
sanatd33 Sep 29, 2025
b653fd7
stuff
petergarud Oct 13, 2025
5477bf5
New danger score parameters
petergarud Oct 26, 2025
e2b8c4e
Merge from ros2
petergarud Oct 26, 2025
f070f8a
Danger angle change
petergarud Oct 27, 2025
2f1354a
doesn't mark the guy with the ball anymore
shourikb Oct 29, 2025
ac18cc7
completed marking coordinator
shourikb Oct 29, 2025
a53480b
cleaned up a little
shourikb Oct 29, 2025
3914d60
Fix Code Style On marking-coordinator (#2447)
github-actions[bot] Nov 3, 2025
3073ef6
Resolve merge comments
petergarud Nov 3, 2025
9207a0c
Resolve comments
petergarud Nov 10, 2025
d916b5a
Fix Code Style On marking-coordinator (#2452)
github-actions[bot] Nov 10, 2025
8de5768
fix client handles
sanatd33 Nov 12, 2025
0ce1e25
Fix Code Style On marking-coordinator (#2454)
github-actions[bot] Nov 12, 2025
e79fb8e
addressed most comments but still missing some callback stuff (check …
shourikb Nov 12, 2025
1fc4831
Fix Code Style On marking-coordinator (#2457)
github-actions[bot] Nov 16, 2025
22d0b1b
fixed some more comments
shourikb Nov 19, 2025
88daaec
Merge branch 'marking-coordinator' of https://github.com/RoboJackets/…
shourikb Nov 19, 2025
7b1c468
More fixes
shourikb Nov 19, 2025
498f016
addressed all comments
shourikb Nov 24, 2025
dd5a402
Add client handles implementation
petergarud Nov 24, 2025
5e2cc4d
Fix Code Style On marking-coordinator (#2472)
github-actions[bot] Nov 24, 2025
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
2 changes: 1 addition & 1 deletion install/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash"

unset COLCON_CURRENT_PREFIX
unset _colcon_prefix_chain_bash_source_script
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove these changes from the commit (same for install/setup.zsh)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think anything got changed here. Looks like just removed then added the line back.

unset _colcon_prefix_chain_bash_source_script
2 changes: 1 addition & 1 deletion install/setup.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ COLCON_CURRENT_PREFIX="$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && p
_colcon_prefix_chain_zsh_source_script "$COLCON_CURRENT_PREFIX/local_setup.zsh"

unset COLCON_CURRENT_PREFIX
unset _colcon_prefix_chain_zsh_source_script
unset _colcon_prefix_chain_zsh_source_script
7 changes: 7 additions & 0 deletions launch/soccer.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ def generate_launch_description():
output="screen",
parameters=[param_config_filepath],
on_exit=Shutdown(),
),
Node(
package="rj_strategy",
executable="marking_node",
output="screen",
parameters=[param_config_filepath],
on_exit=Shutdown(),
)
]
)
1 change: 1 addition & 0 deletions src/rj_constants/include/rj_constants/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/// all weights in kilograms

// Number of identifiable robots on one team
// IF U CHANGE THIS NUMBER CHECK Marking.msg
inline constexpr size_t kNumShells = 16;

// Number of playing robots on one team
Expand Down
2 changes: 2 additions & 0 deletions src/rj_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ rosidl_generate_interfaces(

# Coordinators
msg/KickerPicker.msg
msg/Marking.msg

# Agent Request Messages
request/JoinWallRequest.msg
Expand All @@ -84,6 +85,7 @@ rosidl_generate_interfaces(
# Services
srv/AgentCommunication.srv
srv/KickerPicker.srv
srv/Marking.srv
srv/ListJoysticks.srv
srv/PlanHypotheticalPath.srv
srv/QuickCommands.srv
Expand Down
2 changes: 2 additions & 0 deletions src/rj_msgs/msg/Marking.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This is a message to pick a robot to mark
uint8[16] mark_robot_ids # ID of the robot to mark on the opposing team
5 changes: 5 additions & 0 deletions src/rj_msgs/srv/Marking.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Request a robot to be added to or removed from the marking group
uint8 robot_id # ID of the robot (0 to kNumShells-1)
bool join
---
bool success # Always true
21 changes: 19 additions & 2 deletions src/rj_strategy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ set(RJ_STRATEGY_SRC
src/agent/position/goalie.cpp
src/agent/position/idle.cpp
src/agent/position/line.cpp
src/agent/position/marker.cpp
src/agent/position/offense.cpp
src/agent/position/penalty_non_kicker.cpp
src/agent/position/penalty_player.cpp
Expand All @@ -64,6 +63,7 @@ set(RJ_STRATEGY_SRC

# Coordinators
src/coordinator/kicker_picker_client.cpp
src/coordinator/marking_client.cpp
)

# rj_strategy library
Expand Down Expand Up @@ -115,6 +115,23 @@ ament_target_dependencies(kicker_picker_node
${RJ_STRATEGY_DEPS}
)

# Marking Node
add_executable(marking_node
${RJ_STRATEGY_SRC}
src/coordinator/marking_client.cpp
src/coordinator/marking.cpp
)

target_include_directories(marking_node
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

ament_target_dependencies(marking_node
${RJ_STRATEGY_DEPS}
)

# Agent Action Clients
add_executable(agent_action_clients
${RJ_STRATEGY_SRC}
Expand Down Expand Up @@ -146,7 +163,7 @@ install(
)

install(
TARGETS straight_line_test_node kicker_picker_node agent_action_clients
TARGETS straight_line_test_node kicker_picker_node marking_node agent_action_clients
DESTINATION lib/${PROJECT_NAME}
)

Expand Down
9 changes: 5 additions & 4 deletions src/rj_strategy/include/rj_strategy/agent/position.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@

// Coordinators
#include "rj_strategy/coordinator/kicker_picker_client.hpp"
#include "rj_strategy/coordinator/marking_client.hpp"

// tell compiler this class exists, but no need to import the whole header
class AgentActionClient;

namespace strategy {

// Client Handles for coordinators
struct ClientHandles {
std::unique_ptr<KickerPickerClient> kicker_picker;
std::unique_ptr<MarkingClient> marking;
};

/*
Expand Down Expand Up @@ -318,12 +319,12 @@ class Position {
// protected to allow WorldState to be accessed directly by deriveed
WorldState* last_world_state_;

// Current goalie
int goalie_id_;

// Client Handles
std::shared_ptr<ClientHandles> client_handles_;

// Current goalie
int goalie_id_;

private:
/**
* @brief allow derived classes to change behavior of get_task(). See
Expand Down
13 changes: 6 additions & 7 deletions src/rj_strategy/include/rj_strategy/agent/position/defense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <rj_msgs/action/robot_move.hpp>

#include "rj_strategy/agent/position.hpp"
#include "rj_strategy/agent/position/marker.hpp"
#include "rj_strategy/agent/position/waller.hpp"

namespace strategy {

/*
Expand All @@ -44,9 +42,8 @@ class Defense : public Position {
void revive() override;

private:
// static constexpr int kMaxWallers{6};
static constexpr int kMaxWallers{
static_cast<int>(kNumShells)}; // This effectively turns off marking
static constexpr int kMaxWallers{2};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be changed into a constant

static constexpr RJ::Seconds kMarkingGroupJoinTimeout{2.0};

/**
* @brief The derived_get_task method returns the task for the defensive robot
Expand Down Expand Up @@ -120,8 +117,10 @@ class Defense : public Position {
int get_waller_id();
State current_state_ = JOINING_WALL;

int get_marker_target_id();
Marker marker_;
bool sent_join_marking_group_request_ = false;
RJ::Time request_time_;

bool pending_marking_state_ = false;
};

} // namespace strategy
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ class GoalKicker : public Position {
std::optional<RobotIntent> derived_get_task(RobotIntent intent) override;
};

} // namespace strategy
} // namespace strategy
44 changes: 0 additions & 44 deletions src/rj_strategy/include/rj_strategy/agent/position/marker.hpp

This file was deleted.

61 changes: 61 additions & 0 deletions src/rj_strategy/include/rj_strategy/coordinator/marking.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once

#include <algorithm>
#include <array>
#include <limits>

#include <rclcpp/rclcpp.hpp>

#include <rj_common/field_dimensions.hpp>
#include <rj_common/world_state.hpp>
#include <rj_constants/constants.hpp>
#include <rj_constants/topic_names.hpp>
#include <rj_convert/ros_convert.hpp>
#include <rj_msgs/msg/marking.hpp>
#include <rj_msgs/msg/world_state.hpp>
#include <rj_msgs/srv/marking.hpp>

#include "rj_strategy/coordinator.hpp"

namespace strategy {

class Marking : public Coordinator<Marking, rj_msgs::srv::Marking, rj_msgs::msg::Marking> {
public:
static constexpr uint8_t kInvalidRobotId = kNumShells;

Marking();
~Marking() override = default;
Marking(const Marking&) = delete;
Marking& operator=(const Marking&) = delete;
Marking(Marking&&) = delete;
Marking& operator=(Marking&&) = delete;

void service_callback(RequestPtr request, ResponsePtr response);

private:
void publish_marking_list();
void update_danger_scores();
uint8_t find_their_robot_in_possession();
uint8_t most_dangerous_robot(uint8_t robotInPossession);

static constexpr int kMaxMarkers = 2;
// this is the threshold value for switching
// you can play with these constants if the current results aren't good enough
static constexpr double kSuperDangerSub = 3.2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe some more info on what each param is?

static constexpr double kDangerDistToBall = 3.0;
static constexpr double kDangerDistToGoal = 5.0;
static constexpr double kDangerDistToOurRobots = 3.0;
static constexpr double kDangerAngle = 2.0;
static constexpr double kPossessionThreshold = 0.3;
int num_markers_;

std::array<uint8_t, kNumShells> marking_list_{};
std::array<double, kNumShells> danger_score_{};
std::array<uint8_t, kNumShells> enemy_to_friends_{};
std::unordered_set<uint8_t> unassigned_markers_queue_;
WorldState last_world_state_;
FieldDimensions field_dimensions_ = FieldDimensions::kDefaultDimensions;
rclcpp::Subscription<rj_msgs::msg::WorldState>::SharedPtr world_state_sub_;
};

} // namespace strategy
72 changes: 72 additions & 0 deletions src/rj_strategy/include/rj_strategy/coordinator/marking_client.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#pragma once

#include <functional>

#include <rclcpp/rclcpp.hpp>
#include <spdlog/spdlog.h>

#include <rj_msgs/msg/marking.hpp>
#include <rj_msgs/srv/marking.hpp>

#include "rj_constants/constants.hpp"

namespace strategy {

/**
* @brief Client for interacting with the KickerPicker coordinator.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update these docstrings

*
* Manages membership in the kicker group and tracks the currently selected kicker.
*/
class MarkingClient {
public:
static constexpr uint8_t kInvalidRobotId = kNumShells;

using StatusCallback = std::function<void(bool)>;

explicit MarkingClient(rclcpp::Node::SharedPtr node, uint8_t robot_id);
~MarkingClient() = default;
MarkingClient(const MarkingClient&) = delete;
MarkingClient& operator=(const MarkingClient&) = delete;
MarkingClient(MarkingClient&&) = delete;
MarkingClient& operator=(MarkingClient&&) = delete;

/**
* @brief Join the marking group.
* @param callback Called with current membership status after attempt to join.
*/
void join_group(StatusCallback callback = nullptr);

/**
* @brief Leave the marking group.
* @param callback Called with current membership status after attempt to leave.
*/
void leave_group(StatusCallback callback = nullptr);

/**
* @brief Check if this robot is a member of the marker group.
*/
[[nodiscard]] bool am_i_member() const;

/**
* @brief Get the currently selected enemey robot id marking.
* @return robot ID of selected robot, or kInvalidRobotId if none selected.
*/
[[nodiscard]] uint8_t who_am_i_marking() const;

/**
* @brief Check if this robot is currently marking.
*/
[[nodiscard]] bool am_i_marking() const;

private:
rclcpp::Node::SharedPtr node_;
const uint8_t robot_id_; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) -- class
// isn't move/copy-able anyway
rclcpp::Client<rj_msgs::srv::Marking>::SharedPtr client_;
rclcpp::Subscription<rj_msgs::msg::Marking>::SharedPtr subscription_;
bool am_i_member_{false};
bool am_i_marking_{false};
uint8_t selected_robot_marking_id_{kInvalidRobotId};
};

} // namespace strategy
Loading
Loading