diff --git a/src/software/embedded/primitive_executor.cpp b/src/software/embedded/primitive_executor.cpp index d1f56161ee..86dd75f7d8 100644 --- a/src/software/embedded/primitive_executor.cpp +++ b/src/software/embedded/primitive_executor.cpp @@ -11,13 +11,8 @@ #include "software/physics/velocity_conversion_util.h" PrimitiveExecutor::PrimitiveExecutor( - const Duration time_step, const robot_constants::RobotConstants& robot_constants, - const TeamColour friendly_team_colour, const RobotId robot_id) - : current_primitive_(), - friendly_team_colour_(friendly_team_colour), - robot_constants_(robot_constants), - time_step_(time_step), - robot_id_(robot_id) + const Duration time_step, const robot_constants::RobotConstants& robot_constants) + : current_primitive_(), robot_constants_(robot_constants), time_step_(time_step) { } @@ -38,11 +33,6 @@ void PrimitiveExecutor::updatePrimitive(const TbotsProto::Primitive& primitive_m } } -void PrimitiveExecutor::setStopPrimitive() -{ - current_primitive_ = *createStopPrimitiveProto(); -} - void PrimitiveExecutor::updateVelocity(const Vector& local_velocity, const AngularVelocity& angular_velocity) { @@ -145,8 +135,3 @@ std::unique_ptr PrimitiveExecutor::stepPrimi } return std::make_unique(); } - -void PrimitiveExecutor::setRobotId(const RobotId robot_id) -{ - robot_id_ = robot_id; -} diff --git a/src/software/embedded/primitive_executor.h b/src/software/embedded/primitive_executor.h index 145874f3c2..52d9de711e 100644 --- a/src/software/embedded/primitive_executor.h +++ b/src/software/embedded/primitive_executor.h @@ -17,13 +17,9 @@ class PrimitiveExecutor * @param time_step Time step which this primitive executor operates in * @param robot_constants The robot constants for the robot which uses this primitive * executor - * @param friendly_team_colour The colour of the friendly team - * @param robot_id The id of the robot which uses this primitive executor */ explicit PrimitiveExecutor(const Duration time_step, - const robot_constants::RobotConstants& robot_constants, - const TeamColour friendly_team_colour, - const RobotId robot_id); + const robot_constants::RobotConstants& robot_constants); /** * Update primitive executor with a new Primitive @@ -31,11 +27,6 @@ class PrimitiveExecutor */ void updatePrimitive(const TbotsProto::Primitive& primitive_msg); - /** - * Set the current primitive to the stop primitive - */ - void setStopPrimitive(); - /** * Update primitive executor with the current velocity of the robot * @@ -45,12 +36,6 @@ class PrimitiveExecutor void updateVelocity(const Vector& local_velocity, const AngularVelocity& angular_velocity); - /** - * Set the robot id - * @param robot_id The id of the robot which uses this primitive executor - */ - void setRobotId(RobotId robot_id); - /** * Steps the current primitive and returns a direct control primitive with the * target wheel velocities @@ -81,7 +66,6 @@ class PrimitiveExecutor Vector velocity_; AngularVelocity angular_velocity_; Angle orientation_; - TeamColour friendly_team_colour_; robot_constants::RobotConstants robot_constants_; std::optional trajectory_path_; std::optional angular_trajectory_; @@ -89,7 +73,6 @@ class PrimitiveExecutor // TODO (#2855): Add dynamic time_step to `stepPrimitive` and remove this constant // time step to be used, in Seconds Duration time_step_; - RobotId robot_id_; // Estimated delay between a vision frame to AI processing to robot executing static constexpr double VISION_TO_ROBOT_DELAY_S = 0.03; diff --git a/src/software/embedded/thunderloop.cpp b/src/software/embedded/thunderloop.cpp index afc30bdd03..c2d9c08a70 100644 --- a/src/software/embedded/thunderloop.cpp +++ b/src/software/embedded/thunderloop.cpp @@ -4,6 +4,7 @@ #include #include "proto/message_translation/tbots_protobuf.h" +#include "proto/primitive/primitive_msg_factory.h" #include "proto/robot_crash_msg.pb.h" #include "proto/robot_status_msg.pb.h" #include "proto/tbots_software_msgs.pb.h" @@ -71,7 +72,6 @@ extern "C" Thunderloop::Thunderloop(const robot_constants::RobotConstants& robot_constants, bool enable_log_merging, const int loop_hz) - // TODO (#2495): Set the friendly team colour : toml_config_client_(std::make_unique(TOML_CONFIG_FILE_PATH)), motor_status_(std::nullopt), robot_constants_(robot_constants), @@ -84,8 +84,7 @@ Thunderloop::Thunderloop(const robot_constants::RobotConstants& robot_constants, kick_constant_(std::stoi(toml_config_client_->get(ROBOT_KICK_CONSTANT_CONFIG_KEY))), chip_pulse_width_( std::stoi(toml_config_client_->get(ROBOT_CHIP_PULSE_WIDTH_CONFIG_KEY))), - primitive_executor_(Duration::fromSeconds(1.0 / loop_hz), robot_constants, - TeamColour::YELLOW, robot_id_) + primitive_executor_(Duration::fromSeconds(1.0 / loop_hz), robot_constants) { waitForNetworkUp(); @@ -284,7 +283,7 @@ void Thunderloop::runLoop() if (nanoseconds_elapsed_since_last_primitive > PACKET_TIMEOUT_NS) { - primitive_executor_.setStopPrimitive(); + primitive_executor_.updatePrimitive(*createStopPrimitiveProto()); } direct_control_ = diff --git a/src/software/simulation/er_force_simulator.cpp b/src/software/simulation/er_force_simulator.cpp index 7a645b85e1..c609bff582 100644 --- a/src/software/simulation/er_force_simulator.cpp +++ b/src/software/simulation/er_force_simulator.cpp @@ -281,15 +281,13 @@ void ErForceSimulator::setRobots( if (side == gameController::Team::BLUE) { auto robot_primitive_executor = std::make_shared( - Duration::fromSeconds(primitive_executor_time_step_s), robot_constants, - TeamColour::BLUE, id); + Duration::fromSeconds(primitive_executor_time_step_s), robot_constants); blue_primitive_executor_map.insert({id, robot_primitive_executor}); } else { auto robot_primitive_executor = std::make_shared( - Duration::fromSeconds(primitive_executor_time_step_s), robot_constants, - TeamColour::YELLOW, id); + Duration::fromSeconds(primitive_executor_time_step_s), robot_constants); yellow_primitive_executor_map.insert({id, robot_primitive_executor}); } }