Skip to content

Commit d84d48c

Browse files
[pre-commit.ci lite] apply automatic fixes
1 parent c3087d7 commit d84d48c

7 files changed

Lines changed: 46 additions & 38 deletions

File tree

src/shared/robot_constants.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ RobotConstants createRobotConstants()
2626
.dribbler_width_meters = 0.07825f,
2727

2828
// Dribbler speeds are negative as that is the direction that sucks the ball in
29-
.indefinite_dribbler_speed_rpm = -10000,
30-
.max_force_dribbler_speed_rpm = -6000,
29+
.indefinite_dribbler_speed_rpm = -10000,
30+
.max_force_dribbler_speed_rpm = -6000,
3131
.release_ball_dribbler_speed_rpm = 0,
3232

3333
// Motor constant
3434
.motor_max_acceleration_m_per_s_2 = 8.0f,
3535

3636
// Robot's linear movement constants
37-
.robot_max_speed_m_per_s = 5.0f,
37+
.robot_max_speed_m_per_s = 5.0f,
3838
.ball_placement_wall_max_speed_m_per_s = 0.3f,
3939
.ball_placement_retreat_max_speed_m_per_s = 0.3f,
4040
.dribble_speed_m_per_s = 1.5f,
41-
.robot_trajectory_max_speed_m_per_s = 3.5f,
41+
.robot_trajectory_max_speed_m_per_s = 3.5f,
4242

4343
.robot_max_acceleration_m_per_s_2 = 4.0f,
4444
.robot_max_deceleration_m_per_s_2 = 4.0f,

src/software/ai/navigator/trajectory/jerk_limited_trajectory_1d.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,20 @@ void JerkLimitedTrajectory1D::generate(const double initial_pos, const double fi
3737
return;
3838
}
3939

40-
// Note: if we are already at the target but still moving, we intentionally do not stop
41-
// here. Doing so would leave the robot wherever its momentum carries it rather than at
42-
// the destination. Instead we fall through to the logic below, which will overshoot the
43-
// target and then plan a trajectory back to it.
40+
// Note: if we are already at the target but still moving, we intentionally do not
41+
// stop here. Doing so would leave the robot wherever its momentum carries it rather
42+
// than at the destination. Instead we fall through to the logic below, which will
43+
// overshoot the target and then plan a trajectory back to it.
4444

