Skip to content

Commit e0db5b2

Browse files
authored
Clean up robot constants and make them selectable at compile time (#3714)
1 parent 2f009bb commit e0db5b2

43 files changed

Lines changed: 266 additions & 264 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ build --cxxopt="-DG3_DYNAMIC_LOGGING"
7575
build --per_file_copt=.*\.pb\.(h|cc|cpp)$@-w
7676
build --per_file_copt=./external/.*,./bazel-out/.*@-w
7777

78+
# Define Robot Versions
79+
build --copt="-DCURRENT_ROBOT_VERSION=2026"
80+
7881
############## External Deps Compatibility ##############
7982
build --noincompatible_disallow_ctx_resolve_tools
8083
build --check_direct_dependencies=off

src/proto/message_translation/ssl_simulation_robot_control.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ std::unique_ptr<SSLSimulationProto::RobotMoveCommand> createRobotMoveCommand(
5252
std::unique_ptr<SSLSimulationProto::RobotCommand> getRobotCommandFromDirectControl(
5353
unsigned int robot_id,
5454
std::unique_ptr<TbotsProto::DirectControlPrimitive> direct_control,
55-
RobotConstants_t& robot_constants)
55+
robot_constants::RobotConstants& robot_constants)
5656
{
5757
auto move_command = createRobotMoveCommand(
5858
*direct_control, robot_constants.front_wheel_angle_deg,

src/proto/message_translation/ssl_simulation_robot_control.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ std::unique_ptr<SSLSimulationProto::RobotMoveCommand> createRobotMoveCommand(
3434
std::unique_ptr<SSLSimulationProto::RobotCommand> getRobotCommandFromDirectControl(
3535
unsigned int robot_id,
3636
std::unique_ptr<TbotsProto::DirectControlPrimitive> direct_control,
37-
RobotConstants_t& robot_constants);
37+
robot_constants::RobotConstants& robot_constants);
3838

3939
/**
4040
* Creates a RobotCommand proto

src/proto/message_translation/ssl_simulation_robot_control_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
#include <gtest/gtest.h>
44

5-
#include "shared/2021_robot_constants.h"
5+
#include "shared/robot_constants.h"
66

77
class SSLSimulationProtoTest : public ::testing::Test
88
{
99
protected:
10-
RobotConstants_t robot_constants = create2021RobotConstants();
10+
robot_constants::RobotConstants robot_constants =
11+
robot_constants::createRobotConstants();
1112
};
1213

1314
TEST_F(SSLSimulationProtoTest, test_create_robot_move_command_forward_from_primitive)

src/proto/message_translation/tbots_protobuf.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ std::unique_ptr<TbotsProto::CostVisualization> createCostVisualization(
426426

427427
std::optional<TrajectoryPath> createTrajectoryPathFromParams(
428428
const TbotsProto::TrajectoryPathParams2D& params, const Vector& initial_velocity,
429-
const RobotConstants& robot_constants)
429+
const robot_constants::RobotConstants& robot_constants)
430430
{
431431
double max_speed = convertMaxAllowedSpeedModeToMaxAllowedSpeed(
432432
params.max_speed_mode(), robot_constants);
@@ -476,7 +476,8 @@ std::optional<TrajectoryPath> createTrajectoryPathFromParams(
476476

477477
BangBangTrajectory1DAngular createAngularTrajectoryFromParams(
478478
const TbotsProto::TrajectoryParamsAngular1D& params,
479-
const AngularVelocity& initial_velocity, const RobotConstants& robot_constants)
479+
const AngularVelocity& initial_velocity,
480+
const robot_constants::RobotConstants& robot_constants)
480481
{
481482
return BangBangTrajectory1DAngular(
482483
createAngle(params.start_angle()), createAngle(params.final_angle()),
@@ -489,7 +490,7 @@ BangBangTrajectory1DAngular createAngularTrajectoryFromParams(
489490
}
490491

491492
int convertDribblerModeToDribblerSpeed(TbotsProto::DribblerMode dribbler_mode,
492-
RobotConstants_t robot_constants)
493+
robot_constants::RobotConstants robot_constants)
493494
{
494495
switch (dribbler_mode)
495496
{
@@ -507,7 +508,7 @@ int convertDribblerModeToDribblerSpeed(TbotsProto::DribblerMode dribbler_mode,
507508

508509
double convertMaxAllowedSpeedModeToMaxAllowedSpeed(
509510
TbotsProto::MaxAllowedSpeedMode max_allowed_speed_mode,
510-
RobotConstants_t robot_constants)
511+
robot_constants::RobotConstants robot_constants)
511512
{
512513
switch (max_allowed_speed_mode)
513514
{

src/proto/message_translation/tbots_protobuf.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ std::unique_ptr<TbotsProto::CostVisualization> createCostVisualization(
245245
*/
246246
std::optional<TrajectoryPath> createTrajectoryPathFromParams(
247247
const TbotsProto::TrajectoryPathParams2D& params, const Vector& initial_velocity,
248-
const RobotConstants& robot_constants);
248+
const robot_constants::RobotConstants& robot_constants);
249249

250250
/**
251251
* Generate an angular trajectory Path given angular trajectory proto parameters
@@ -257,7 +257,8 @@ std::optional<TrajectoryPath> createTrajectoryPathFromParams(
257257
*/
258258
BangBangTrajectory1DAngular createAngularTrajectoryFromParams(
259259
const TbotsProto::TrajectoryParamsAngular1D& params,
260-
const AngularVelocity& initial_velocity, const RobotConstants& robot_constants);
260+
const AngularVelocity& initial_velocity,
261+
const robot_constants::RobotConstants& robot_constants);
261262

262263
/**
263264
* Convert dribbler mode to dribbler speed
@@ -268,7 +269,7 @@ BangBangTrajectory1DAngular createAngularTrajectoryFromParams(
268269
* @return the dribbler speed in RPM
269270
*/
270271
int convertDribblerModeToDribblerSpeed(TbotsProto::DribblerMode dribbler_mode,
271-
RobotConstants_t robot_constants);
272+
robot_constants::RobotConstants robot_constants);
272273

