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

RobotFactoryPosition Layer #2107

Merged
merged 51 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f8a3e42
delete manipulator control node
sid-parikh Jul 2, 2023
fd8dcf9
delete node
sid-parikh Jul 2, 2023
c3fc070
delete maniuplators vector
sid-parikh Jul 2, 2023
bdcfa8f
Fix Code Style On delete_maninpulator_node (#2084)
github-actions[bot] Aug 15, 2023
fb613c5
Remove mention to removed filed
Sep 12, 2023
0c032b6
Setup Ros2
Sep 13, 2023
6236804
WIP: removed default position assignment from AC
p-nayak11 Sep 25, 2023
3ecd267
Add Referee/PlayState to files using CoachState
Sep 27, 2023
a5058e7
added some functions back... will have to convert them later
p-nayak11 Oct 2, 2023
ec56dc2
Forward PlayState to Position
Oct 4, 2023
8ed6372
Formatting
Oct 4, 2023
175801a
remove world_state and field_dim callbacks from Position -> pass via …
p-nayak11 Oct 4, 2023
32d1a45
replace the world_state() function in Position class
p-nayak11 Oct 4, 2023
745b2d8
planner gets global overrides directly from referee
petergarud Oct 16, 2023
137cc1d
allow external referee to work
petergarud Oct 16, 2023
cb216f0
WIP analyzer class
p-nayak11 Oct 16, 2023
1dfa12d
Calculate Global Overrides in Planner Node
Oct 18, 2023
6b099bb
compiles with analyzer class but sim broken
p-nayak11 Oct 18, 2023
73fe00d
conceptual mistake of analyzer and position
p-nayak11 Oct 18, 2023
75ea0d2
removed defense obstacles publishing from coach node and moved code t…
petergarud Oct 18, 2023
d21a9cf
Fix Code Style On remove-coach-node-defense-obstacles (#2123)
github-actions[bot] Oct 22, 2023
e1236ff
Fix Code Style On remove-coach-node-global-overrides (#2124)
github-actions[bot] Oct 22, 2023
f23c310
compiler errors
petergarud Oct 23, 2023
ec11b00
defense obstacles updates on new field_dimensions
petergarud Oct 23, 2023
b863631
changed situation analyzer to RootRobotPosition
p-nayak11 Oct 23, 2023
1639325
compiles now
p-nayak11 Oct 23, 2023
2289c55
fixed issues on pull request
petergarud Oct 24, 2023
c52cef0
override set_is_done from rootrobotposition
p-nayak11 Oct 25, 2023
1a5c8df
Fix Warnings
Oct 30, 2023
5e0c840
root_robot -> robot_factory change and planning works
p-nayak11 Oct 30, 2023
7055351
merged remove-coach-node
p-nayak11 Nov 6, 2023
b31191b
communication is properly forwarded to subclasses
p-nayak11 Nov 6, 2023
fb93905
remove print statements
p-nayak11 Nov 6, 2023
d7e26d9
Merge remote-tracking branch 'origin/remove-coach-node-defense-obstac…
p-nayak11 Nov 8, 2023
55369df
update include; add docstring
p-nayak11 Nov 8, 2023
1aa4bc1
Delete Coach
p-nayak11 Nov 8, 2023
0017c29
merged remove-coach-node-global-overrides
p-nayak11 Nov 13, 2023
9bd8204
final changes and revisions across PR
p-nayak11 Nov 13, 2023
c027010
Fix Code Style On position_rewrite (#2108)
github-actions[bot] Nov 13, 2023
69f130f
make pretty lines
p-nayak11 Nov 13, 2023
ce59fe5
Merge branch 'position_rewrite' of https://github.com/RoboJackets/rob…
p-nayak11 Nov 13, 2023
5fc2f22
changed check styles because we don't work with python
p-nayak11 Nov 13, 2023
890a065
changed check styles because we don't work with python again
p-nayak11 Nov 13, 2023
91290e2
Merge remote-tracking branch 'origin/ros2' into position_rewrite. Note:
sid-parikh Nov 16, 2023
30d503f
fix subscriptions; don't republish FieldDimensions unless necessary
sid-parikh Nov 18, 2023
e76286b
delete unused constant
sid-parikh Nov 18, 2023
ba34170
remove spammy debug logging
sid-parikh Nov 18, 2023
30e70bc
actually make lock; modernize no void thing
sid-parikh Nov 18, 2023
37688b7
clang-tidy warnings
sid-parikh Nov 18, 2023
d70bdbc
no copy or move for RobotFactoryPosition
sid-parikh Nov 19, 2023
0574346
reformat
sid-parikh Nov 19, 2023
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
12 changes: 2 additions & 10 deletions launch/soccer.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def generate_launch_description():
output="screen",
on_exit=Shutdown(),
),
# spawn strategy only if manual is not on
# spawn internal_ref/external_ref based on internal_ref
# LaunchArgument
Node(
condition=IfCondition(PythonExpression(["not ", use_manual_control])),
package="rj_robocup",
Expand All @@ -189,15 +190,6 @@ def generate_launch_description():
parameters=[param_config_filepath],
on_exit=Shutdown(),
),
Node(
condition=IfCondition(PythonExpression(["not ", use_manual_control])),
package="rj_robocup",
executable="coach_node",
output="screen",
parameters=[param_config_filepath],
on_exit=Shutdown(),
),
# spawn internal_ref/external_ref based on internal_ref LaunchArgument
Node(
condition=IfCondition(PythonExpression([use_internal_ref])),
package="rj_robocup",
Expand Down
2 changes: 1 addition & 1 deletion rj_common/include/rj_common/field_dimensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct FieldDimensions {

/*
* Provides a rect that is a padded version of their goalbox.
* Used as a static obstalce by coach in certain match situations.
* Used as a static obstacle in certain match situations.
*/
[[nodiscard]] rj_geometry::Rect their_defense_area_padded(float padding) {
rj_geometry::Rect tmp = rj_geometry::Rect(their_defense_area_);
Expand Down
2 changes: 1 addition & 1 deletion rj_common/include/rj_common/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static const std::string kSharedVisionSourceAddress = "224.5.23.2";
* one (or try them all in worst-case).
*/

static const std::string kRefereeInterface = "192.168.20.119";
static const std::string kRefereeInterface = "127.0.0.1";
/* static const std::string kRefereeInterface = "172.0.0.1"; */
static const std::string kVisionInterface =
kRefereeInterface; // In all but rare cirucmstances, this should match kRefereeInterface.
Expand Down
6 changes: 4 additions & 2 deletions rj_config/src/config_server/config_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ void ConfigServer::broadcast_field_dimensions() {
}

void ConfigServer::set_field_dimensions_callback(const FieldDimensionsMsg& msg) {
field_dimensions_ = msg;
broadcast_field_dimensions();
if (field_dimensions_ != msg) {
field_dimensions_ = msg;
broadcast_field_dimensions();
}
}

} // namespace config_server
4 changes: 1 addition & 3 deletions rj_constants/include/rj_constants/topic_names.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ static inline std::string trajectory_topic(int robot_id) {
} // namespace planning::topics

namespace strategy::topics {
constexpr auto kCoachStateTopic{"/strategy/coach_state"};
constexpr auto kPositionsTopic{"/strategy/positions"};
} // namespace strategy::topics

namespace control {
Expand Down Expand Up @@ -108,4 +106,4 @@ static inline std::string robot_status_topic(int robot_id) {
return "radio/robot_status/robot_" + std::to_string(robot_id);
}

} // namespace radio::topics
} // namespace radio::topics
3 changes: 0 additions & 3 deletions rj_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ rosidl_generate_interfaces(
msg/AliveRobots.msg
msg/BallState.msg
msg/BallPlacement.msg
msg/CoachState.msg
msg/DetectionBall.msg
msg/DetectionFrame.msg
msg/DetectionRobot.msg
msg/FieldDimensions.msg
msg/FieldOrientation.msg
msg/GameSettings.msg
msg/GlobalOverride.msg
msg/Goalie.msg
msg/ManipulatorSetpoint.msg
msg/MatchState.msg
Expand All @@ -54,7 +52,6 @@ rosidl_generate_interfaces(
msg/TeamInfo.msg
msg/Trajectory.msg
msg/WorldState.msg
msg/PositionAssignment.msg

# Communication
msg/AgentRequest.msg
Expand Down
4 changes: 0 additions & 4 deletions rj_msgs/msg/CoachState.msg

This file was deleted.

6 changes: 0 additions & 6 deletions rj_msgs/msg/GlobalOverride.msg

This file was deleted.

2 changes: 1 addition & 1 deletion rj_protos/protos/Control.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message Control {
ON_BREAK_BEAM = 2;
}

// LEDs on the robot display different colors based on current role from Coach
// LEDs on the robot display different colors based on current role
enum Role {
GOALIE = 0;
DEFENSE = 1;
Expand Down
8 changes: 0 additions & 8 deletions soccer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ add_executable(sim_radio_node)
add_executable(network_radio_node)
add_executable(manual_control_node)
add_executable(global_param_server_node)
add_executable(coach_node)
add_executable(agent_action_client_node)

if(BUILD_TESTING)
Expand Down Expand Up @@ -170,9 +169,6 @@ set(LOG_VIEWER_DEPS_LIBRARIES robocup)
set(REFEREE_NODE_DEPS_SYSTEM_LIBRARIES)
set(REFEREE_NODE_DEPS_LIBRARIES robocup)

set(COACH_NODE_DEPS_SYSTEM_LIBRARIES)
set(COACH_NODE_DEPS_LIBRARIES robocup)

set(RADIO_NODE_DEPS_SYSTEM_LIBRARIES)
set(RADIO_NODE_DEPS_LIBRARIES robocup)

Expand Down Expand Up @@ -229,9 +225,6 @@ target_link_libraries(internal_referee_node PRIVATE ${REFEREE_NODE_DEPS_SYSTEM_L
target_link_libraries(sim_radio_node PRIVATE ${RADIO_NODE_DEPS_SYSTEM_LIBRARIES}
${RADIO_NODE_DEPS_LIBRARIES})

target_link_libraries(coach_node PRIVATE ${COACH_NODE_DEPS_SYSTEM_LIBRARIES}
${COACH_NODE_DEPS_LIBRARIES})

# -- network_radio_node --
target_link_libraries(network_radio_node PRIVATE ${RADIO_NODE_DEPS_SYSTEM_LIBRARIES}
${RADIO_NODE_DEPS_LIBRARIES})
Expand Down Expand Up @@ -296,7 +289,6 @@ install(
planner_node
control_node
sim_radio_node
coach_node
network_radio_node
manual_control_node
global_param_server_node
Expand Down
8 changes: 1 addition & 7 deletions soccer/src/soccer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ set(ROBOCUP_LIB_SRC
radio/network_radio.cpp
radio/packet_convert.cpp
radio/sim_radio.cpp
strategy/coach/coach_node.cpp
radio/radio.cpp
referee/referee_base.cpp
referee/external_referee.cpp
Expand All @@ -72,12 +71,12 @@ set(ROBOCUP_LIB_SRC
ros2_temp/soccer_config_client.cpp
ros2_temp/raw_vision_packet_sub.cpp
ros2_temp/referee_sub.cpp
ros2_temp/coach_sub.cpp
ros2_temp/autonomy_interface.cpp
ros2_temp/debug_draw_interface.cpp
strategy/agent/agent_action_client.cpp
strategy/agent/communication/communication.cpp
strategy/agent/position/position.cpp
strategy/agent/position/robot_factory_position.cpp
strategy/agent/position/goalie.cpp
strategy/agent/position/offense.cpp
strategy/agent/position/defense.cpp
Expand Down Expand Up @@ -122,8 +121,6 @@ set(CONTROL_NODE_SRC control/control_node_main.cpp)

set(SIM_RADIO_NODE_SRC radio/sim_radio_node_main.cpp)

set(COACH_NODE_SRC strategy/coach/coach_node_main.cpp)

set(NETWORK_RADIO_NODE_SRC radio/network_radio_node_main.cpp)

set(MANUAL_CONTROL_NODE_SRC joystick/manual_control_node_main.cpp)
Expand Down Expand Up @@ -163,9 +160,6 @@ target_sources(control_node PRIVATE ${CONTROL_NODE_SRC})
# ---- sim_radio_node ----
target_sources(sim_radio_node PRIVATE ${SIM_RADIO_NODE_SRC})

# ---- coach_node ----
target_sources(coach_node PRIVATE ${COACH_NODE_SRC})

# ---- sim_radio_node ----
target_sources(network_radio_node PRIVATE ${NETWORK_RADIO_NODE_SRC})

Expand Down
1 change: 1 addition & 0 deletions soccer/src/soccer/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct Context {
// Radio -> Gameplay
std::array<RobotStatus, kNumShells> robot_status;
// Coach -> Positions
// TODO(sid-parikh) Delete Robot_Positions UI stuff
std::array<uint32_t, kNumShells> robot_positions;
// MainWindow -> Manual control
std::array<bool, kNumShells> is_joystick_controlled{};
Expand Down
1 change: 1 addition & 0 deletions soccer/src/soccer/control/motion_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <rj_geometry/util.hpp>
#include <rj_utils/logging.hpp>

#include "game_state.hpp"
#include "planning/instant.hpp"

namespace control {
Expand Down
3 changes: 2 additions & 1 deletion soccer/src/soccer/control/motion_control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <rj_param_utils/param.hpp>

#include "control/motion_setpoint.hpp"
#include "game_state.hpp"
#include "ros_debug_drawer.hpp"

#include <rc-fshare/pid.hpp>
Expand Down Expand Up @@ -96,4 +97,4 @@ class MotionControl {
rclcpp::Publisher<RobotState::Msg>::SharedPtr target_state_pub_;
};

} // namespace control
} // namespace control
3 changes: 2 additions & 1 deletion soccer/src/soccer/control/motion_control_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>

#include "game_state.hpp"
#include "motion_control_node.hpp"

namespace control::testing {
Expand Down Expand Up @@ -129,4 +130,4 @@ TEST_F(MotionControlTest, coordinate_transform_body_x) {
EXPECT_NEAR(setpoint.avelocity, 0.0, 1e-6);
}

} // namespace control::testing
} // namespace control::testing
70 changes: 54 additions & 16 deletions soccer/src/soccer/planning/global_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ GlobalState::GlobalState(rclcpp::Node* node) {
play_state_sub_ = node->create_subscription<rj_msgs::msg::PlayState>(
referee::topics::kPlayStateTopic, rclcpp::QoS(1),
[this](rj_msgs::msg::PlayState::SharedPtr state) { // NOLINT
auto lock = std::lock_guard(last_play_state_mutex_);
last_play_state_ = rj_convert::convert_from_ros(*state);
{
auto lock = std::lock_guard(last_play_state_mutex_);
last_play_state_ = rj_convert::convert_from_ros(*state);
have_play_state_ = true;
}
set_static_obstacles();
});
game_settings_sub_ = node->create_subscription<rj_msgs::msg::GameSettings>(
config_server::topics::kGameSettingsTopic, rclcpp::QoS(1),
Expand All @@ -27,30 +31,29 @@ GlobalState::GlobalState(rclcpp::Node* node) {
auto lock = std::lock_guard(last_global_obstacles_mutex_);
last_global_obstacles_ = rj_convert::convert_from_ros(*global_obstacles);
});
def_area_obstacles_sub_ = node->create_subscription<rj_geometry_msgs::msg::ShapeSet>(
planning::topics::kDefAreaObstaclesTopic, rclcpp::QoS(1),
[this](rj_geometry_msgs::msg::ShapeSet::SharedPtr def_area_obstacles) { // NOLINT
auto lock = std::lock_guard(last_def_area_obstacles_mutex_);
last_def_area_obstacles_ = rj_convert::convert_from_ros(*def_area_obstacles);
});
world_state_sub_ = node->create_subscription<rj_msgs::msg::WorldState>(
vision_filter::topics::kWorldStateTopic, rclcpp::QoS(1),
[this](rj_msgs::msg::WorldState::SharedPtr world_state) { // NOLINT
auto lock = std::lock_guard(last_world_state_mutex_);
last_world_state_ = rj_convert::convert_from_ros(*world_state);
});
coach_state_sub_ = node->create_subscription<rj_msgs::msg::CoachState>(
"/strategy/coach_state", rclcpp::QoS(1),
[this](rj_msgs::msg::CoachState::SharedPtr coach_state) { // NOLINT
auto lock = std::lock_guard(last_coach_state_mutex_);
last_coach_state_ = *coach_state;
field_dimensions_sub_ = node->create_subscription<rj_msgs::msg::FieldDimensions>(
::config_server::topics::kFieldDimensionsTopic, rclcpp::QoS(1).transient_local(),
[this](const rj_msgs::msg::FieldDimensions::SharedPtr msg) { // NOLINT
{
auto lock = std::lock_guard(last_field_dimensions_mutex_);
last_field_dimensions_ = rj_convert::convert_from_ros(*msg);
have_field_dimensions_ = true;
}
set_static_obstacles();
});
}

[[nodiscard]] PlayState GlobalState::play_state() const {
auto lock = std::lock_guard(last_play_state_mutex_);
return last_play_state_;
}

[[nodiscard]] GameSettings GlobalState::game_settings() const {
auto lock = std::lock_guard(last_game_settings_mutex_);
return last_game_settings_;
Expand All @@ -71,9 +74,44 @@ GlobalState::GlobalState(rclcpp::Node* node) {
auto lock = std::lock_guard(last_world_state_mutex_);
return &last_world_state_;
}
[[nodiscard]] const rj_msgs::msg::CoachState GlobalState::coach_state() const {
auto lock = std::lock_guard(last_coach_state_mutex_);
return last_coach_state_;

rj_geometry::ShapeSet GlobalState::create_defense_area_obstacles() {
// need field dimensions and to be initialized for this to
// work
// Create defense areas as rectangular area obstacles
auto our_defense_area{
std::make_shared<rj_geometry::Rect>(last_field_dimensions_.our_defense_area())};

// Sometimes there is a greater distance we need to keep:
// https://robocup-ssl.github.io/ssl-rules/sslrules.html#_robot_too_close_to_opponent_defense_area
bool is_extra_dist_necessary = (last_play_state_.state() == PlayState::State::Stop ||
last_play_state_.restart() == PlayState::Restart::Free);

// Also add a slack around the box
float slack_around_box{0.3f};

auto their_defense_area =
is_extra_dist_necessary
? std::make_shared<rj_geometry::Rect>(
last_field_dimensions_.their_defense_area_padded(slack_around_box))
: std::make_shared<rj_geometry::Rect>(last_field_dimensions_.their_defense_area());

// Combine both defense areas into ShapeSet
rj_geometry::ShapeSet def_area_obstacles{};
def_area_obstacles.add(our_defense_area);
def_area_obstacles.add(their_defense_area);

return def_area_obstacles;
}

void GlobalState::set_static_obstacles() {
std::scoped_lock lock{last_field_dimensions_mutex_, last_play_state_mutex_,
last_def_area_obstacles_mutex_};

if (have_field_dimensions_ && have_play_state_) {
// SPDLOG_INFO("Creating new defense obstacles");
last_def_area_obstacles_ = create_defense_area_obstacles();
}
}

} // namespace planning
Loading
Loading