Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/proto/message_translation/er_force_world_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <gtest/gtest.h>

#include "software/geom/angular_velocity.h"
#include "software/test_util/test_util.h"


Expand Down Expand Up @@ -47,7 +48,7 @@ TEST(ErForceWorldTest, test_create_robot)
const Point expected_pos(sim_robot->p_x(), sim_robot->p_y());
const Vector expected_vel(sim_robot->v_x(), sim_robot->v_y());
RobotState expected_state(expected_pos, expected_vel, Angle::zero(),
Angle::fromRadians(5.0));
AngularVelocity::fromRadians(5.0));
EXPECT_EQ(0, test_robot.id());
EXPECT_TRUE(TestUtil::equalWithinTolerance(test_robot.currentState(), expected_state,
1e-6, Angle::fromDegrees(0)));
Expand Down
2 changes: 1 addition & 1 deletion src/proto/message_translation/tbots_geometry_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST(TbotsProtobufTest, point_msg_test)

TEST(TbotsProtobufTest, angular_velocity_msg_test)
{
auto angular_velocity = Angle::fromRadians(4.20);
auto angular_velocity = AngularVelocity::fromRadians(4.20);
auto angular_velocity_msg = createAngularVelocityProto(angular_velocity);

EXPECT_EQ(angular_velocity_msg->radians_per_second(), angular_velocity.toRadians());
Expand Down
5 changes: 3 additions & 2 deletions src/proto/message_translation/tbots_protobuf.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "proto/message_translation/tbots_protobuf.h"

#include "software/ai/navigator/trajectory/bang_bang_trajectory_1d_angular.h"
#include "software/geom/angular_acceleration.h"
#include "software/logger/logger.h"


Expand Down Expand Up @@ -482,9 +483,9 @@ BangBangTrajectory1DAngular createAngularTrajectoryFromParams(
createAngle(params.start_angle()), createAngle(params.final_angle()),
initial_velocity,
AngularVelocity::fromRadians(robot_constants.robot_max_ang_speed_rad_per_s),
AngularVelocity::fromRadians(
AngularAcceleration::fromRadians(
robot_constants.robot_max_ang_acceleration_rad_per_s_2),
AngularVelocity::fromRadians(
AngularAcceleration::fromRadians(
robot_constants.robot_max_ang_acceleration_rad_per_s_2));
}

Expand Down
2 changes: 1 addition & 1 deletion src/proto/message_translation/tbots_protobuf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ TEST(TbotsProtobufTest, robot_state_msg_test)
auto position = Point(4.20, 4.20);
auto velocity = Vector(4.20, 4.20);
auto orientation = Angle::fromRadians(4.20);
auto angular_velocity = Angle::fromRadians(4.20);
auto angular_velocity = AngularVelocity::fromRadians(4.20);

Robot robot(0, position, velocity, orientation, angular_velocity,
Timestamp::fromSeconds(0));
Expand Down
4 changes: 2 additions & 2 deletions src/software/ai/hl/stp/play/passing_sim_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def setup_pass_and_robots(
index,
location,
tbots_cpp.Vector(0.0, 0.0),
tbots_cpp.Angle.fromRadians(0),
tbots_cpp.Angle(),
tbots_cpp.AngularVelocity(),
tbots_cpp.Timestamp(),
)
for index, location in enumerate(blue_robot_locations)
Expand All @@ -80,8 +80,8 @@ def setup_pass_and_robots(
index,
location,
tbots_cpp.Vector(0.0, 0.0),
tbots_cpp.Angle.fromRadians(0),
tbots_cpp.Angle(),
tbots_cpp.AngularVelocity(),
tbots_cpp.Timestamp(),
)
for index, location in enumerate(enemy_robot_positions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ INSTANTIATE_TEST_CASE_P(
// the state of the friendly robot
RobotStateWithId{
1, RobotState(Point(0.25, 0), Vector(0, 0), Angle::fromDegrees(180),
Angle::fromDegrees(0))},
AngularVelocity::fromDegrees(0))},
// the state of the ball
BallState(Point(0., 0.), Vector(0, 0)),
// the states of the enemy robots
Expand Down Expand Up @@ -227,8 +227,9 @@ INSTANTIATE_TEST_CASE_P(
Pass(Point(FIELD_TOP_LEFT.x() + 0.05, FIELD_TOP_LEFT.y() - 0.05), Point(0, 0),
5),
// the state of the friendly robot
RobotStateWithId{1, RobotState(FIELD_TOP_LEFT, Vector(0, 0),
Angle::fromDegrees(0), Angle::fromDegrees(0))},
RobotStateWithId{
1, RobotState(FIELD_TOP_LEFT, Vector(0, 0), Angle::fromDegrees(0),
AngularVelocity::fromDegrees(0))},
// the state of the ball
BallState(Point(FIELD_TOP_LEFT.x() + 0.05, FIELD_TOP_LEFT.y() - 0.2),
Vector(0, 0)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "software/ai/hl/stp/tactic/attacker/attacker_tactic.h"
#include "software/ai/hl/stp/tactic/move/move_tactic.h"
#include "software/geom/algorithms/contains.h"
#include "software/geom/angular_velocity.h"
#include "software/simulated_tests/simulated_er_force_sim_play_test_fixture.h"
#include "software/simulated_tests/terminating_validation_functions/ball_kicked_validation.h"
#include "software/simulated_tests/terminating_validation_functions/robot_state_validation.h"
Expand Down Expand Up @@ -73,23 +74,23 @@ INSTANTIATE_TEST_CASE_P(
// Stationary Ball Tests
// Attacker point != Balls location & Balls location != Robots Location
std::make_tuple(Pass(Point(0.0, 0.5), Point(0, 0), 5),
RobotStateWithId{
1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0), Angle::fromDegrees(0))},
RobotStateWithId{1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0),
AngularVelocity::fromDegrees(0))},
BallState(Point(0.5, 0.5), Vector(0, 0))),

// Attacker point == Balls location & Balls location != Robots Location
std::make_tuple(Pass(Point(-0.5, -0.5), Point(0, 0), 5),
RobotStateWithId{
1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0), Angle::fromDegrees(0))},
RobotStateWithId{1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0),
AngularVelocity::fromDegrees(0))},
BallState(Point(-0.5, -0.5), Vector(0, 0))),

