Skip to content

Commit e47756d

Browse files
Shrunk robot radius (UBC-Thunderbots#3544)
* Shrunk robot radius * [pre-commit.ci lite] apply automatic fixes * Add explanation of why field radius is shrunk Added comment to clarify field boundary adjustment for robot movement. * make radius shrink only applied when in a game * fix rectangle initialization issue by using tenary instead * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 0fdcf5b commit e47756d

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/software/ai/hl/stp/tactic/move_primitive.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "software/ai/hl/stp/tactic/move_primitive.h"
22

3+
#include <cmath>
4+
35
#include "proto/message_translation/tbots_geometry.h"
46
#include "proto/message_translation/tbots_protobuf.h"
57
#include "proto/primitive/primitive_msg_factory.h"
@@ -63,9 +65,17 @@ MovePrimitive::generatePrimitiveProtoMessage(
6365
max_speed, robot.robotConstants().robot_max_acceleration_m_per_s_2,
6466
robot.robotConstants().robot_max_deceleration_m_per_s_2);
6567

66-
// TODO (#3104): The fieldBounary should be shrunk by the robot radius before being
67-
// passed to the planner.
68-
Rectangle navigable_area = world.field().fieldBoundary();
68+
// Shrink the field by the radius of robot to ensure robot don't go out of bounds, if
69+
// we are in a game Return normal field boundaries if not in a game
70+
Rectangle field_boundary = world.field().fieldBoundary();
71+
72+
double shrink_amount = world.gameState().isPlaying() ? ROBOT_MAX_RADIUS_METERS : 0.0;
73+
Point neg_x_neg_y_corner(field_boundary.negXNegYCorner().x() + shrink_amount,
74+
field_boundary.negXNegYCorner().y() + shrink_amount);
75+
Point pos_x_pos_y_corner(field_boundary.posXPosYCorner().x() - shrink_amount,
76+
field_boundary.posXPosYCorner().y() - shrink_amount);
77+
Rectangle navigable_area = Rectangle(neg_x_neg_y_corner, pos_x_pos_y_corner);
78+
6979

7080
// If the robot is in a static obstacle, then we should first move to the nearest
7181
// point out

0 commit comments

Comments
 (0)