273274
/**
274275
* Convert max allowed speed mode to max allowed speed
@@ -280,4 +281,4 @@ int convertDribblerModeToDribblerSpeed(TbotsProto::DribblerMode dribbler_mode,
280281
*/
281282
double convertMaxAllowedSpeedModeToMaxAllowedSpeed(
282283
TbotsProto::MaxAllowedSpeedMode max_allowed_speed_mode,
283-
RobotConstants_t robot_constants);
284+
robot_constants::RobotConstants robot_constants);

src/proto/message_translation/tbots_protobuf_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ TEST_P(TrajectoryParamConversionTest, trajectory_params_msg_test)
152152
// Generate a trajectory, and then generate a TbotsProto::TrajectoryPathParams2D
153153
// with the same parameters as the trajectory, finally, generate a second trajectory
154154
// from the parameters and make sure the two trajectories are equal.
155-
RobotConstants robot_constants = create2021RobotConstants();
155+
robot_constants::RobotConstants robot_constants =
156+
robot_constants::createRobotConstants();
156157
Point start_position(0.0, 0.0);
157158
Point destination(0.0, 0.0);
158159

src/proto/primitive/primitive_msg_factory_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
#include <gtest/gtest.h>
44

5-
#include "shared/2021_robot_constants.h"
65
#include "shared/constants.h"
6+
#include "shared/robot_constants.h"
77
#include "software/test_util/test_util.h"
88

99
class PrimitiveFactoryTest : public testing::Test
1010
{
1111
protected:
12-
RobotConstants_t robot_constants = create2021RobotConstants();
12+
robot_constants::RobotConstants robot_constants =
13+
robot_constants::createRobotConstants();
1314
};
1415

1516
TEST_F(PrimitiveFactoryTest, test_auto_chip_or_kick_equality)

src/shared/2021_robot_constants.cpp

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/shared/2021_robot_constants.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)