Skip to content
Closed
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
2 changes: 1 addition & 1 deletion scripts/lint_and_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function run_bazel_formatting () {
function run_ruff() {
printf "Running ruff to lint and format Python files...\n\n"

/opt/tbotspython/bin/python3 -m ruff check $BAZEL_ROOT_DIR --fix-only --extend-select D
/opt/tbotspython/bin/python3 -m ruff check $BAZEL_ROOT_DIR --fix-only --extend-select D,I
/opt/tbotspython/bin/python3 -m ruff format $BAZEL_ROOT_DIR

if [[ "$?" != 0 ]]; then
Expand Down
3 changes: 2 additions & 1 deletion src/cli/cli_params.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typer import Option, Argument
from enum import Enum
from typing import Annotated

from typer import Argument, Option

from cli.multi_option import MultiOption


Expand Down
2 changes: 1 addition & 1 deletion src/cli/multi_option.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Any

import click
import typer
import typer.core
import typer.main
from typer.models import OptionInfo


# ======= Patch to support nargs functionality in typer =======
# nargs usage is considered bad practice in typer and many CLIs,
# but since we likely want to be able to parse many optional args at once, this patch allows us to do so.
Expand Down
1 change: 1 addition & 0 deletions src/proto/import_all_protos.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib
import pkgutil

import proto


Expand Down
8 changes: 5 additions & 3 deletions src/proto/message_translation/tbots_protobuf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import annotations

from proto.import_all_protos import *
import software.python_bindings as tbots_cpp
import numpy
import math

import numpy

import software.python_bindings as tbots_cpp
from proto.import_all_protos import *


def create_world_state(
yellow_robot_locations: list[tbots_cpp.Point],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
import software.python_bindings as tbots_cpp
from software.py_constants import ENEMY_BALL_PLACEMENT_DISTANCE_METERS

import software.python_bindings as tbots_cpp
from proto.import_all_protos import *
from proto.ssl_gc_common_pb2 import Team
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.py_constants import ENEMY_BALL_PLACEMENT_DISTANCE_METERS
from software.simulated_tests.ball_enters_region import (
BallAlwaysStaysInRegion,
BallEventuallyEntersRegion,
Expand Down Expand Up @@ -122,12 +122,12 @@ def ball_placement_play_setup(

# Game Controller Setup
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
# Pass in placement point here - not required for all play tests
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.BALL_PLACEMENT,
team=Team.BLUE,
team=SslTeam.BLUE,
final_ball_placement_point=ball_placement_point,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import software.python_bindings as tbots_cpp
from proto.play_pb2 import Play, PlayName
from proto.import_all_protos import *
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team
from proto.play_pb2 import Play, PlayName
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
Expand Down Expand Up @@ -44,10 +44,10 @@ def setup(*args):
)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.FORCE_START, team=Team.BLUE
gc_command=Command.Type.FORCE_START, team=SslTeam.BLUE
)

blue_play = Play()
Expand Down
12 changes: 6 additions & 6 deletions src/software/ai/hl/stp/play/defense/defense_play_test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pytest

import software.python_bindings as tbots_cpp
from proto.message_translation.tbots_protobuf import create_world_state
from proto.play_pb2 import Play, PlayName
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.ball_enters_region import *
from software.simulated_tests.friendly_has_ball_possession import (
FriendlyEventuallyHasBallPossession,
)
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
Expand Down Expand Up @@ -49,10 +49,10 @@ def setup(*args):
)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.FORCE_START, team=Team.BLUE
gc_command=Command.Type.FORCE_START, team=SslTeam.BLUE
)

blue_play = Play()
Expand Down Expand Up @@ -118,10 +118,10 @@ def setup(*args):
)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.FORCE_START, team=Team.BLUE
gc_command=Command.Type.FORCE_START, team=SslTeam.BLUE
)

blue_play = Play()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pytest

import software.python_bindings as tbots_cpp
from proto.message_translation.tbots_protobuf import create_world_state
from proto.play_pb2 import Play, PlayName
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.robot_enters_placement_region import *
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team


@pytest.mark.parametrize(
Expand Down Expand Up @@ -55,11 +55,11 @@ def setup(*args):
)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.BALL_PLACEMENT,
team=Team.YELLOW,
team=SslTeam.YELLOW,
final_ball_placement_point=ball_placement_point,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import pytest

import software.python_bindings as tbots_cpp
from proto.message_translation.tbots_protobuf import create_world_state
from proto.play_pb2 import Play, PlayName

from software.simulated_tests.or_validation import OrValidation

from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.ball_enters_region import *
from software.simulated_tests.ball_moves_from_rest import (
BallEventuallyMovesFromRest,
)
from software.simulated_tests.friendly_team_scored import *
from software.simulated_tests.ball_enters_region import *
from software.simulated_tests.or_validation import OrValidation
from software.simulated_tests.robot_enters_region import (
RobotEventuallyEntersRegion,
RobotNeverEntersRegion,
)
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
Expand Down Expand Up @@ -113,10 +111,10 @@ def setup(*args):
)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.DIRECT, team=Team.YELLOW
gc_command=Command.Type.DIRECT, team=SslTeam.YELLOW
)

