Skip to content

Conversation

@GrayHoang
Copy link
Contributor

@GrayHoang GrayHoang commented Jul 11, 2025

Description

Adds a pytest for penalty kick
Basically this test just assess whether the ball goes into the goal. I may update it later to pass if the ball enters the crease, as in theory the goalie can defend the ball and we would still consider the play to succeed, even if the ball didn't score.

Testing Done

It compiles and the broken penalty kick ai fails the test (gotta fix that)

Resolved Issues

working on #3389

Length Justification and Key Files to Review

there are a couple of comments on lines I wasn't sure about.

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

@GrayHoang
Copy link
Contributor Author

Probably going to add the pytest for the tactic to this branch as well. Just gotta figure out how to write that...

# Always Validation
inv_always_validation_sequence_set = [[]]

ag_always_validation_sequence_set = [[FriendlyAlwaysHasBallPossession(), BallAlwaysMovesForward(ball_initial_pos)]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't this be inv_always?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It immediately fails cause I think the ball doesn't start moving forward? Or the robot doesn't immediately start with the ball. I forget which.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact it is both.

create_world_state(
yellow_robot_locations=[],
blue_robot_locations=[tbots_cpp.Point(-3, 0)],
ball_location=tbots_cpp.Point(0, 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

penalty mark is 6m from the opponent net (-1.5, 0)

https://robocup-ssl.github.io/ssl-rules/sslrules.html#_penalty_mark

from proto.import_all_protos import *


def test_penalty_kick_no_goalie(simulated_test_runner):
Copy link
Contributor

Choose a reason for hiding this comment

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

you should break this test into 2 different tests (setup and taking):
https://robocup-ssl.github.io/ssl-rules/sslrules.html#_penalty_kick

setup: checks that all friendly robots are behind the ball and only 1 robot is near the ball

take: checks that we score and the ball always moves forward. we need to issue NORMAL_START so that the penalty kick taker actually starts manipulating the ball. you would do this by adding these lines

    simulated_test_runner.gamecontroller.send_gc_command(
        gc_command=Command.Type.NORMAL_START, team=Team.BLUE
    )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I realized after I wrote this test lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test only has one robot though, so I think this should be in the play test, and not the tactic test?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah it should be under src/software/ai/hl/stp/play/penalty_kick/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah change was made to the right file

@williamckha williamckha linked an issue Aug 30, 2025 that may be closed by this pull request
1 task
def test_penalty_kick_play(simulated_test_runner):
ball_initial_pos = tbots_cpp.Point(0, 0)

def setup(*args):
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing docstring, add param docs for args.

inv_eventually_validation_sequence_set = [
[
FriendlyTeamEventuallyScored(),
BallEventuallyEntersRegion(regions=[field.enemyDefenseArea()]),
Copy link
Contributor

Choose a reason for hiding this comment

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

this validation is kinda redundant considering we have FriendlyTeamEventuallyScored

Comment on lines +67 to +70
[
FriendlyAlwaysHasBallPossession(),
BallAlwaysMovesForward(tbots_cpp.Point(0, 0)),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: make this another variable like you've done for the other sets

],
)

cc_test(
Copy link
Contributor

Choose a reason for hiding this comment

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

you can delete this test now that you've added the pytest

Copy link
Contributor

@itsarune itsarune left a comment

Choose a reason for hiding this comment

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

left some feedback, you might want to check if the tests you made pass locally.

@Thunderbots Thunderbots linked an issue Oct 3, 2025 that may be closed by this pull request
1 task
@GrayHoang GrayHoang requested a review from Andrewyx as a code owner November 22, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Penalty kick play Python test Fix PenaltyKickTactic Tests in Er Force Simulator

2 participants