// Attacker point != Balls location & Balls location == Robots Location
std::make_tuple(Pass(Point(0.5, 0.5), Point(0, 1), 5),
RobotStateWithId{
1, RobotState(Point(0.5, 0.5), Vector(0, 0),
Angle::fromDegrees(0), Angle::fromDegrees(0))},
RobotStateWithId{1, RobotState(Point(0.5, 0.5), Vector(0, 0),
Angle::fromDegrees(0),
AngularVelocity::fromDegrees(0))},
BallState(Point(-0.5, 0.5), Vector(0, 0))),

// TODO(#2909) : Enable test once the robot can turn faster and hits the ball with
Expand All @@ -103,24 +104,24 @@ INSTANTIATE_TEST_CASE_P(

// Attacker point far away (not a normal use case, but just to sanity check)
std::make_tuple(Pass(Point(0.0, 0.0), Point(0, 0), 5),
RobotStateWithId{
1, RobotState(Point(3.5, 2.5), Vector(0, 0),
Angle::fromDegrees(0), Angle::fromDegrees(0))},
RobotStateWithId{1, RobotState(Point(3.5, 2.5), Vector(0, 0),
Angle::fromDegrees(0),
AngularVelocity::fromDegrees(0))},
BallState(Point(0.0, 0.0), Vector(0, 0))),

// Attacker point != Balls location & Balls location != Robots Location
std::make_tuple(Pass(Point(0.0, 0.5), Point(0, 0), 5),
RobotStateWithId{
1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0), Angle::fromDegrees(0))},
RobotStateWithId{1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0),
AngularVelocity::fromDegrees(0))},
BallState(Point(0.5, 0.5), Vector(0, 0))),

