diff --git a/ateam_ai/CMakeLists.txt b/ateam_ai/CMakeLists.txt
deleted file mode 100644
index 4e7730a33..000000000
--- a/ateam_ai/CMakeLists.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-cmake_minimum_required(VERSION 3.5)
-project(ateam_ai)
-
-if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- add_compile_options(-Wall -Wextra -Wpedantic)
-endif()
-
-find_package(ament_cmake REQUIRED)
-find_package(rclcpp REQUIRED)
-find_package(rclcpp_components REQUIRED)
-find_package(tf2 REQUIRED)
-find_package(tf2_geometry_msgs REQUIRED)
-find_package(ateam_common REQUIRED)
-find_package(ateam_geometry REQUIRED)
-find_package(ateam_msgs REQUIRED)
-find_package(eigen3_cmake_module REQUIRED)
-find_package(Eigen3 REQUIRED)
-find_package(angles REQUIRED)
-
-add_library(${PROJECT_NAME} SHARED
- src/ateam_ai_node.cpp
- src/behavior/behavior_evaluator.cpp
- src/behavior/behavior_executor.cpp
- src/behavior/behavior_follower.cpp
- src/behavior/behavior_realization.cpp
- src/trajectory_generation/b_spline_wrapper.cpp
- src/trajectory_generation/b_spline.cpp
- src/trajectory_generation/trajectory_editor.cpp
- src/trajectory_generation/trajectory_generation.cpp
- src/trajectory_generation/trapezoidal_motion_profile.cpp
- src/util/message_conversions.cpp
-)
-target_include_directories(${PROJECT_NAME} PRIVATE src)
-set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20)
-ament_target_dependencies(${PROJECT_NAME}
- rclcpp
- rclcpp_components
- ateam_common
- ateam_geometry
- ateam_msgs
- Eigen3
- tf2
- tf2_geometry_msgs
- angles
-)
-rclcpp_components_register_node(
- ${PROJECT_NAME}
- PLUGIN "ateam_ai::ATeamAINode"
- EXECUTABLE ateam_ai_node
-)
-
-# Export symbols so we can backtrace
-set_property(TARGET ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS ON)
-
-install(TARGETS ${PROJECT_NAME} DESTINATION lib)
-
-if(BUILD_TESTING)
- find_package(ament_lint_auto REQUIRED)
- ament_lint_auto_find_test_dependencies()
-
- find_package(ament_cmake_gtest REQUIRED)
- ament_add_gtest(${PROJECT_NAME}_test
- test/behavior/behavior_realization_test.cpp
- test/trajectory_generation/b_spline_test.cpp
- test/trajectory_generation/b_spline_wrapper_test.cpp
- test/trajectory_generation/ilqr_problem_test.cpp
- test/trajectory_generation/trajectory_editor_test.cpp
- test/trajectory_generation/trapezoidal_motion_profile_test.cpp
- test/util/pid_test.cpp
- )
- target_include_directories(${PROJECT_NAME}_test PRIVATE test src)
- target_link_libraries(${PROJECT_NAME}_test ${PROJECT_NAME})
- set_target_properties(${PROJECT_NAME}_test PROPERTIES CXX_STANDARD 20)
-endif()
-
-ament_package()
diff --git a/ateam_ai/COLCON_IGNORE b/ateam_ai/COLCON_IGNORE
deleted file mode 100644
index e69de29bb..000000000
diff --git a/ateam_ai/package.xml b/ateam_ai/package.xml
deleted file mode 100644
index 9add084c4..000000000
--- a/ateam_ai/package.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
- ateam_ai
- 0.0.0
- A Team AI module.
- Joseph Neiger
- TODO: License declaration
-
- ament_cmake
-
- rclcpp
- rclcpp_components
- tf2
- tf2_geometry_msgs
- ateam_common
- ateam_msgs
- ateam_geometry
- eigen3_cmake_module
- eigen
- angles
-
- ament_lint_auto
- ament_lint_common
-
-
- ament_cmake
-
-
diff --git a/ateam_ai/src/ateam_ai_node.cpp b/ateam_ai/src/ateam_ai_node.cpp
deleted file mode 100644
index 5bc912240..000000000
--- a/ateam_ai/src/ateam_ai_node.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-// Copyright 2021 A Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "behavior/behavior_evaluator.hpp"
-#include "behavior/behavior_executor.hpp"
-#include "behavior/behavior_follower.hpp"
-#include "behavior/behavior_realization.hpp"
-#include "trajectory_generation/trajectory_editor.hpp"
-#include "types/world.hpp"
-#include "util/directed_graph.hpp"
-#include "util/message_conversions.hpp"
-
-using namespace std::chrono_literals;
-using ateam_common::indexed_topic_helpers::create_indexed_subscribers;
-using ateam_common::indexed_topic_helpers::create_indexed_publishers;
-
-namespace ateam_ai
-{
-
-class ATeamAINode : public rclcpp::Node
-{
-public:
- explicit ATeamAINode(const rclcpp::NodeOptions & options)
- : rclcpp::Node("ateam_ai_node", options), game_controller_listener_(*this), \
- evaluator_(realization_), executor_(realization_)
- {
- REGISTER_NODE_PARAMS(this);
- ateam_common::Overlay::GetOverlay().SetNamespace("ateam_ai");
-
- std::lock_guard lock(world_mutex_);
- world_.balls.emplace_back(Ball{});
-
- create_indexed_subscribers(
- blue_robots_subscriptions_,
- Topics::kBlueTeamRobotPrefix,
- 10,
- &ATeamAINode::blue_robot_state_callback,
- this);
-
- create_indexed_subscribers(
- yellow_robots_subscriptions_,
- Topics::kYellowTeamRobotPrefix,
- 10,
- &ATeamAINode::yellow_robot_state_callback,
- this);
-
- create_indexed_publishers(
- robot_commands_publishers_, Topics::kRobotMotionCommandPrefix,
- rclcpp::SystemDefaultsQoS(), this);
-
- auto ball_callback = [&](const ateam_msgs::msg::BallState::SharedPtr ball_state_msg) {
- ball_state_callback(world_.balls.at(0), ball_state_msg);
- };
- ball_subscription_ = create_subscription(
- std::string(Topics::kBall),
- 10,
- ball_callback);
-
- world_publisher_ = create_publisher(
- "~/world",
- rclcpp::SystemDefaultsQoS());
-
- overlay_publisher_ = create_publisher(
- "/overlay",
- rclcpp::SystemDefaultsQoS());
- ateam_common::Overlay::GetOverlay().SetOverlayPublishCallback(
- [&](ateam_msgs::msg::Overlay overlay) {
- overlay_publisher_->publish(overlay);
- }
- );
-
- field_subscription_ = create_subscription(
- std::string(Topics::kField),
- 10,
- std::bind(&ATeamAINode::field_callback, this, std::placeholders::_1));
-
- timer_ = create_wall_timer(10ms, std::bind(&ATeamAINode::timer_callback, this));
- }
-
-private:
- rclcpp::TimerBase::SharedPtr timer_;
-
- rclcpp::Subscription::SharedPtr ball_subscription_;
- std::array::SharedPtr,
- 16> blue_robots_subscriptions_;
- std::array::SharedPtr,
- 16> yellow_robots_subscriptions_;
- rclcpp::Subscription::SharedPtr
- field_subscription_;
- std::array::SharedPtr,
- 16> robot_commands_publishers_;
- rclcpp::Publisher::SharedPtr overlay_publisher_;
-
- rclcpp::Publisher::SharedPtr world_publisher_;
-
- ateam_common::GameControllerListener game_controller_listener_;
-
- BehaviorRealization realization_;
- BehaviorEvaluator evaluator_;
- BehaviorExecutor executor_;
- BehaviorFollower follower_;
- std::mutex world_mutex_;
- World world_;
- std::array, 16> previous_frame_trajectories;
-
- void blue_robot_state_callback(
- const ateam_msgs::msg::RobotState::SharedPtr robot_state_msg,
- int id)
- {
- const auto are_we_blue = game_controller_listener_.GetTeamColor() ==
- ateam_common::TeamColor::Blue;
- auto & robot_state_array = are_we_blue ? world_.our_robots : world_.their_robots;
- robot_state_callback(robot_state_array, id, robot_state_msg);
- }
-
- void yellow_robot_state_callback(
- const ateam_msgs::msg::RobotState::SharedPtr robot_state_msg,
- int id)
- {
- const auto are_we_yellow = game_controller_listener_.GetTeamColor() ==
- ateam_common::TeamColor::Yellow;
- auto & robot_state_array = are_we_yellow ? world_.our_robots : world_.their_robots;
- robot_state_callback(robot_state_array, id, robot_state_msg);
- }
-
- void robot_state_callback(
- std::array, 16> & robot_states,
- std::size_t id,
- const ateam_msgs::msg::RobotState::SharedPtr robot_state_msg)
- {
- std::lock_guard lock(world_mutex_);
- robot_states.at(id) = Robot();
- robot_states.at(id).value().pos.x() = robot_state_msg->pose.position.x;
- robot_states.at(id).value().pos.y() = robot_state_msg->pose.position.y;
- tf2::Quaternion tf2_quat;
- tf2::fromMsg(robot_state_msg->pose.orientation, tf2_quat);
- robot_states.at(id).value().theta = tf2::getYaw(tf2_quat);
- robot_states.at(id).value().vel.x() = robot_state_msg->twist.linear.x;
- robot_states.at(id).value().vel.y() = robot_state_msg->twist.linear.y;
- robot_states.at(id).value().omega = robot_state_msg->twist.angular.z;
- }
-
- void ball_state_callback(
- Ball & ball_state,
- const ateam_msgs::msg::BallState::SharedPtr ball_state_msg)
- {
- std::lock_guard lock(world_mutex_);
- ball_state.pos.x() = ball_state_msg->pose.position.x;
- ball_state.pos.y() = ball_state_msg->pose.position.y;
- ball_state.vel.x() = ball_state_msg->twist.linear.x;
- ball_state.vel.y() = ball_state_msg->twist.linear.y;
- }
-
- void field_callback(const ateam_msgs::msg::FieldInfo::SharedPtr field_msg)
- {
- Field field {
- .field_length = field_msg->field_length,
- .field_width = field_msg->field_width,
- .goal_width = field_msg->goal_width,
- .goal_depth = field_msg->goal_depth,
- .boundary_width = field_msg->boundary_width
- };
-
- // Multiple def error
- // field.center_circle = ateam_geometry::makeCircle({field_msg->center_circle.x,
- // field_msg->center_circle.y}, field_msg->center_circle_radius);
-
- // I could have just defined conversion operators for all of this but
- // Im pretty sure joe wanted ros separate from cpp
- auto convert_point_array = [&](auto & starting_array, auto final_array_iter) {
- std::transform(
- starting_array.begin(), starting_array.end(), final_array_iter,
- [&](auto & val)->Eigen::Vector2d {
- return {val.x, val.y};
- });
- };
-
- convert_point_array(field_msg->field_corners.points, field.field_corners.begin());
- convert_point_array(field_msg->ours.defense_area_corners.points, field.ours.goalie_box.begin());
- convert_point_array(field_msg->ours.goal_corners.points, field.ours.goal.begin());
- convert_point_array(
- field_msg->theirs.defense_area_corners.points,
- field.theirs.goalie_box.begin());
- convert_point_array(field_msg->theirs.goal_corners.points, field.theirs.goal.begin());
-
- std::lock_guard lock(world_mutex_);
- world_.field = field;
- }
-
- void timer_callback()
- {
- std::lock_guard lock(world_mutex_);
-
- //
- // Preproccess world
- //
- world_.current_time += 0.01;
- for (std::size_t robot_id = 0; robot_id < 16; robot_id++) {
- // Estimate of how long it will take for the round trip of
- // Command -> Radio -> Robot -> Motion -> Vision change
- const auto & maybe_trajectory = previous_frame_trajectories.at(robot_id);
- if (maybe_trajectory.has_value()) {
- world_.plan_from_our_robots.at(robot_id) = trajectory_editor::state_at_immutable_duration(
- maybe_trajectory.value(),
- world_.immutable_duration, world_.current_time);
- } else {
- world_.plan_from_our_robots.at(robot_id) = world_.our_robots.at(robot_id);
- }
- }
-
- // Get current game state for world
- world_.referee_info.running_command = game_controller_listener_.GetGameCommand();
- world_.referee_info.current_game_stage = game_controller_listener_.GetGameStage();
- // Save off the world to the rosbag
- world_publisher_->publish(ateam_ai::message_conversions::toMsg(world_));
-
- //
- // Plan behavior
- //
- auto current_behaviors = evaluator_.get_best_behaviors(world_);
- auto current_trajectories = executor_.execute_behaviors(
- current_behaviors, world_,
- world_.behavior_executor_state);
- auto robot_motion_commands = follower_.follow(current_trajectories, world_);
-
- send_all_motion_commands(robot_motion_commands);
-
- //
- // Cleanup for next frame
- //
- previous_frame_trajectories = current_trajectories;
- }
-
- void send_all_motion_commands(
- const std::array,
- 16> & robot_motion_commands)
- {
- for (std::size_t id = 0; id < robot_commands_publishers_.size(); id++) {
- const auto & maybe_motion_command = robot_motion_commands.at(id);
- if (maybe_motion_command.has_value()) {
- robot_commands_publishers_.at(id)->publish(maybe_motion_command.value());
- }
- }
- }
-};
-
-} // namespace ateam_ai
-
-RCLCPP_COMPONENTS_REGISTER_NODE(ateam_ai::ATeamAINode)
diff --git a/ateam_ai/src/behavior/behavior_evaluator.cpp b/ateam_ai/src/behavior/behavior_evaluator.cpp
deleted file mode 100644
index f721f55fe..000000000
--- a/ateam_ai/src/behavior/behavior_evaluator.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright 2023 A Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "behavior/behavior_evaluator.hpp"
-
-#include
-#include
-#include
-
-#include
-
-CREATE_PARAM(double, "behavior_evaluator/", kRotationSpeed, 0.005);
-
-BehaviorEvaluator::BehaviorEvaluator(BehaviorRealization & behavior_realization)
-: behavior_realization(behavior_realization) {}
-
-DirectedGraph BehaviorEvaluator::get_best_behaviors(const World & world)
-{
- //
- // Do preprocessing on world state to get important metrics like possession
- //
-
- //
- // Setup different behavior options
- //
-
-
- // DirectedGraph three_one_touch_shot;
- // Behavior initial_pass_start{
- // Behavior::Type::MovingKick,
- // Behavior::Priority::Required,
- // KickParam({0, 0})};
- // Behavior first_receiver{
- // Behavior::Type::OneTouchReceiveKick,
- // Behavior::Priority::Required,
- // ReceiveParam({0, 0}, {10, 10})};
- // Behavior second_receiver{
- // Behavior::Type::OneTouchReceiveKick,
- // Behavior::Priority::Required,
- // ReceiveParam({10, 10}, {-10, -10})};
- // Behavior final_receiver_shot{
- // Behavior::Type::OneTouchShot,
- // Behavior::Priority::Required,
- // ReceiveShotParam({-10, -10})};
-
- // std::size_t parent = three_one_touch_shot.add_node(initial_pass_start);
- // parent = three_one_touch_shot.add_node(first_receiver, parent);
- // parent = three_one_touch_shot.add_node(second_receiver, parent);
- // parent = three_one_touch_shot.add_node(final_receiver_shot, parent);
-
-
- // DirectedGraph direct_shot;
- // BehaviorGoal shot{
- // Behavior::Type::Shot,
- // Behavior::Priority::Required,
- // ShotParam()};
-
- // direct_shot.add_node(shot);
-
- // Generate 16 move behaviors towards the ball, we'll figure out which
- // ones we can fill later
- // DirectedGraph simple_move;
- // static double j = 0;
- // j += kRotationSpeed;
- // for (int i = 0; i < 16; i++) {
- // double theta = i / 11.0 * 3.14 * 2 + j;
- // BehaviorGoal move{
- // BehaviorGoal::Type::MoveToPoint,
- // BehaviorGoal::Priority::Required,
- // MoveParam(
- // (sin(3 * theta) + 1.5) * Eigen::Vector2d{cos(theta), sin(
- // theta)} - Eigen::Vector2d{2, 0})};
- // }
-
- //
- // Qual Video Behaviors
- //
- DirectedGraph qual_goalie_and_shot;
- double ball_y = 0;
- if (world.get_unique_ball().has_value()) {
- ball_y = world.get_unique_ball().value().pos.y();
- }
- BehaviorGoal goalie{
- BehaviorGoal::Type::MoveToPoint,
- BehaviorGoal::Priority::Required,
- MoveParam(Eigen::Vector2d{-5, ball_y})};
- qual_goalie_and_shot.add_node(goalie);
-
- BehaviorGoal kicker{
- BehaviorGoal::Type::MovingKick,
- BehaviorGoal::Priority::Required,
- MoveParam(Eigen::Vector2d{0, 1})};
- qual_goalie_and_shot.add_node(kicker);
-
- for (int i = 2; i < 16; i++) {
- BehaviorGoal move{
- BehaviorGoal::Type::MoveToPoint,
- BehaviorGoal::Priority::Required,
- MoveParam(Eigen::Vector2d{i / -2.0, 4})};
- qual_goalie_and_shot.add_node(move);
- }
-
- //
- // Add background behaviors
- //
-
- // std::vector>> possible_behaviors{
- // three_one_touch_shot, direct_shot};
- // for (auto & behavior : possible_behaviors) {
- // Behavior goalie{
- // Behavior::Type::MoveToPoint,
- // Behavior::Priority::Medium,
- // MoveParam({0, 0})}; // Field::OurGoal.center();
- // Behavior forward{
- // Behavior::Type::MoveToPoint,
- // Behavior::Priority::Low,
- // MoveParam({10, 0})}; // Field::TheirGoal.center();
- // Behavior left_defender{
- // Behavior::Type::MoveToPoint,
- // Behavior::Priority::Medium,
- // MoveParam({5, 5})};
- // Behavior right_defender{
- // Behavior::Type::MoveToPoint,
- // Behavior::Priority::Medium,
- // MoveParam({5, -5})};
-
- // behavior.get().add_node(goalie);
- // behavior.get().add_node(forward);
- // behavior.get().add_node(left_defender);
- // behavior.get().add_node(right_defender);
- // }
-
- //
- // See how that combination of behaviors would be planned and executed
- //
- // DirectedGraph three_one_touch_shot_feedback =
- // behavior_realization.realize_behaviors(three_one_touch_shot, world);
- // DirectedGraph direct_shot_feedback =
- // behavior_realization.realize_behaviors(direct_shot, world);
-
- //
- // Choose main behavior
- //
-
- // choose direct shot because score chance is better or
- // maybe the total behavior completetion time is short
- // or maybe the other one can't be completed due to number of robots
- DirectedGraph behavior_out = qual_goalie_and_shot;
-
- return behavior_out;
-}
diff --git a/ateam_ai/src/behavior/behavior_evaluator.hpp b/ateam_ai/src/behavior/behavior_evaluator.hpp
deleted file mode 100644
index eea8a1aff..000000000
--- a/ateam_ai/src/behavior/behavior_evaluator.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2021 A Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef BEHAVIOR__BEHAVIOR_EVALUATOR_HPP_
-#define BEHAVIOR__BEHAVIOR_EVALUATOR_HPP_
-
-#include
-
-#include "behavior/behavior_realization.hpp"
-#include "types/behavior_goal.hpp"
-#include "types/world.hpp"
-#include "util/directed_graph.hpp"
-
-/**
- * Figure out which set of behaviors to run
- */
-class BehaviorEvaluator
-{
-public:
- explicit BehaviorEvaluator(BehaviorRealization & behavior_realization);
-
- DirectedGraph get_best_behaviors(const World & world);
-
-private:
- BehaviorRealization & behavior_realization;
-};
-
-#endif // BEHAVIOR__BEHAVIOR_EVALUATOR_HPP_
diff --git a/ateam_ai/src/behavior/behavior_executor.cpp b/ateam_ai/src/behavior/behavior_executor.cpp
deleted file mode 100644
index b48a282fc..000000000
--- a/ateam_ai/src/behavior/behavior_executor.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2021 A Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "behavior/behavior_executor.hpp"
-
-#include "types/behavior_plan.hpp"
-#include "trajectory_generation/trajectory_editor.hpp"
-
-BehaviorExecutor::BehaviorExecutor(BehaviorRealization & behavior_realization)
-: behavior_realization(behavior_realization) {}
-
-std::array, 16> BehaviorExecutor::execute_behaviors(
- const DirectedGraph & behaviors,
- const World & world,
- BehaviorExecutorState & self_state)
-{
- //
- // Grab trajectories for everything
- //
- DirectedGraph behavior_feedback = behavior_realization.realize_behaviors(
- behaviors, world);
-
- //
- // Replan course trajectories as we approach their start time
- //
-
- // Long term planning (>10 seconds) is not valid due to the speed of robots
- // as we approach some of the later behaviors in time, we need to replan them
- // using better planners to dodge these obstacles and everything
-
- //
- // Send trajectories to follow
- //
-
- // Clear world trajectories
- for (auto & trajectory : self_state.previous_trajectories) {
- trajectory.reset();
- }
-
- std::array, 16> output_trajectories;
- for (const auto & root_id : behavior_feedback.get_root_nodes()) {
- // Assume there are no children for now
- const auto & root_node = behavior_feedback.get_node(root_id);
-
- // If the behavior is assigned a robot
- if (root_node.assigned_robot_id.has_value()) {
- Trajectory trajectory = root_node.trajectory;
- std::size_t assigned_robot = root_node.assigned_robot_id.value();
-
- if (self_state.previous_trajectories.at(assigned_robot).has_value()) {
- trajectory = trajectory_editor::apply_immutable_duration(
- self_state.previous_trajectories.at(assigned_robot).value(),
- trajectory,
- world.immutable_duration,
- world.current_time);
- }
-
- output_trajectories.at(root_node.assigned_robot_id.value()) = root_node.trajectory;
- self_state.previous_trajectories.at(assigned_robot) = trajectory;
- }
- }
-
- return output_trajectories;
-}
diff --git a/ateam_ai/src/behavior/behavior_executor.hpp b/ateam_ai/src/behavior/behavior_executor.hpp
deleted file mode 100644
index 4507c3794..000000000
--- a/ateam_ai/src/behavior/behavior_executor.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2021 A Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef BEHAVIOR__BEHAVIOR_EXECUTOR_HPP_
-#define BEHAVIOR__BEHAVIOR_EXECUTOR_HPP_
-
-#include
-#include
-
-#include
-#include
-
-#include "behavior/behavior_realization.hpp"
-#include "types/behavior_goal.hpp"
-#include "types/world.hpp"
-#include "types/trajectory.hpp"
-#include "util/directed_graph.hpp"
-
-
-/**
- * Given a set of behaviors
- * - Replan trajectories as their start time approaches
- * - Manage the trajectories
- */
-class BehaviorExecutor
-{
-public:
- explicit BehaviorExecutor(BehaviorRealization & behavior_realization);
-
- std::array, 16> execute_behaviors(
- const DirectedGraph & behaviors,
- const World & world,
- BehaviorExecutorState & self_state);
-
-private:
- BehaviorRealization & behavior_realization;
-};
-
-#endif // BEHAVIOR__BEHAVIOR_EXECUTOR_HPP_
diff --git a/ateam_ai/src/behavior/behavior_follower.cpp b/ateam_ai/src/behavior/behavior_follower.cpp
deleted file mode 100644
index e6bbb361e..000000000
--- a/ateam_ai/src/behavior/behavior_follower.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2021 A Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "behavior/behavior_follower.hpp"
-
-#include
-
-#include "util/pid.hpp"
-#include "util/viz.hpp"
-
-CREATE_PARAM(double, "follower/pid/x_kp", x_kp, 2);
-CREATE_PARAM(double, "follower/pid/y_kp", y_kp, 2);
-CREATE_PARAM(double, "follower/pid/t_kp", t_kp, 3);
-
-BehaviorFollower::RobotMotionCommands BehaviorFollower::follow(
- const std::array, 16> & robot_trajectories,
- World & world)
-{
- RobotMotionCommands robot_motion_commands;
- for (std::size_t robot_id = 0; robot_id < 16; robot_id++) {
- const auto & maybe_trajectory = robot_trajectories.at(robot_id);
-
- // We need a trajectory that is at least 1 sample long
- if (!maybe_trajectory.has_value() ||
- maybe_trajectory.value().samples.empty())
- {
- continue;
- }
-
- auto & robot_controllers = trajectory_controllers.at(robot_id);
- auto & x_controller = robot_controllers.at(0);
- x_controller.set_kp(x_kp);
- auto & y_controller = robot_controllers.at(1);
- y_controller.set_kp(y_kp);
- auto & t_controller = robot_controllers.at(2);
- t_controller.set_kp(t_kp);
-
- Sample3d command = get_next_command(maybe_trajectory.value(), world.current_time);
-
- const auto & our_robot = world.our_robots.at(robot_id).value();
-
- ateam_msgs::msg::RobotMotionCommand motion_command;
- motion_command.twist.linear.x = command.vel.x() + x_controller.execute(
- command.pose.x(), our_robot.pos.x());
- motion_command.twist.linear.y = command.vel.y() + y_controller.execute(
- command.pose.y(), our_robot.pos.y());
- motion_command.twist.angular.z = command.vel.z() + t_controller.execute(
- command.pose.z(), our_robot.theta, true);
-
- viz::DrawTrajectory(robot_id, maybe_trajectory.value());
-
- // TODO(jneiger): move this to a better spot
- Eigen::Vector2d robot{world.our_robots.at(robot_id).value().pos.x(), world.our_robots.at(
- robot_id).value().pos.y()};
- motion_command.kick = world.get_unique_ball().has_value() &&
- (world.get_unique_ball().value().pos - robot).norm() < 0.1;
- motion_command.kick_speed = 5; // m/s
- robot_motion_commands.at(robot_id) = motion_command;
- }
-
- return robot_motion_commands;
-}
-
-Sample3d BehaviorFollower::get_next_command(const Trajectory & t, double current_time)
-{
- Sample3d command;
- command = t.samples.front();
-
- // Find first sample that is either current time or after
- for (const auto & sample : t.samples) {
- if (sample.time >= current_time) {
- command = sample;
- break;
- }
- }
-
- return command;
-}
diff --git a/ateam_ai/src/behavior/behavior_follower.hpp b/ateam_ai/src/behavior/behavior_follower.hpp
deleted file mode 100644
index 0e81dae0b..000000000
--- a/ateam_ai/src/behavior/behavior_follower.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2021 A Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef BEHAVIOR__BEHAVIOR_FOLLOWER_HPP_
-#define BEHAVIOR__BEHAVIOR_FOLLOWER_HPP_
-
-#include
-#include
-
-#include
-#include
-
-#include "behavior/behavior_realization.hpp"
-#include "types/trajectory.hpp"
-#include "types/world.hpp"
-#include "util/pid.hpp"
-
-/**
- * Given trajectories as a function of time
- * - Follow them as best as possible
- */
-class BehaviorFollower
-{
-public:
- using MaybeRobotMotionCommand = std::optional;
- using RobotMotionCommands = std::array;
-
- RobotMotionCommands follow(
- const std::array, 16> & robot_trajectories,
- World & world);
-
-private:
- static Sample3d get_next_command(const Trajectory & t, double current_time);
-
- std::array, 16> trajectory_controllers;
-};
-
-#endif // BEHAVIOR__BEHAVIOR_FOLLOWER_HPP_
diff --git a/ateam_ai/src/behavior/behavior_realization.cpp b/ateam_ai/src/behavior/behavior_realization.cpp
deleted file mode 100644
index a656d2a41..000000000
--- a/ateam_ai/src/behavior/behavior_realization.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-// Copyright 2021 A Team
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include