コード例 #1
0
def test_add_event_message_to_queue(referee: RCJSoccerReferee):
    assert referee.event_messages_to_draw == []

    for i in range(1, MAX_EVENT_MESSAGES_IN_QUEUE + 1):
        referee.add_event_message_to_queue(str(i))
        assert len(referee.event_messages_to_draw) == i
        assert referee.event_messages_to_draw[-1] == (referee.time, str(i))

    referee.add_event_message_to_queue(str(MAX_EVENT_MESSAGES_IN_QUEUE + 1))
    assert len(referee.event_messages_to_draw) == MAX_EVENT_MESSAGES_IN_QUEUE
    assert referee.event_messages_to_draw[-1] == (
        referee.time,
        str(MAX_EVENT_MESSAGES_IN_QUEUE + 1),
    )
    assert referee.event_messages_to_draw[0] == (referee.time, "2")
コード例 #2
0
def test_add_initial_position_noise(referee: RCJSoccerReferee):
    position = [0.0, 0.0, 0.0]
    new_position = referee._add_initial_position_noise(position)

    assert -0.075 <= new_position[0] < 0.075
    assert -0.075 <= new_position[1] < 0.075
    assert new_position[2] == 0.0
コード例 #3
0
def referee() -> RCJSoccerReferee:
    supervisor = MagicMock()
    return RCJSoccerReferee(
        supervisor=supervisor,
        match_time=600,
        progress_check_steps=235,
        progress_check_threshold=0.5,
        ball_progress_check_steps=235,
        ball_progress_check_threshold=0.5,
        team_name_blue="Blues",
        team_name_yellow="Yellows",
        initial_score_blue=0,
        initial_score_yellow=0,
        penalty_area_allowed_time=15,
        penalty_area_reset_after=2,
        match_id=1,
        half_id=1,
        initial_position_noise=0.15,
    )
from math import ceil
from referee.consts import MATCH_TIME, TIME_STEP
from referee.referee import RCJSoccerReferee

referee = RCJSoccerReferee(
    match_time=MATCH_TIME,
    progress_check_steps=ceil(15 / (TIME_STEP / 1000.0)),
    progress_check_threshold=0.5,
    ball_progress_check_steps=ceil(10 / (TIME_STEP / 1000.0)),
    ball_progress_check_threshold=0.5,
)

while referee.step(TIME_STEP) != -1:
    referee.emit_positions()

    if not referee.tick():
        break

# When end of match, pause simulator immediately
referee.simulationSetMode(referee.SIMULATION_MODE_PAUSE)
コード例 #5
0
        directory.mkdir(parents=True, exist_ok=True)

    p = directory / Path(f'{team_blue}_vs_{team_yellow}-{now_str}')
    return p


output_prefix = output_path(Path('reflog'), TEAM_BLUE, TEAM_YELLOW)
reflog_path = output_prefix.with_suffix('.jsonl')
video_path = output_prefix.with_suffix('.mp4')

referee = RCJSoccerReferee(
    match_time=MATCH_TIME,
    progress_check_steps=ceil(15/(TIME_STEP/1000.0)),
    progress_check_threshold=0,
    ball_progress_check_steps=ceil(10/(TIME_STEP/1000.0)),
    ball_progress_check_threshold=0.5,
    team_name_blue=TEAM_BLUE,
    team_name_yellow=TEAM_YELLOW,
    penalty_area_allowed_time=15,
    penalty_area_reset_after=2,
)

recorder = VideoRecordAssistant(
    supervisor=referee,
    output_path=str(video_path),
    resolution="720p",
)

if automatic_mode:
    referee.simulationSetMode(referee.SIMULATION_MODE_FAST)
    recorder.start_recording()
コード例 #6
0
def test_pack_packet(referee: RCJSoccerReferee):
    assert referee._pack_packet() == b"\x00"