diff --git a/f1tenth_gym/envs/f110_env.py b/f1tenth_gym/envs/f110_env.py index ba301e76..f6b62916 100644 --- a/f1tenth_gym/envs/f110_env.py +++ b/f1tenth_gym/envs/f110_env.py @@ -27,25 +27,21 @@ # gym imports import gymnasium as gym -from .action import (CarAction, - from_single_to_multi_action_space) -from .integrator import IntegratorType -from .rendering import make_renderer +# others +import numpy as np -from .track import Track +from .action import CarAction, from_single_to_multi_action_space # base classes -from .base_classes import Simulator, DynamicModel +from .base_classes import DynamicModel, Simulator +from .integrator import IntegratorType from .observation import observation_factory +from .rendering import make_renderer from .reset import make_reset_fn from .track import Track from .utils import deep_update -# others -import numpy as np - - class F110Env(gym.Env): """ OpenAI gym environment for F1TENTH @@ -143,14 +139,14 @@ def __init__(self, config: dict = None, render_mode=None, **kwargs): model=self.model, action_type=self.action_type, ) - self.sim.set_map(self.map, config["scale"]) + self.sim.set_map(self.map, self.config["scale"]) if isinstance(self.map, Track): self.track = self.map else: self.track = Track.from_track_name( self.map, - track_scale=config["scale"], + track_scale=self.config["scale"], ) # load track in gym env for convenience # observations @@ -202,7 +198,6 @@ def fullscale_vehicle_params(cls) -> dict: "I": 1538.8533713561394, "width": 1.674, "length": 4.298, - # steering constraints "s_min": -0.91, "s_max": 0.91, @@ -212,17 +207,15 @@ def fullscale_vehicle_params(cls) -> dict: "kappa_dot_max": 0.4, # maximum curvature rate rate "kappa_dot_dot_max": 20, - # Longitudinal constraints "v_switch": 4.755, "a_max": 11.5, "v_min": -13.9, "v_max": 45.8, # maximum longitudinal jerk [m/s^3] - "j_max": 10.0e+3, + "j_max": 10.0e3, # maximum longitudinal jerk change [m/s^4] "j_dot_max": 10.0e3, - # Extra parameters (for future use in multibody simulation) # sprung mass [kg] SMASS "m_s": 1094.542720290477, @@ -230,7 +223,6 @@ def fullscale_vehicle_params(cls) -> dict: "m_uf": 65.67256321742863, # unsprung mass rear [kg] UMASSR "m_ur": 65.67256321742863, - # moments of inertia of sprung mass # moment of inertia for sprung mass in roll [kg m^2] IXS "I_Phi_s": 244.04723069965206, @@ -240,7 +232,6 @@ def fullscale_vehicle_params(cls) -> dict: "I_z": 1538.8533713561394, # moment of inertia cross product [kg m^2] IXZ "I_xz_s": 0.0, - # suspension parameters # suspension spring rate (front) [N/m] KSF "K_sf": 21898.332429625985, @@ -250,7 +241,6 @@ def fullscale_vehicle_params(cls) -> dict: "K_sr": 21898.332429625985, # suspension damping rate (rear) [N s/m] KSDR "K_sdr": 1459.3902937206362, - # geometric parameters # track width front [m] TRWF "T_f": 1.389888, @@ -258,7 +248,6 @@ def fullscale_vehicle_params(cls) -> dict: "T_r": 1.423416, # lateral spring rate at compliant compliant pin joint between M_s and M_u [N/m] KRAS "K_ras": 175186.65943700788, - # auxiliary torsion roll stiffness per axle (normally negative) (front) [N m/rad] KTSF "K_tsf": -12880.270509148304, # auxiliary torsion roll stiffness per axle (normally negative) (rear) [N m/rad] KTSR @@ -267,33 +256,27 @@ def fullscale_vehicle_params(cls) -> dict: "K_rad": 10215.732056044453, # vertical spring rate of tire [N/m] KZT "K_zt": 189785.5477234252, - # center of gravity height of total mass [m] HCG (mainly required for conversion to other vehicle models) "h_cg": 0.5577840000000001, # height of roll axis above ground (front) [m] HRAF "h_raf": 0.0, # height of roll axis above ground (rear) [m] HRAR "h_rar": 0.0, - # M_s center of gravity above ground [m] HS "h_s": 0.59436, - # moment of inertia for unsprung mass about x-axis (front) [kg m^2] IXUF "I_uf": 32.53963075995361, # moment of inertia for unsprung mass about x-axis (rear) [kg m^2] IXUR "I_ur": 32.53963075995361, # wheel inertia, from internet forum for 235/65 R 17 [kg m^2] "I_y_w": 1.7, - # lateral compliance rate of tire, wheel, and suspension, per tire [m/N] KLT "K_lt": 1.0278264878518764e-05, # effective wheel/tire radius chosen as tire rolling radius RR taken from ADAMS documentation [m] "R_w": 0.344, - # split of brake and engine torque "T_sb": 0.76, "T_se": 1, - # suspension parameters # [rad/m] DF "D_f": -0.6233595800524934, @@ -303,7 +286,6 @@ def fullscale_vehicle_params(cls) -> dict: "E_f": 0, # [needs conversion if nonzero] ER "E_r": 0, - } return params @@ -369,7 +351,9 @@ def configure(self, config: dict) -> None: if hasattr(self, "action_space"): # if some parameters changed, recompute action space - self.action_type = CarAction(self.config["control_input"], params=self.params) + self.action_type = CarAction( + self.config["control_input"], params=self.params + ) self.action_space = from_single_to_multi_action_space( self.action_type.space, self.num_agents ) diff --git a/f1tenth_gym/envs/rendering/__init__.py b/f1tenth_gym/envs/rendering/__init__.py index ea6ac128..bcfa6bfb 100644 --- a/f1tenth_gym/envs/rendering/__init__.py +++ b/f1tenth_gym/envs/rendering/__init__.py @@ -2,12 +2,12 @@ from typing import Any, Optional from .renderer import RenderSpec, EnvRenderer -from ..track import Track +# from ..track import Track This is due to a circular import def make_renderer( params: dict[str, Any], - track: Track, + track: "Track", agent_ids: list[str], render_mode: Optional[str] = None, render_fps: Optional[int] = 100, @@ -33,7 +33,7 @@ def make_renderer( if render_spec.render_type == "pygame": from .rendering_pygame import PygameEnvRenderer as EnvRenderer - elif render_spec.render_type == "pyqt6": + elif render_spec.render_type == "pyqt6": from .rendering_pyqt import PyQtEnvRenderer as EnvRenderer else: raise ValueError(f"Unknown render type: {render_spec.render_type}") diff --git a/poetry.lock b/poetry.lock index d1b4be77..2a6de40f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1644,6 +1644,84 @@ files = [ [package.extras] diagrams = ["jinja2", "railroad-diagrams"] +[[package]] +name = "pyqt6" +version = "6.7.1" +description = "Python bindings for the Qt cross platform application toolkit" +optional = false +python-versions = ">=3.8" +files = [ + {file = "PyQt6-6.7.1-1-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:7f397f4b38b23b5588eb2c0933510deb953d96b1f0323a916c4839c2a66ccccc"}, + {file = "PyQt6-6.7.1-1-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:c2f202b7941aa74e5c7e1463a6f27d9131dbc1e6cabe85571d7364f5b3de7397"}, + {file = "PyQt6-6.7.1-cp38-abi3-macosx_11_0_universal2.whl", hash = "sha256:f053378e3aef6248fa612c8afddda17f942fb63f9fe8a9aeb2a6b6b4cbb0eba9"}, + {file = "PyQt6-6.7.1-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:0adb7914c732ad1dee46d9cec838a98cb2b11bc38cc3b7b36fbd8701ae64bf47"}, + {file = "PyQt6-6.7.1-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:2d771fa0981514cb1ee937633dfa64f14caa902707d9afffab66677f3a73e3da"}, + {file = "PyQt6-6.7.1-cp38-abi3-win_amd64.whl", hash = "sha256:fa3954698233fe286a8afc477b84d8517f0788eb46b74da69d3ccc0170d3714c"}, + {file = "PyQt6-6.7.1.tar.gz", hash = "sha256:3672a82ccd3a62e99ab200a13903421e2928e399fda25ced98d140313ad59cb9"}, +] + +[package.dependencies] +PyQt6-Qt6 = ">=6.7.0,<6.8.0" +PyQt6-sip = ">=13.8,<14" + +[[package]] +name = "pyqt6-qt6" +version = "6.7.2" +description = "The subset of a Qt installation needed by PyQt6." +optional = false +python-versions = "*" +files = [ + {file = "PyQt6_Qt6-6.7.2-py3-none-macosx_10_14_x86_64.whl", hash = "sha256:065415589219a2f364aba29d6a98920bb32810286301acbfa157e522d30369e3"}, + {file = "PyQt6_Qt6-6.7.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7f817efa86a0e8eda9152c85b73405463fbf3266299090f32bbb2266da540ead"}, + {file = "PyQt6_Qt6-6.7.2-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:05f2c7d195d316d9e678a92ecac0252a24ed175bd2444cc6077441807d756580"}, + {file = "PyQt6_Qt6-6.7.2-py3-none-manylinux_2_28_x86_64.whl", hash = "sha256:fc93945eaef4536d68bd53566535efcbe78a7c05c2a533790a8fd022bac8bfaa"}, + {file = "PyQt6_Qt6-6.7.2-py3-none-win_amd64.whl", hash = "sha256:b2d7e5ddb1b9764cd60f1d730fa7bf7a1f0f61b2630967c81761d3d0a5a8a2e0"}, +] + +[[package]] +name = "pyqt6-sip" +version = "13.8.0" +description = "The sip module support for PyQt6" +optional = false +python-versions = ">=3.8" +files = [ + {file = "PyQt6_sip-13.8.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:cedd554c643e54c4c2e12b5874781a87441a1b405acf3650a4a2e1df42aae231"}, + {file = "PyQt6_sip-13.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f57275b5af774529f9838adcfb58869ba3ebdaf805daea113bb0697a96a3f3cb"}, + {file = "PyQt6_sip-13.8.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:835ed22eab977f75fd77e60d4ff308a1fa794b1d0c04849311f36d2a080cdf3b"}, + {file = "PyQt6_sip-13.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d8b22a6850917c68ce83fc152a8b606ecb2efaaeed35be53110468885d6cdd9d"}, + {file = "PyQt6_sip-13.8.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:b203b6fbae4a8f2d27f35b7df46200057033d9ecd9134bcf30e3eab66d43572c"}, + {file = "PyQt6_sip-13.8.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:beaddc1ec96b342f4e239702f91802706a80cb403166c2da318cec4ad8b790cb"}, + {file = "PyQt6_sip-13.8.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:a5c086b7c9c7996ea9b7522646cc24eebbf3591ec9dd38f65c0a3fdb0dbeaac7"}, + {file = "PyQt6_sip-13.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:dd168667addf01f8a4b0fa7755323e43e4cd12ca4bade558c61f713a5d48ba1a"}, + {file = "PyQt6_sip-13.8.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:33d9b399fc9c9dc99496266842b0fb2735d924604774e97cf9b555667cc0fc59"}, + {file = "PyQt6_sip-13.8.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:056af69d1d8d28d5968066ec5da908afd82fc0be07b67cf2b84b9f02228416ce"}, + {file = "PyQt6_sip-13.8.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:08dd81037a2864982ece2bf9891f3bf4558e247034e112993ea1a3fe239458cb"}, + {file = "PyQt6_sip-13.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:fbb249b82c53180f1420571ece5dc24fea1188ba435923edd055599dffe7abfb"}, + {file = "PyQt6_sip-13.8.0-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:6bce6bc5870d9e87efe5338b1ee4a7b9d7d26cdd16a79a5757d80b6f25e71edc"}, + {file = "PyQt6_sip-13.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd81144b0770084e8005d3a121c9382e6f9bc8d0bb320dd618718ffe5090e0e6"}, + {file = "PyQt6_sip-13.8.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:755beb5d271d081e56618fb30342cdd901464f721450495cb7cb0212764da89e"}, + {file = "PyQt6_sip-13.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:7a0bbc0918eab5b6351735d40cf22cbfa5aa2476b55e0d5fe881aeed7d871c29"}, + {file = "PyQt6_sip-13.8.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:7f84c472afdc7d316ff683f63129350d645ef82d9b3fd75a609b08472d1f7291"}, + {file = "PyQt6_sip-13.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b1bf29e95f10a8a00819dac804ca7e5eba5fc1769adcd74c837c11477bf81954"}, + {file = "PyQt6_sip-13.8.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:9ea9223c94906efd68148f12ae45b51a21d67e86704225ddc92bce9c54e4d93c"}, + {file = "PyQt6_sip-13.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:2559afa68825d08de09d71c42f3b6ad839dcc30f91e7c6d0785e07830d5541a5"}, + {file = "PyQt6_sip-13.8.0.tar.gz", hash = "sha256:2f74cf3d6d9cab5152bd9f49d570b2dfb87553ebb5c4919abfde27f5b9fd69d4"}, +] + +[[package]] +name = "pyqtgraph" +version = "0.13.7" +description = "Scientific Graphics and GUI Library for Python" +optional = false +python-versions = ">=3.9" +files = [ + {file = "pyqtgraph-0.13.7-py3-none-any.whl", hash = "sha256:7754edbefb6c367fa0dfb176e2d0610da3ada20aa7a5318516c74af5fb72bf7a"}, + {file = "pyqtgraph-0.13.7.tar.gz", hash = "sha256:64f84f1935c6996d0e09b1ee66fe478a7771e3ca6f3aaa05f00f6e068321d9e3"}, +] + +[package.dependencies] +numpy = ">=1.22.0" + [[package]] name = "pytest" version = "7.4.4" @@ -2174,4 +2252,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = ">=3.9" -content-hash = "efdbfe91976ae78442e45faa2c5eda3e54ccbf6d92323c504fcedf0ac3637dcc" +content-hash = "122155f8f9834afa2311682f69cf154059146c4f15599cb87c4f7db9a7d19bb4"