Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
42172bf
init merge
Andrewyx May 29, 2026
fa58f79
linting
Andrewyx May 29, 2026
1cd0268
remove auto test
Andrewyx May 29, 2026
aff8056
remove auto test
Andrewyx May 29, 2026
41df92c
test fixture fixes
Andrewyx May 29, 2026
a677125
test fixture fixes linting
Andrewyx May 29, 2026
4e4a2c4
tuning constants pid
Andrewyx May 29, 2026
cc994be
tuning constants pid
Andrewyx May 29, 2026
8639b2c
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] May 29, 2026
573dc74
removed old pid
Andrewyx May 29, 2026
060b704
Merge branch 'Andrewyx/robot_localizer' of github.com:Andrewyx/Softwa…
Andrewyx May 29, 2026
39d7d7b
tuning fixes
Thunderbots May 29, 2026
24a50ac
tuning fixes
Thunderbots May 29, 2026
acedc5a
refactor and localizer fixes
Andrewyx May 31, 2026
244f17c
sim tests
Andrewyx Jun 2, 2026
96c20c1
linting
Andrewyx Jun 2, 2026
1bd2cd9
test fixes
Andrewyx Jun 2, 2026
4b62eae
more euclid change
Andrewyx Jun 2, 2026
9335cb7
more euclid change
Andrewyx Jun 2, 2026
d1f3efb
temporary fix for ai vs ai
nycrat Jun 3, 2026
6e0bc08
reseting
Andrewyx Jun 4, 2026
9c35caf
Merge branch 'Andrewyx/robot_localizer' of github.com:Andrewyx/Softwa…
Andrewyx Jun 4, 2026
f09c6f2
Merge branch 'master' of github.com:UBC-Thunderbots/Software into And…
Andrewyx Jun 5, 2026
810eae0
Merge branch 'master' of github.com:UBC-Thunderbots/Software into And…
Andrewyx Jun 7, 2026
5b3c06c
merged
Andrewyx Jun 10, 2026
f1321f6
Merge master into Andrewyx/robot_localizer
Andrewyx Jun 12, 2026
c13928f
pid
Andrewyx Jun 12, 2026
57f787c
localizer
Andrewyx Jun 12, 2026
9eb4d05
test fixes
Andrewyx Jun 13, 2026
9c8e12f
bugs fixed
Andrewyx Jun 14, 2026
bc13c3c
linting
Andrewyx Jun 14, 2026
3f0e37f
Merge branch 'master' of github.com:UBC-Thunderbots/Software into And…
Andrewyx Jun 14, 2026
66b994a
flags added
Andrewyx Jun 14, 2026
88afd0b
linting
Andrewyx Jun 14, 2026
3821ee2
renamed motors
Andrewyx Jun 14, 2026
ea757d1
prim
Andrewyx Jun 15, 2026
9fc91ad
Merge branch 'master' of github.com:UBC-Thunderbots/Software into And…
Andrewyx Jun 15, 2026
83e8911
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jun 15, 2026
e7cea8a
localizer tests
Andrewyx Jun 16, 2026
9fd5abb
merged
Andrewyx Jun 16, 2026
7f2ceae
merge fixes
Andrewyx Jun 16, 2026
39a2c16
pi values
Thunderbots Jun 16, 2026
e870f9a
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jun 16, 2026
6957006
breakout
Andrewyx Jun 17, 2026
80148f1
linting
Andrewyx Jun 17, 2026
bddca1e
Merge branch 'master' of github.com:UBC-Thunderbots/Software into And…
Andrewyx Jun 17, 2026
11d2689
removed unrelated changes
Andrewyx Jun 17, 2026
325aa27
removed unrelated changes
Andrewyx Jun 17, 2026
907725a
removed unrelated changes
Andrewyx Jun 17, 2026
bc73a47
Merge branch 'master' of github.com:UBC-Thunderbots/Software into And…
Andrewyx Jun 17, 2026
18c3d92
reverts
Andrewyx Jun 17, 2026
b2d8adb
limits added
Andrewyx Jun 18, 2026
214ae7e
cleanup
Andrewyx Jun 18, 2026
fac4b71
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jun 18, 2026
c0f17b7
enable i2c
Andrewyx Jun 19, 2026
fac14bb
Merge branch 'Andrewyx/robot_localizer' of github.com:Andrewyx/Softwa…
Andrewyx Jun 19, 2026
44c311d
Implement new SPI protocol with message delimiting and acknowledgements
williamckha Jun 20, 2026
4378009
Merge branch 'master' of https://github.com/UBC-Thunderbots/Software …
Thunderbots Jun 20, 2026
3216e59
Merge branch 'william/new_spi_protocol' of https://github.com/UBC-Thu…
Thunderbots Jun 20, 2026
d15fcad
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jun 20, 2026
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
16 changes: 8 additions & 8 deletions src/proto/message_translation/tbots_protobuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ std::unique_ptr<TbotsProto::CostVisualization> createCostVisualization(
}