4545
// Ramp the initial acceleration to zero via a preliminary jerk phase, then plan the
4646
// rest of the trajectory from that zero-acceleration state. The 2D layer feeds the
4747
// robot's actual (unscaled) initial acceleration into each axis while scaling the
48-
// per-axis acceleration/jerk limits, so the initial acceleration can exceed or conflict
49-
// with those limits. The planning primitives below (planAccelProfile, planDecelToStop,
50-
// planDecelToSpeed) are only well-defined for a zero initial acceleration; feeding them
51-
// an out-of-range initial acceleration produces inconsistent profiles (e.g. negative
52-
// phase durations) that fail to reach the destination.
48+
// per-axis acceleration/jerk limits, so the initial acceleration can exceed or
49+
// conflict with those limits. The planning primitives below (planAccelProfile,
50+
// planDecelToStop, planDecelToSpeed) are only well-defined for a zero initial
51+
// acceleration; feeding them an out-of-range initial acceleration produces
52+
// inconsistent profiles (e.g. negative phase durations) that fail to reach the
53+
// destination.
5354
double t = 0.0, p = 0.0, v = initial_vel, a = initial_accel;
5455
if (std::abs(a) > EPSILON)
5556
{
@@ -492,12 +493,12 @@ void JerkLimitedTrajectory1D::generateDirect(
492493

493494
// Plan the phase that brings the robot from its initial velocity to signed_peak. We
494495
// accelerate if the peak is above the initial speed, but decelerate if the initial
495-
// speed already exceeds the peak (which happens when a scaled 2D axis velocity limit is
496-
// smaller than the robot's initial speed component along that axis). Previously this
497-
// always used planAccelProfile, which returns an empty plan when the initial speed is
498-
// already above the peak. The robot would then never slow down to the cruise speed, so
499-
// the cruise/deceleration distances were computed for the peak speed while the robot
500-
// was actually travelling faster, causing it to overshoot the destination.
496+
// speed already exceeds the peak (which happens when a scaled 2D axis velocity limit
497+
// is smaller than the robot's initial speed component along that axis). Previously
498+
// this always used planAccelProfile, which returns an empty plan when the initial
499+
// speed is already above the peak. The robot would then never slow down to the cruise
500+
// speed, so the cruise/deceleration distances were computed for the peak speed while
501+
// the robot was actually travelling faster, causing it to overshoot the destination.
501502
auto planToPeak = [&](const double signed_peak)
502503
{
503504
if (std::abs(signed_peak) >= std::abs(initial_vel))

src/software/ai/navigator/trajectory/jerk_limited_trajectory_1d.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class JerkLimitedTrajectory1D : public Trajectory<double, double, double>
5858
// Decelerate from the initial speed down to a lower target speed (in the same
5959
// direction of travel as initial_vel). This is the mirror of planAccelProfile for the
6060
// case where the initial speed already exceeds the desired peak/cruise speed, which
61-
// can happen when a 2D axis limit is scaled below the robot's initial speed component.
61+
// can happen when a 2D axis limit is scaled below the robot's initial speed
62+
// component.
6263
static AccelPlan planDecelToSpeed(double initial_vel, double initial_accel,
6364
double target_speed, double max_jerk,
6465
double min_jerk, double max_decel);

src/software/embedded/motion_control/position_controller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class PositionController : public MotionController<Point, TrajectoryPath, Vector
2828
*
2929
* @param config The PID gains to use for the underlying x/y PID controllers.
3030
*/
31-
explicit PositionController(const PositionControllerConfig& config = PositionControllerConfig());
31+
explicit PositionController(
32+
const PositionControllerConfig& config = PositionControllerConfig());
3233

3334
/**
3435
* Given a position and target trajectory, returns a target global velocity to

src/software/embedded/primitive_executor.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,14 @@ Vector PrimitiveExecutor::stepTargetLinearVelocity(const Duration& delta_time)
349349
// {"target_pos_y", target_position.y()},
350350
// {"target_vel_x", target_v_global.x()},
351351
// {"target_vel_y", target_v_global.y()},
352-
// {"actual_pos_x", state_.position().x()},
353-
// {"actual_pos_y", state_.position().y()},
354-
// {"actual_vel_x", state_.velocity().x()},
355-
// {"actual_vel_y", state_.velocity().y()},
352+
// {"actual_pos_x",
353+
// state_.position().x()},
354+
// {"actual_pos_y",
355+
// state_.position().y()},
356+
// {"actual_vel_x",
357+
// state_.velocity().x()},
358+
// {"actual_vel_y",
359+
// state_.velocity().y()},
356360
// {"traj_vel_x", target_velocity.x()},
357361
// {"traj_vel_y", target_velocity.y()}});
358362

src/software/embedded/thunderloop.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ Thunderloop::Thunderloop(const robot_constants::RobotConstants& robot_constants,
8484
primitive_executor_(
8585
robot_constants,
8686
PositionControllerConfig{
87-
std::stod(toml_config_client_->get(
88-
ROBOT_POSITION_CONTROLLER_KP_CONFIG_KEY)),
89-
std::stod(toml_config_client_->get(
90-
ROBOT_POSITION_CONTROLLER_KI_CONFIG_KEY)),
91-
std::stod(toml_config_client_->get(
92-
ROBOT_POSITION_CONTROLLER_KD_CONFIG_KEY)),
87+
std::stod(
88+
toml_config_client_->get(ROBOT_POSITION_CONTROLLER_KP_CONFIG_KEY)),
89+
std::stod(
90+
toml_config_client_->get(ROBOT_POSITION_CONTROLLER_KI_CONFIG_KEY)),
91+
std::stod(
92+
toml_config_client_->get(ROBOT_POSITION_CONTROLLER_KD_CONFIG_KEY)),
9393
std::stod(toml_config_client_->get(
9494
ROBOT_POSITION_CONTROLLER_MAX_INTEGRAL_CONFIG_KEY))},
9595
OrientationControllerConfig{
96-
std::stod(toml_config_client_->get(
97-
ROBOT_ORIENTATION_CONTROLLER_KP_CONFIG_KEY)),
98-
std::stod(toml_config_client_->get(
99-
ROBOT_ORIENTATION_CONTROLLER_KI_CONFIG_KEY)),
100-
std::stod(toml_config_client_->get(
101-
ROBOT_ORIENTATION_CONTROLLER_KD_CONFIG_KEY)),
96+
std::stod(
97+
toml_config_client_->get(ROBOT_ORIENTATION_CONTROLLER_KP_CONFIG_KEY)),
98+
std::stod(
99+
toml_config_client_->get(ROBOT_ORIENTATION_CONTROLLER_KI_CONFIG_KEY)),
100+
std::stod(
101+
toml_config_client_->get(ROBOT_ORIENTATION_CONTROLLER_KD_CONFIG_KEY)),
102102
std::stod(toml_config_client_->get(
103103
ROBOT_ORIENTATION_CONTROLLER_MAX_INTEGRAL_CONFIG_KEY))}),
104104
robot_localizer_(RobotLocalizer::RobotLocalizerConfig{

src/software/embedded/toml_config/toml_config_client.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ void TomlConfigClient::writeConfig()
8989
has_pending_changes_ = false;
9090
}
9191

92-
std::string TomlConfigClient::get(const std::string& key, const std::string& default_value)
92+
std::string TomlConfigClient::get(const std::string& key,
93+
const std::string& default_value)
9394
{
9495
std::lock_guard<std::mutex> lock(config_mutex_);
9596

0 commit comments

Comments
 (0)