// Moving Ball Tests
// Attacker point == Balls location & Balls location != Robots Location
std::make_tuple(Pass(Point(-0.5, -0.5), Point(0, 0), 5),
RobotStateWithId{
1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0), Angle::fromDegrees(0))},
RobotStateWithId{1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0),
AngularVelocity::fromDegrees(0))},
BallState(Point(-0.5, -0.5), Vector(1, 0))),

// TODO (#2859): Robot does not kick ball when dribbler is off since it is
Expand All @@ -135,7 +136,7 @@ INSTANTIATE_TEST_CASE_P(

// Attacker point == Balls location & Balls location == Robots Location
std::make_tuple(Pass(Point(0.0, 0.0), Point(0, 0), 5),
RobotStateWithId{
1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0), Angle::fromDegrees(0))},
RobotStateWithId{1, RobotState(Point(0, 0), Vector(0, 0),
Angle::fromDegrees(0),
AngularVelocity::fromDegrees(0))},
BallState(Point(0.0, 0.0), Vector(1, 0)))));
14 changes: 7 additions & 7 deletions src/software/ai/hl/stp/tactic/move/move_tactic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ TEST_F(MoveTacticTest, test_spinning_move_clockwise)
BallState ball_state(Point(1, 1), Vector(0, 0));
auto friendly_robots = {RobotStateWithId{
.id = 0,
.robot_state = RobotState(initial_position, Vector(0, 0), Angle::zero(),
AngularVelocity::quarter())}};
.robot_state = RobotState(initial_position, Vector(0, 0), -Angle::quarter(),
AngularVelocity::zero())}};
auto enemy_robots = TestUtil::createStationaryRobotStatesWithId({Point(4, 0)});