blue_play = Play()
Expand Down
14 changes: 7 additions & 7 deletions src/software/ai/hl/stp/play/example/example_play_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import software.python_bindings as tbots_cpp
from proto.message_translation.tbots_protobuf import create_world_state
from proto.play_pb2 import Play, PlayName
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.robot_enters_region import (
NumberOfRobotsEventuallyExitsRegion,
NumberOfRobotsEventuallyEntersRegion,
NumberOfRobotsEventuallyExitsRegion,
)
from software.simulated_tests.robot_speed_threshold import *
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team
from proto.play_pb2 import Play, PlayName
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
Expand Down Expand Up @@ -57,13 +57,13 @@ def setup(*args):
simulated_test_runner.set_play(yellow_play, is_friendly=False)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.NORMAL_START, team=Team.BLUE
gc_command=Command.Type.NORMAL_START, team=SslTeam.BLUE
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.DIRECT, team=Team.BLUE
gc_command=Command.Type.DIRECT, team=SslTeam.BLUE
)

# params just have to be a list of length 1 to ensure the test runs at least once
Expand Down
10 changes: 5 additions & 5 deletions src/software/ai/hl/stp/play/free_kick/free_kick_play_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pytest

import software.python_bindings as tbots_cpp
from proto.message_translation.tbots_protobuf import create_world_state
from proto.play_pb2 import Play, PlayName
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.ball_enters_region import *
from software.simulated_tests.friendly_team_scored import *
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
Expand All @@ -24,13 +24,13 @@ def free_kick_play_setup(
)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.NORMAL_START, team=Team.BLUE
gc_command=Command.Type.NORMAL_START, team=SslTeam.BLUE
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.DIRECT, team=Team.BLUE
gc_command=Command.Type.DIRECT, team=SslTeam.BLUE
)

blue_play = Play()
Expand Down
12 changes: 6 additions & 6 deletions src/software/ai/hl/stp/play/halt_play/halt_play_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import software.python_bindings as tbots_cpp
from software.simulated_tests.robot_speed_threshold import *
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.robot_speed_threshold import *
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
Expand Down Expand Up @@ -45,10 +45,10 @@ def setup(*args):
)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.FORCE_START, team=Team.UNKNOWN
gc_command=Command.Type.FORCE_START, team=SslTeam.UNKNOWN
)

# params just have to be a list of length 1 to ensure the test runs at least once
Expand All @@ -64,8 +64,8 @@ def setup(*args):
[RobotSpeedEventuallyBelowThreshold(1e-3)]
],
ci_cmd_with_delay=[
(3, Command.Type.HALT, Team.BLUE),
(3, Command.Type.HALT, Team.YELLOW),
(3, Command.Type.HALT, SslTeam.BLUE),
(3, Command.Type.HALT, SslTeam.YELLOW),
],
test_timeout_s=10,
)
Expand Down
18 changes: 9 additions & 9 deletions src/software/ai/hl/stp/play/kickoff_play_test.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import pytest

import software.python_bindings as tbots_cpp
from proto.import_all_protos import *
from proto.message_translation.tbots_protobuf import create_world_state
from proto.play_pb2 import Play, PlayName
from software.simulated_tests.robot_enters_region import *
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.ball_enters_region import *
from software.simulated_tests.ball_moves_from_rest import *
from proto.import_all_protos import *
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team
from software.simulated_tests.or_validation import OrValidation
from software.simulated_tests.robot_enters_region import *
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
from software.simulated_tests.or_validation import OrValidation


@pytest.mark.parametrize("is_friendly_test", [True, False])
Expand Down Expand Up @@ -54,24 +54,24 @@ def setup(*args):
yellow_play = Play()

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)

if is_friendly_test:
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.KICKOFF, team=Team.BLUE
gc_command=Command.Type.KICKOFF, team=SslTeam.BLUE
)
blue_play.name = PlayName.KickoffFriendlyPlay
yellow_play.name = PlayName.KickoffEnemyPlay
else:
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.KICKOFF, team=Team.YELLOW
gc_command=Command.Type.KICKOFF, team=SslTeam.YELLOW
)
blue_play.name = PlayName.KickoffEnemyPlay
yellow_play.name = PlayName.KickoffFriendlyPlay

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.NORMAL_START, team=Team.BLUE
gc_command=Command.Type.NORMAL_START, team=SslTeam.BLUE
)

simulated_test_runner.set_play(blue_play, is_friendly=True)
Expand Down
13 changes: 6 additions & 7 deletions src/software/ai/hl/stp/play/offense/offense_play_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import software.python_bindings as tbots_cpp
from proto.message_translation.tbots_protobuf import create_world_state
from proto.play_pb2 import Play, PlayName

from software.simulated_tests.excessive_dribbling import NeverExcessivelyDribbles
from software.simulated_tests.friendly_team_scored import *
from proto.ssl_gc_common_pb2 import Team as SslTeam
from software.simulated_tests.ball_enters_region import *
from software.simulated_tests.excessive_dribbling import NeverExcessivelyDribbles
from software.simulated_tests.friendly_has_ball_possession import *
from proto.message_translation.tbots_protobuf import create_world_state
from proto.ssl_gc_common_pb2 import Team
from software.simulated_tests.friendly_team_scored import *
from software.simulated_tests.simulated_test_fixture import (
pytest_main,
)
Expand Down Expand Up @@ -48,10 +47,10 @@ def setup(start_point):
)

simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.STOP, team=Team.UNKNOWN
gc_command=Command.Type.STOP, team=SslTeam.UNKNOWN
)
simulated_test_runner.send_gamecontroller_command(
gc_command=Command.Type.FORCE_START, team=Team.BLUE
gc_command=Command.Type.FORCE_START, team=SslTeam.BLUE
)

blue_play = Play()
Expand Down
Loading
Loading