Skip to content

Commit

Permalink
Release 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbouteiller committed Feb 6, 2025
1 parent f10832c commit dccef7c
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ __pycache__/
*$py.class

# C extensions
*.so
# *.so

# Distribution / packaging
.Python
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ This works on any track, using any (sensible) camera configuration.
}
```
Note that human players can see or hear the features provided by this environment: we provide no "cheat" that would render the approach non-transferable to the real world.
In case you do wish to cheat, though, you can easily take inspiration from our [rtgym interfaces](https://github.com/trackmania-rl/tmrl/blob/master/tmrl/custom/custom_gym_interfaces.py) to build your own custom environment for TrackMania.
In case you do wish to cheat, though, you can easily take inspiration from our [rtgym interfaces](https://github.com/trackmania-rl/tmrl/blob/master/tmrl/custom/tm/tm_gym_interfaces.py) to build your own custom environment for TrackMania.

The `Full` environment is used in the official [TMRL competition](https://github.com/trackmania-rl/tmrl/blob/master/readme/competition.md), and custom environments are featured in the "off" competition :wink:

Expand Down Expand Up @@ -471,7 +471,7 @@ This project uses [Real-Time Gym](https://github.com/yannbouteiller/rtgym) (```r

Time-steps are being elastically constrained to their nominal duration. When this elastic constraint cannot be satisfied, the previous time-step times out and the new time-step starts from the current timestamp.