auto tactic = std::make_shared<MoveTactic>(std::make_shared<TbotsProto::AiConfig>());
Expand All @@ -175,8 +175,8 @@ TEST_F(MoveTacticTest, test_spinning_move_clockwise)
[destination, tactic](std::shared_ptr<World> world_ptr,
ValidationCoroutine::push_type& yield)
{
robotAtAngularVelocity(0, world_ptr, AngularVelocity::fromDegrees(1 * 360),
AngularVelocity::fromDegrees(50), yield);
robotAtAngularVelocity(0, world_ptr, AngularVelocity::fromDegrees(10),
AngularVelocity::fromDegrees(5), yield);
robotAtPosition(0, world_ptr, destination, 0.05, yield);
robotAtOrientation(0, world_ptr, Angle::zero(), Angle::fromDegrees(5), yield);
while (!tactic->done())
Expand Down Expand Up @@ -207,7 +207,7 @@ TEST_F(MoveTacticTest, test_spinning_move_counter_clockwise)
BallState ball_state(Point(1, 1), Vector(0, 0));
auto friendly_robots = {RobotStateWithId{
.id = 0,
.robot_state = RobotState(initial_position, Vector(0, 0), Angle::quarter(),
.robot_state = RobotState(initial_position, Vector(0, 0), -Angle::quarter(),
AngularVelocity::zero())}};
auto enemy_robots = TestUtil::createStationaryRobotStatesWithId({Point(4, 0)});

Expand All @@ -223,8 +223,8 @@ TEST_F(MoveTacticTest, test_spinning_move_counter_clockwise)
[destination, tactic](std::shared_ptr<World> world_ptr,
ValidationCoroutine::push_type& yield)
{
robotAtAngularVelocity(0, world_ptr, AngularVelocity::fromDegrees(-4 * 360),
AngularVelocity::fromDegrees(50), yield);
robotAtAngularVelocity(0, world_ptr, AngularVelocity::fromDegrees(-10),
AngularVelocity::fromDegrees(5), yield);
robotAtPosition(0, world_ptr, destination, 0.05, yield);
robotAtOrientation(0, world_ptr, Angle::half(), Angle::fromDegrees(5), yield);
while (!tactic->done())
Expand Down
5 changes: 3 additions & 2 deletions src/software/ai/hl/stp/tactic/move_primitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "proto/primitive/primitive_msg_factory.h"
#include "software/ai/navigator/trajectory/bang_bang_trajectory_1d_angular.h"
#include "software/geom/algorithms/end_in_obstacle_sample.h"
#include "software/geom/angular_acceleration.h"

MovePrimitive::MovePrimitive(
const Robot &robot, const Point &destination, const Angle &final_angle,
Expand Down Expand Up @@ -38,9 +39,9 @@ MovePrimitive::MovePrimitive(
robot.orientation(), final_angle, robot.angularVelocity(),
AngularVelocity::fromRadians(
robot.robotConstants().robot_max_ang_speed_rad_per_s),
AngularVelocity::fromRadians(
AngularAcceleration::fromRadians(
robot.robotConstants().robot_max_ang_acceleration_rad_per_s_2),
AngularVelocity::fromRadians(
AngularAcceleration::fromRadians(
robot.robotConstants().robot_max_ang_acceleration_rad_per_s_2));

estimated_cost =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <utility>

#include "software/geom/angular_velocity.h"
#include "software/simulated_tests/non_terminating_validation_functions/ball_in_play_or_scored_validation.h"
#include "software/simulated_tests/non_terminating_validation_functions/ball_never_moves_backward_validation.h"
#include "software/simulated_tests/non_terminating_validation_functions/robot_not_excessively_dribbling_validation.h"
Expand All @@ -21,8 +22,8 @@ class PenaltyKickTacticTest : public SimulatedErForceSimPlayTestFixture,
Field field = Field::createField(field_type);
BallState ball = BallState(field.friendlyPenaltyMark(), Vector(0, 0));
Point initial_position = field.friendlyPenaltyMark() + Vector(-0.1, 0);
RobotStateWithId shooter = {
0, RobotState(initial_position, Vector(0, 0), Angle::zero(), Angle::zero())};
RobotStateWithId shooter = {0, RobotState(initial_position, Vector(0, 0),
Angle::zero(), AngularVelocity::zero())};
};

// TODO (#2232): Improve dribbling control so the ball is not lost during this test
Expand Down Expand Up @@ -79,22 +80,23 @@ INSTANTIATE_TEST_CASE_P(
RobotLocations, PenaltyKickTacticTest,
::testing::Values(
// enemy robot stationary at centre of goal
RobotStateWithId{0, RobotState(Field::createSSLDivisionBField().enemyGoalCenter(),
Vector(0, 0), Angle::half(), Angle::zero())},
RobotStateWithId{
0, RobotState(Field::createSSLDivisionBField().enemyGoalCenter(),
Vector(0, 0), Angle::half(), AngularVelocity::zero())},

// enemy robot stationary left of net
RobotStateWithId{0,
RobotState(Field::createSSLDivisionBField().enemyGoalpostNeg(),
Vector(0, 0), Angle::half(), Angle::zero())},
RobotStateWithId{
0, RobotState(Field::createSSLDivisionBField().enemyGoalpostNeg(),
Vector(0, 0), Angle::half(), AngularVelocity::zero())},
// enemy robot stationary right of net
RobotStateWithId{0,
RobotState(Field::createSSLDivisionBField().enemyGoalpostPos(),
Vector(0, 0), Angle::half(), Angle::zero())},
RobotStateWithId{
0, RobotState(Field::createSSLDivisionBField().enemyGoalpostPos(),
Vector(0, 0), Angle::half(), AngularVelocity::zero())},
// enemy robot left of net but moving right
RobotStateWithId{0,
RobotState(Field::createSSLDivisionBField().enemyGoalpostNeg(),
Vector(0, 1.2), Angle::half(), Angle::zero())},
RobotStateWithId{
0, RobotState(Field::createSSLDivisionBField().enemyGoalpostNeg(),
Vector(0, 1.2), Angle::half(), AngularVelocity::zero())},
// enemy robot right of net but moving left
RobotStateWithId{0,
RobotState(Field::createSSLDivisionBField().enemyGoalpostPos(),
Vector(0, -1.2), Angle::half(), Angle::zero())}));
RobotStateWithId{
0, RobotState(Field::createSSLDivisionBField().enemyGoalpostPos(),
Vector(0, -1.2), Angle::half(), AngularVelocity::zero())}));
Loading
Loading