Skip to content

Commit cd03e70

Browse files
authored
Merge pull request #141 from robocup-junior/update-webots
Update webots to R2023b
2 parents da989e6 + 56e096d commit cd03e70

File tree

18 files changed

+196
-232
lines changed

18 files changed

+196
-232
lines changed

.pre-commit-config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ default_language_version:
22
python: python3.8
33
repos:
44
- repo: https://github.com/pycqa/isort
5-
rev: 5.10.1
5+
rev: 5.12.0
66
hooks:
77
- id: isort
88
entry: bash -c 'isort --check-only .'
99
stages: [commit]
1010
- repo: https://github.com/ambv/black
11-
rev: 21.11b1
11+
rev: 23.9.1
1212
hooks:
1313
- id: black
1414
entry: bash -c 'black --check .'
1515
stages: [commit]
1616
- repo: https://gitlab.com/pycqa/flake8
17-
rev: 4.0.1
17+
rev: 6.1.0
1818
hooks:
1919
- id: flake8
2020
entry: bash -c 'python3 -m flake8 .'

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
* Features
6+
* **BREAKING** Change the message format sent between Emitter and Receiver
7+
* Update Webots from R2022a to R2023b
8+
* Other
9+
* Update development requirements
10+
511
## v2.1
612

713
* Features

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
This is the official repository of the RoboCupJunior Soccer Simulator. The
44
simulator is based on [Webots](https://github.com/cyberbotics/webots) and this
55
repository provides both the "automatic referee" (which implements the [Soccer
6-
Simulated Rules](https://github.com/RoboCupJuniorTC/soccer-rules-simulation))
6+
Simulated Rules](https://github.com/robocup-junior/soccer-rules-simulation))
77
as well as a sample simulated team of robots with some basic strategy.
88

99
![Soccer Sim](./docs/docs/images/soccer_sim.png)
1010

11-
*Learn more in the [documentation](https://robocupjuniortc.github.io/rcj-soccersim/).*
11+
*Learn more in the [documentation](https://robocup-junior.github.io/rcj-soccersim/).*
1212

1313
# How do I try this out?
1414

1515
## Installation
1616

1717
1. Install Python 3.7 (or higher) 64 bit from the [official website](https://www.python.org/downloads/) (please make sure it is version 3.7 or higher for Windows, and 3.8 or higher if installing on MacOS or Linux). On Windows, please make sure your Python is referenced in Windows PATH by selecting the option "Add Python 3.x to PATH" during the installation. Check out this great [installation guide](https://realpython.com/installing-python/) if you need some help!
1818

19-
2. Download [Webots](https://www.cyberbotics.com/#download) from their official website. Currently, version R2022a is stable with the Soccer Simulator. You can find detailed installation procedure on the official [Webots Installation guide](https://cyberbotics.com/doc/guide/installation-procedure).
19+
2. Download [Webots](https://www.cyberbotics.com/#download) from their official website. Currently, version R2023b is stable with the Soccer Simulator. You can find detailed installation procedure on the official [Webots Installation guide](https://cyberbotics.com/doc/guide/installation-procedure).
2020

21-
3. Clone the rcj-soccersim repository to your computer by downloading the ZIP file from [here](https://github.com/RoboCupJuniorTC/rcj-soccersim/archive/master.zip) or running
21+
3. Clone the rcj-soccersim repository to your computer by downloading the ZIP file from [here](https://github.com/robocup-junior/rcj-soccersim/archive/master.zip) or running
2222

23-
git clone https://github.com/RoboCupJuniorTC/rcj-soccersim.git
23+
git clone https://github.com/robocup-junior/rcj-soccersim.git
2424

2525
4. Finally, run Webots, go to `Tools > Preferences > Python command` and set it to `python` or `python3` to point Webots to Python 3. Depending on your system, the reference to Python 3 can be via the command `python` or `python3`. More information on how to configure Webots to work with Python can be found [here](https://cyberbotics.com/doc/guide/using-python).
2626

@@ -48,7 +48,7 @@ avoid any compilation issues.
4848

4949
## Development
5050

51-
We are open to contributions! Have a look at our [issues](https://github.com/RoboCupJuniorTC/rcj-soccersim/issues).
51+
We are open to contributions! Have a look at our [issues](https://github.com/robocup-junior/rcj-soccersim/issues).
5252
Before you make a pull request, make sure the code is formatted
5353
with `black` and `isort`, and `flake8` issues are fixed.
5454

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import struct
2-
31
from controller import Robot
42

53
robot = Robot()
64
ball_emitter = robot.getDevice("ball emitter")
75

8-
data = [True] # Packet cannot be empty
9-
packet = struct.pack("?", *data)
6+
data = "x" # Packet cannot be empty
107

118
while robot.step(32) != -1:
12-
ball_emitter.send(packet)
9+
ball_emitter.send(data)

controllers/rcj_soccer_referee_supervisor/rcj_soccer_referee_supervisor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def output_path(
3030
match_id: int,
3131
half_id: int,
3232
) -> PosixPath:
33-
3433
now_str = datetime.utcnow().strftime("%Y%m%dT%H%M%S")
3534
team_blue = team_blue_id.replace(" ", "_")
3635
team_yellow = team_yellow_id.replace(" ", "_")

controllers/rcj_soccer_referee_supervisor/recorder/recorder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def __init__(
1717
fastforward_rate: int = 1,
1818
resolution: str = "720p",
1919
):
20-
2120
self.supervisor = supervisor
2221
self.output_path = output_path
2322
self.fastforward_rate = fastforward_rate

controllers/rcj_soccer_referee_supervisor/referee/progress_checker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ def reset(self):
1515
self.prev_position = None
1616

1717
def track(self, position: List[float]):
18-
"""Make ProgressChecker react to a new position. Internally, it computes
19-
the Euclidian distance from the previous position and saves it so that
20-
it can be used when computing whether the given object has made
21-
progress.
18+
"""Make ProgressChecker react to a new position. Internally, it
19+
computes the Euclidian distance from the previous position and
20+
saves it so that it can be used when computing whether the given
21+
object has made progress.
2222
2323
Args:
2424
position (list): Current position of the object

controllers/rcj_soccer_referee_supervisor/referee/referee.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import json
12
import random
2-
import struct
33
from typing import List, Optional, Tuple
44

55
from controller import Supervisor
@@ -91,21 +91,18 @@ def __init__(
9191
self.sv.draw_team_names(self.team_name_blue, self.team_name_yellow)
9292
self.sv.draw_scores(self.score_blue, self.score_yellow)
9393

94-
def _pack_packet(self) -> bytes:
95-
"""Pack data into packet.
94+
def _pack_data(self) -> str:
95+
"""Pack data into json string.
9696
9797
Returns:
98-
bytes: the packed packet.
98+
str: json data encoded into string.
9999
"""
100-
# True/False telling whether the goal was scored
101-
struct_fmt = "?"
102-
data = list()
100+
# Add Notification if the goal is scored and we are
101+
# waiting for kickoff. The value is True or False
102+
waiting_for_kickoff = self.ball_reset_timer > 0
103103

104-
# Add Notification if the goal is scored and we are waiting for kickoff
105-
# The value is True or False
106-
data.append(self.ball_reset_timer > 0)
107-
108-
return struct.pack(struct_fmt, *data)
104+
data = {"waiting_for_kickoff": waiting_for_kickoff}
105+
return json.dumps(data)
109106

110107
def _add_initial_position_noise(
111108
self, translation: List[float]
@@ -396,7 +393,7 @@ def tick(self) -> bool:
396393
)
397394

398395
self.sv.update_positions()
399-
self.sv.emit_data(self._pack_packet())
396+
self.sv.emit_data(self._pack_data())
400397
self.time -= TIME_STEP / 1000.0
401398

402399
# On the very last tick, note that the match has finished

controllers/rcj_soccer_referee_supervisor/referee/supervisor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ def move_object_to_neutral_spot(self, object_name: str, neutral_spot: str):
217217
object_name, ROBOT_INITIAL_ROTATION[object_name]
218218
)
219219

220-
def emit_data(self, packet: bytes):
220+
def emit_data(self, data: str):
221221
"""Send packet via emitter
222222
223223
Args:
224-
packet (bytes): the packet to be sent
224+
data (str): the data to be sent
225225
"""
226-
self.emitter.send(packet)
226+
self.emitter.send(data)
227227

228228
def draw_team_names(self, team_name_blue: str, team_name_yellow: str):
229229
"""Visualize (draw) the names of the teams.

controllers/rcj_soccer_referee_supervisor/referee/tests/test_referee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def referee() -> RCJSoccerReferee:
3232

3333

3434
def test_pack_packet(referee: RCJSoccerReferee):
35-
assert referee._pack_packet() == b"\x00"
35+
assert referee._pack_data() == '{"waiting_for_kickoff": false}'
3636

3737

3838
def test_add_initial_position_noise(referee: RCJSoccerReferee):

0 commit comments

Comments
 (0)