std::optional<TrajectoryPath> createTrajectoryPathFromParams(
const TbotsProto::TrajectoryPathParams2D& params, const Vector& initial_velocity,
const TbotsProto::TrajectoryPathParams2D& params, const Point& start_position,
const Vector& initial_velocity,
const robot_constants::RobotConstants& robot_constants)
{
double max_speed = convertMaxAllowedSpeedModeToMaxAllowedSpeed(
Expand All @@ -449,8 +450,7 @@ std::optional<TrajectoryPath> createTrajectoryPathFromParams(
}

auto trajectory = std::make_shared<BangBangTrajectory2D>(
createPoint(params.start_position()), initial_destination, initial_velocity,
constraints);
start_position, initial_destination, initial_velocity, constraints);

TrajectoryPath trajectory_path(trajectory, BangBangTrajectory2D::generator);

Expand All @@ -475,14 +475,14 @@ std::optional<TrajectoryPath> createTrajectoryPathFromParams(
}

BangBangTrajectory1DAngular createAngularTrajectoryFromParams(
const TbotsProto::TrajectoryParamsAngular1D& params,
const TbotsProto::TrajectoryParamsAngular1D& params, const Angle& start_angle,
const AngularVelocity& initial_velocity,
const robot_constants::RobotConstants& robot_constants)
{
return BangBangTrajectory1DAngular(
createAngle(params.start_angle()), createAngle(params.final_angle()),
initial_velocity,
AngularVelocity::fromRadians(robot_constants.robot_max_ang_speed_rad_per_s),
start_angle, createAngle(params.final_angle()), initial_velocity,
AngularVelocity::fromRadians(
robot_constants.robot_max_ang_speed_trajectory_rad_per_s),
AngularVelocity::fromRadians(
robot_constants.robot_max_ang_acceleration_rad_per_s_2),
AngularVelocity::fromRadians(
Expand Down Expand Up @@ -513,7 +513,7 @@ double convertMaxAllowedSpeedModeToMaxAllowedSpeed(
switch (max_allowed_speed_mode)
{
case TbotsProto::MaxAllowedSpeedMode::PHYSICAL_LIMIT:
return robot_constants.robot_max_speed_m_per_s;
return robot_constants.robot_max_speed_trajectory_m_per_s;
case TbotsProto::MaxAllowedSpeedMode::STOP_COMMAND:
return STOP_COMMAND_ROBOT_MAX_SPEED_METERS_PER_SECOND -
STOP_COMMAND_SPEED_SAFETY_MARGIN_METERS_PER_SECOND;
Expand Down
11 changes: 7 additions & 4 deletions src/proto/message_translation/tbots_protobuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,25 +238,28 @@ std::unique_ptr<TbotsProto::CostVisualization> createCostVisualization(
* Generate a 2D Trajectory Path given 2D trajectory parameters
*
* @param params 2D Trajectory Path
* @param start_position Initial position to use for the trajectory
* @param initial_velocity Initial velocity to use for the trajectory
* @param robot_constants Constants to use for the trajectory
* @return TrajectoryPath, or std::nullopt if the trajectory path could not be created
* from the given parameters
*/
std::optional<TrajectoryPath> createTrajectoryPathFromParams(
const TbotsProto::TrajectoryPathParams2D& params, const Vector& initial_velocity,
const TbotsProto::TrajectoryPathParams2D& params, const Point& start_position,
const Vector& initial_velocity,
const robot_constants::RobotConstants& robot_constants);

/**
* Generate an angular trajectory Path given angular trajectory proto parameters
* Generate an angular trajectory path given angular trajectory proto parameters
*
* @param params angular Trajectory Path
* @param params Angular trajectory path
* @param start_angle Initial angle to use for the trajectory
* @param initial_velocity Initial velocity to use for the trajectory
* @param robot_constants Constants to use for the trajectory
* @return Generate angular trajectory
*/
BangBangTrajectory1DAngular createAngularTrajectoryFromParams(
const TbotsProto::TrajectoryParamsAngular1D& params,
const TbotsProto::TrajectoryParamsAngular1D& params, const Angle& start_angle,
const AngularVelocity& initial_velocity,
const robot_constants::RobotConstants& robot_constants);

Expand Down
4 changes: 2 additions & 2 deletions src/proto/message_translation/tbots_protobuf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ TEST_P(TrajectoryParamConversionTest, trajectory_params_msg_test)
*(params.add_sub_destinations()) = sub_destination_proto;
}

auto converted_trajectory_path_opt =
createTrajectoryPathFromParams(params, initial_velocity, robot_constants);
auto converted_trajectory_path_opt = createTrajectoryPathFromParams(
params, createPoint(params.start_position()), initial_velocity, robot_constants);
ASSERT_TRUE(converted_trajectory_path_opt.has_value());

TrajectoryPath converted_trajectory_path = converted_trajectory_path_opt.value();
Expand Down
3 changes: 3 additions & 0 deletions src/shared/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ static const unsigned THUNDERLOOP_HZ = 300u;

static const unsigned NUM_GENEVA_ANGLES = 5;


static constexpr double RTT_S = 0.03;

// Robot diagnostics constants
constexpr double AUTO_CHIP_DISTANCE_DEFAULT_M = 1.5;
constexpr double AUTO_KICK_SPEED_DEFAULT_M_PER_S = 1.5;
Expand Down
86 changes: 58 additions & 28 deletions src/shared/robot_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ struct RobotConstants
// The angles are assumed to be symmetric for the left and right sides of the robot.
//
// FRONT OF ROBOT
// | ▲ X-Axis
// | / -------+--------- \ eric
// |A / .' │ '. \ ◄─── Front wheel
// | /.' │ .'.\ grayson
// |// │ . \\ samuel
// ; │ . Lever ;
// | │ . Arm |
// ◄─────┼──────────────┼ |
// Y-Axis| |
// ; ;
// |\\ //
// | \'. .'/
// |B \ '. .' / ◄─── Back wheel
// | \ '-. _.-' /
// | ''------''
// | ▲ X-Axis //
// | / -------+--------- \ //
// |A / .' │ '. \ ◄─── Front wheel //
// | /.' │ .'.\ //
// |// │ . |\ //
// ; │ . Lever ; //
// | │ . Arm | //
// ◄─────┼──────────────┼ | //
// Y-Axis| | //
// ; ; //
// |\\ // //
// | \'. .'/ //
// |B \ '. .' / ◄─── Back wheel //
// | \ '-. _.-' / //
// | ''------'' //

// clang-format on

Expand Down Expand Up @@ -88,6 +88,10 @@ struct RobotConstants
// The maximum speed achievable by our robots, in metres per second [m/s]
float robot_max_speed_m_per_s;

// The maximum speed that the trajectory planner is allowed to command the robot to
// move at, while still leaving headroom for the PID to apply correction on lag. [m/s]
float robot_max_speed_trajectory_m_per_s;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo robot_trajectory_max_speed_m_per_s is a clearer naming.


// The maximum acceleration achievable by our robots [m/s^2]
float robot_max_acceleration_m_per_s_2;

Expand All @@ -97,6 +101,11 @@ struct RobotConstants
// The maximum angular speed achievable by our robots [rad/s]
float robot_max_ang_speed_rad_per_s;

// The maximum speed that the trajectory planner is allowed to command the robot to
// move at, while still leaving headroom for the PID to apply correction on lag.
// [rad/s]
float robot_max_ang_speed_trajectory_rad_per_s;

// The maximum angular acceleration achievable by our robots [rad/s^2]
float robot_max_ang_acceleration_rad_per_s_2;

Expand All @@ -107,6 +116,13 @@ struct RobotConstants
// Found by sqrt(x^2 + y^2) of a wheel.
// Front wheel arm = Rear wheel arm. See ASCII image above.
float expected_lever_arm;

// Various variances for the robot localizer
float kalman_process_noise_variance_rad_per_s_4;

float kalman_vision_noise_variance_rad_2;

float kalman_motor_sensor_noise_variance_rad_per_s_2;
};

/**
Expand All @@ -120,7 +136,7 @@ constexpr RobotConstants createRobotConstants()
return {
.robot_radius_m = static_cast<float>(ROBOT_MAX_RADIUS_METERS),
.front_wheel_angle_deg = 32.0f,
.back_wheel_angle_deg = 44.0f,
.back_wheel_angle_deg = 46.0f,

.fr_x_pos_meters = 0.03485f,
.fr_y_pos_meters = -0.06632f,
Expand All @@ -142,17 +158,24 @@ constexpr RobotConstants createRobotConstants()
.motor_max_acceleration_m_per_s_2 = 2.0f,

// Robot's linear movement constants
.robot_max_speed_m_per_s = 3.0f,
.robot_max_acceleration_m_per_s_2 = 3.0f,
.robot_max_deceleration_m_per_s_2 = 3.0f,
.robot_max_speed_m_per_s = 3.0f,
.robot_max_speed_trajectory_m_per_s = 2.5f,
.robot_max_acceleration_m_per_s_2 = 2.0f,
.robot_max_deceleration_m_per_s_2 = 1.5f,

// Robot's angular movement constants
.robot_max_ang_speed_rad_per_s = 10.0f,
.robot_max_ang_acceleration_rad_per_s_2 = 30.0f,
.robot_max_ang_speed_rad_per_s = 6.0f,
.robot_max_ang_speed_trajectory_rad_per_s = 5.0f,
.robot_max_ang_acceleration_rad_per_s_2 = 10.0f,

.wheel_radius_meters = 0.03f,

.expected_lever_arm = 0.0749f};
.expected_lever_arm = 0.0749f,

// Kalman filter variances for robot localizer
.kalman_process_noise_variance_rad_per_s_4 = 1.0f,
.kalman_vision_noise_variance_rad_2 = 0.01f * 0.01f,
.kalman_motor_sensor_noise_variance_rad_per_s_2 = 0.5};
}
#elif CHECK_VERSION(2021)
constexpr RobotConstants createRobotConstants()
Expand All @@ -173,15 +196,22 @@ constexpr RobotConstants createRobotConstants()
.motor_max_acceleration_m_per_s_2 = 4.5f,

// Robot's linear movement constants
.robot_max_speed_m_per_s = 3.000f,
.robot_max_acceleration_m_per_s_2 = 3.0f,
.robot_max_deceleration_m_per_s_2 = 3.0f,
.robot_max_speed_m_per_s = 3.000f,
.robot_max_speed_trajectory_m_per_s = 3.000f,
.robot_max_acceleration_m_per_s_2 = 3.0f,
.robot_max_deceleration_m_per_s_2 = 3.0f,

// Robot's angular movement constants
.robot_max_ang_speed_rad_per_s = 10.0f,
.robot_max_ang_acceleration_rad_per_s_2 = 30.0f,
.robot_max_ang_speed_rad_per_s = 10.0f,
.robot_max_ang_speed_trajectory_rad_per_s = 7.0f,
.robot_max_ang_acceleration_rad_per_s_2 = 30.0f,

.wheel_radius_meters = 0.03f,

.wheel_radius_meters = 0.03f};
// Kalman filter variances for robot localizer
Comment thread
Andrewyx marked this conversation as resolved.
.kalman_process_noise_variance_rad_per_s_4 = 0.5f,
.kalman_vision_noise_variance_rad_2 = 0.01f * 0.01f,
.kalman_motor_sensor_noise_variance_rad_per_s_2 = 0.5f * 0.5f};
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/software/ai/evaluation/intercept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Point findOvershootInterceptPosition(const Robot& robot, const Point intercept_p
Point best_position = intercept_position;
double final_speed = step_speed;
bool finished = false;
double max_speed = robot.robotConstants().robot_max_speed_m_per_s;
double max_speed = robot.robotConstants().robot_max_speed_trajectory_m_per_s;
double max_acc = robot.robotConstants().robot_max_acceleration_m_per_s_2;

while (!finished)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def run_ball_placement_scenario(
inv_eventually_validation_sequence_set=placement_eventually_validation_sequence_set,
ag_always_validation_sequence_set=[[]],
ag_eventually_validation_sequence_set=placement_eventually_validation_sequence_set,
test_timeout_s=[15],
test_timeout_s=15,
)

simulated_test_runner.run_test(
Expand All @@ -209,7 +209,7 @@ def run_ball_placement_scenario(
inv_eventually_validation_sequence_set=drop_ball_eventually_validation_sequence_set,
ag_always_validation_sequence_set=drop_ball_always_validation_sequence_set,
ag_eventually_validation_sequence_set=drop_ball_eventually_validation_sequence_set,
test_timeout_s=[5],
test_timeout_s=5,
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import threading

import software.python_bindings as tbots_cpp
from proto.play_pb2 import PlayName

Expand Down Expand Up @@ -57,14 +55,6 @@ def setup(*args):
gc_command=Command.Type.KICKOFF, team=Team.YELLOW
)

# Let robots get ready before starting kickoff
threading.Timer(
4.0,
lambda: simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.NORMAL_START, team=Team.YELLOW
),
).start()

simulated_test_runner.set_plays(
blue_play=PlayName.KickoffEnemyPlay,
yellow_play=PlayName.KickoffFriendlyPlay,
Expand Down Expand Up @@ -145,6 +135,9 @@ def setup(*args):
ag_eventually_validation_sequence_set=eventually_validation_sequence_set,
ag_always_validation_sequence_set=always_validation_sequence_set,
test_timeout_s=10,
ci_cmd_with_delay=[
(4.0, Command.Type.NORMAL_START, Team.YELLOW),
],
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void KickoffFriendlyPlayFSM::createKickoffSetupPositions(const WorldPtr& world_p
kickoff_setup_positions = {
// Robot 1
Point(world_ptr->field().centerPoint() +
Vector(-world_ptr->field().centerCircleRadius(), 0)),
Vector(-0.95 * world_ptr->field().centerCircleRadius(), 0)),
Comment thread
Andrewyx marked this conversation as resolved.
Outdated
// Robot 2
// Goalie positions will be handled by the goalie tactic
// Robot 3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import threading

import software.python_bindings as tbots_cpp
from proto.play_pb2 import PlayName

Expand Down Expand Up @@ -62,14 +60,6 @@ def setup(*args):
gc_command=Command.Type.KICKOFF, team=Team.BLUE
)

# Let robots get ready before starting kickoff
threading.Timer(
4.0,
lambda: simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.NORMAL_START, team=Team.BLUE
),
).start()

simulated_test_runner.set_plays(
blue_play=PlayName.KickoffFriendlyPlay,
yellow_play=PlayName.KickoffEnemyPlay,
Expand Down Expand Up @@ -145,6 +135,9 @@ def setup(*args):
ag_eventually_validation_sequence_set=eventually_validation_sequence_set,
ag_always_validation_sequence_set=always_validation_sequence_set,
test_timeout_s=10,
ci_cmd_with_delay=[
(4.0, Command.Type.NORMAL_START, Team.BLUE),
],
)


Expand Down
2 changes: 1 addition & 1 deletion src/software/ai/hl/stp/tactic/move_primitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MovePrimitive::MovePrimitive(
angular_trajectory.generate(
robot.orientation(), final_angle, robot.angularVelocity(),
AngularVelocity::fromRadians(
robot.robotConstants().robot_max_ang_speed_rad_per_s),
robot.robotConstants().robot_max_ang_speed_trajectory_rad_per_s),
AngularVelocity::fromRadians(
robot.robotConstants().robot_max_ang_acceleration_rad_per_s_2),
AngularVelocity::fromRadians(
Expand Down
1 change: 1 addition & 0 deletions src/software/ai/navigator/trajectory/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cc_library(
deps = [
":trajectory",
"//software/geom:point",
"//software/geom/algorithms",
],
)

Expand Down
14 changes: 14 additions & 0 deletions src/software/ai/navigator/trajectory/bang_bang_trajectory_1d.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <array>
#include <cmath>
#include <cstddef>

#include "software/ai/navigator/trajectory/trajectory.hpp"
Expand Down Expand Up @@ -103,6 +104,19 @@ class BangBangTrajectory1D : public Trajectory<double, double, double>
*/
size_t getNumTrajectoryParts() const;

/**
* Check if this trajectory is meaningfully different from another trajectory.
* @param other The other trajectory to compare to
* @param threshold The threshold above which the trajectories are considered
* different
* @return True if the trajectories are different, false otherwise
*/
bool isNew(const Trajectory<double, double, double>& other,
Comment thread
Andrewyx marked this conversation as resolved.
Outdated
double threshold) const override
{
return std::abs(getDestination() - other.getDestination()) > threshold;
}

private:
/**
* Generate a trapezoidal trajectory and fill in `trajectory_parts`.
Expand Down
Loading
Loading