Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 2 additions & 17 deletions src/software/embedded/primitive_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand All @@ -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)
{
Expand Down Expand Up @@ -145,8 +135,3 @@ std::unique_ptr<TbotsProto::DirectControlPrimitive> PrimitiveExecutor::stepPrimi
}
return std::make_unique<TbotsProto::DirectControlPrimitive>();
}

void PrimitiveExecutor::setRobotId(const RobotId robot_id)
{
robot_id_ = robot_id;
}
19 changes: 1 addition & 18 deletions src/software/embedded/primitive_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,16 @@ 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
* @param primitive_msg The primitive to start
*/
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
*
Expand All @@ -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
Expand Down Expand Up @@ -81,15 +66,13 @@ class PrimitiveExecutor
Vector velocity_;
AngularVelocity angular_velocity_;
Angle orientation_;
TeamColour friendly_team_colour_;
robot_constants::RobotConstants robot_constants_;
std::optional<TrajectoryPath> trajectory_path_;
std::optional<BangBangTrajectory1DAngular> angular_trajectory_;

// 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;
Expand Down
7 changes: 3 additions & 4 deletions src/software/embedded/thunderloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <fstream>

#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"
Expand Down Expand Up @@ -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<TomlConfigClient>(TOML_CONFIG_FILE_PATH)),
motor_status_(std::nullopt),
robot_constants_(robot_constants),
Expand All @@ -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();

Expand Down Expand Up @@ -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_ =
Expand Down
6 changes: 2 additions & 4 deletions src/software/simulation/er_force_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,13 @@ void ErForceSimulator::setRobots(
if (side == gameController::Team::BLUE)
{
auto robot_primitive_executor = std::make_shared<PrimitiveExecutor>(
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<PrimitiveExecutor>(
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});
}
}
Expand Down
Loading