Custom `rtgym` interfaces for Trackmania used by `tmrl` are implemented in [custom_gym_interfaces.py](https://github.com/yannbouteiller/tmrl/blob/master/tmrl/custom/custom_gym_interfaces.py).
Custom `rtgym` interfaces for Trackmania used by `tmrl` are implemented in [tm_gym_interfaces.py](https://github.com/yannbouteiller/tmrl/blob/master/tmrl/custom/tm/tm_gym_interfaces.py).

## Remote training architecture:

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build-system]
requires = [
"setuptools",
]
build-backend = "setuptools.build_meta"
4 changes: 2 additions & 2 deletions readme/tuto_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ We use [Real-Time Gym](https://github.com/yannbouteiller/rtgym) (`rtgym`) to wra
But you can use an environment of your choice, as long as it is registered as a Gymnasium environment.

To build your own real-time environment (e.g., an environment for your own robot or video game), you can follow the [rtgym tutorial](https://github.com/yannbouteiller/rtgym#tutorial).
If you need inspiration, you can find our `rtgym` interfaces for TrackMania in [custom_gym_interfaces.py](https://github.com/trackmania-rl/tmrl/blob/master/tmrl/custom/custom_gym_interfaces.py).
If you need inspiration, you can find our `rtgym` interfaces for TrackMania in [tm_gym_interfaces.py](https://github.com/trackmania-rl/tmrl/blob/master/tmrl/custom/tm/tm_gym_interfaces.py).

For the sake of the `tmrl` tutorial, we will be using the dummy RC drone environment from the `rtgym` tutorial:

Expand Down Expand Up @@ -558,7 +558,7 @@ A few more parameters are configurable, although they will not be useful in this
In particular:

`obs_preprocessor` can be used to modify observations returned by the environment (this enables, e.g., converting RGB images into grayscale without modifying the environment).
Some examples of such preprocessors are available [here](https://github.com/trackmania-rl/tmrl/blob/master/tmrl/custom/custom_preprocessors.py).
Some examples of such preprocessors are available [here](https://github.com/trackmania-rl/tmrl/blob/master/tmrl/custom/tm/tm_preprocessors.py).

`standalone` can be set to `True` for deployment, in which case the `RolloutWorker` will not attempt to connect to the `Server`.

Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import urllib.error
import socket


TMRL_VERSION = '0.7.0'


if sys.version_info < (3, 7):
sys.exit('Sorry, Python < 3.7 is not supported.')

Expand Down Expand Up @@ -137,13 +141,13 @@ def url_retrieve(url: str, outfile: Path, overwrite: bool = False):

setup(
name='tmrl',
version='0.6.6',
version=TMRL_VERSION,
description='Network-based framework for real-time robot learning',
long_description=README,
long_description_content_type='text/markdown',
keywords='reinforcement learning, robot learning, trackmania, self driving, roborace',
url='https://github.com/trackmania-rl/tmrl',
download_url='https://github.com/trackmania-rl/tmrl/archive/refs/tags/v0.6.6.tar.gz',
download_url=f'https://github.com/trackmania-rl/tmrl/archive/refs/tags/v{TMRL_VERSION}.tar.gz',
author='Yann Bouteiller, Edouard Geze',
author_email='[email protected], [email protected]',
license='MIT',
Expand Down
2 changes: 1 addition & 1 deletion tmrl/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def save(self, path):

def load(self, path, device):
self.device = device
self.load_state_dict(torch.load(path, map_location=self.device))
self.load_state_dict(torch.load(path, map_location=self.device, weights_only=True))
return self

def act_(self, obs, test=False):
Expand Down
5 changes: 2 additions & 3 deletions tmrl/config/config_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# from tmrl.custom.custom_checkpoints import load_run_instance_images_dataset, dump_run_instance_images_dataset
# third-party imports

import numpy as np
import rtgym

# local imports
import tmrl.config.config_constants as cfg
from tmrl.training_offline import TorchTrainingOffline
from tmrl.custom.custom_gym_interfaces import TM2020Interface, TM2020InterfaceLidar, TM2020InterfaceLidarProgress
from tmrl.custom.tm.tm_gym_interfaces import TM2020Interface, TM2020InterfaceLidar, TM2020InterfaceLidarProgress
from tmrl.custom.custom_memories import MemoryTMFull, MemoryTMLidar, MemoryTMLidarProgress, get_local_buffer_sample_lidar, get_local_buffer_sample_lidar_progress, get_local_buffer_sample_tm20_imgs
from tmrl.custom.custom_preprocessors import obs_preprocessor_tm_act_in_obs, obs_preprocessor_tm_lidar_act_in_obs,obs_preprocessor_tm_lidar_progress_act_in_obs
from tmrl.custom.tm.tm_preprocessors import obs_preprocessor_tm_act_in_obs, obs_preprocessor_tm_lidar_act_in_obs, obs_preprocessor_tm_lidar_progress_act_in_obs
from tmrl.envs import GenericGymEnv
from tmrl.custom.custom_models import SquashedGaussianMLPActor, MLPActorCritic, REDQMLPActorCritic, RNNActorCritic, SquashedGaussianRNNActor, SquashedGaussianVanillaCNNActor, VanillaCNNActorCritic, SquashedGaussianVanillaColorCNNActor, VanillaColorCNNActorCritic
from tmrl.custom.custom_algorithms import SpinupSacAgent as SAC_Agent
Expand Down
2 changes: 1 addition & 1 deletion tmrl/custom/custom_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# local imports
import tmrl.custom.custom_models as core
from tmrl.custom.utils.nn import copy_shared, no_grad
from tmrl.util import cached_property, partial
from tmrl.util import cached_property
from tmrl.training import TrainingAgent
import tmrl.config.config_constants as cfg

Expand Down
Empty file added tmrl/custom/tm/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

# local imports
import tmrl.config.config_constants as cfg
from tmrl.custom.utils.compute_reward import RewardFunction
from tmrl.custom.utils.control_gamepad import control_gamepad, gamepad_reset, gamepad_close_finish_pop_up_tm20
from tmrl.custom.utils.control_mouse import mouse_close_finish_pop_up_tm20
from tmrl.custom.utils.control_keyboard import apply_control, keyres
from tmrl.custom.utils.window import WindowInterface
from tmrl.custom.utils.tools import Lidar, TM2020OpenPlanetClient, save_ghost
from tmrl.custom.tm.utils.compute_reward import RewardFunction
from tmrl.custom.tm.utils.control_gamepad import control_gamepad, gamepad_reset, gamepad_close_finish_pop_up_tm20
from tmrl.custom.tm.utils.control_mouse import mouse_close_finish_pop_up_tm20
from tmrl.custom.tm.utils.control_keyboard import apply_control, keyres
from tmrl.custom.tm.utils.window import WindowInterface
from tmrl.custom.tm.utils.tools import Lidar, TM2020OpenPlanetClient, save_ghost

# Globals ==============================================================================================================

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# third-party imports
import numpy as np
import logging
import cv2


# OBSERVATION PREPROCESSING ==================================
Expand Down
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,9 @@

def mouse_close_finish_pop_up_tm20(small_window=False):
if small_window:
click(138, 100)
click(138, 108)
else:
click(550, 300) # clicks where the "improve" button is supposed to be
mouseUp()

def mouse_change_name_replay_tm20(small_window=False):
if small_window:
click(138, 124)
click(138, 124)
else:
click(500, 390)
click(500, 390)

def mouse_close_replay_window_tm20(small_window=False):
if small_window:
click(130, 95)
else:
click(500, 280)
click(550, 320) # clicks where the "improve" button is supposed to be
mouseUp()

def mouse_save_replay_tm20(small_window=False):
Expand All @@ -34,29 +19,23 @@ def mouse_save_replay_tm20(small_window=False):
click(130, 110)
mouseUp()
time.sleep(0.2)
click(130, 104)
click(130, 108)
mouseUp()
else:
click(500, 335)
click(500, 345)
mouseUp()
time.sleep(0.2)
click(500, 310)
click(500, 320)
mouseUp()

else:

def mouse_close_finish_pop_up_tm20(small_window=False):
pass

def mouse_change_name_replay_tm20(small_window=False):
pass

def mouse_save_replay_tm20(small_window=False):
pass

def mouse_close_replay_window_tm20(small_window=False):
pass


if __name__ == "__main__":
# standard library imports
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tmrl/tools/check_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from rtgym.envs.real_time_env import DEFAULT_CONFIG_DICT

# local imports
from tmrl.custom.custom_gym_interfaces import TM2020Interface, TM2020InterfaceLidar
from tmrl.custom.utils.window import WindowInterface
from tmrl.custom.utils.tools import Lidar
from tmrl.custom.tm.tm_gym_interfaces import TM2020Interface, TM2020InterfaceLidar
from tmrl.custom.tm.utils.window import WindowInterface
from tmrl.custom.tm.utils.tools import Lidar
import tmrl.config.config_constants as cfg
import logging

Expand Down
2 changes: 1 addition & 1 deletion tmrl/tools/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# local imports
import tmrl.config.config_constants as cfg
from tmrl.custom.utils.tools import TM2020OpenPlanetClient
from tmrl.custom.tm.utils.tools import TM2020OpenPlanetClient
import logging


Expand Down

0 comments on commit dccef7c

Please sign in to comment.