Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v1.0.0' into dev_edt_asset
Browse files Browse the repository at this point in the history
  • Loading branch information
hzheng40 committed May 3, 2024
2 parents 0c82a66 + 5dbba85 commit 07aa0af
Show file tree
Hide file tree
Showing 41 changed files with 326 additions and 946 deletions.
22 changes: 12 additions & 10 deletions examples/random_trackgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ def main(args):
outdir.mkdir(parents=True, exist_ok=True)

for i in range(n_maps):
try:
print(f"[info] creating track {i}")
track, track_int, track_ext = create_track()
convert_track(track, track_int, track_ext, i, outdir)
print(f"[info] saved track {i} in {outdir}/")
except Exception as _: # noqa: F841
print("[error] failed to create track. Retrying...")
continue
print()
while True:
try:
print(f"[info] creating track {i}")
track, track_int, track_ext = create_track()
convert_track(track, track_int, track_ext, i, outdir)
print(f"[info] saved track {i} in {outdir}/")
break
except Exception as _: # noqa: F841
print("[error] failed to create track. Retrying...")
continue
print()


def create_track():
Expand Down Expand Up @@ -250,7 +252,7 @@ def convert_track(track, track_int, track_ext, track_id, outdir):
"--seed", type=int, default=123, help="The seed for the numpy rng"
)
parser.add_argument(
"--n_maps", type=int, default=3, help="Number of maps to create"
"--n-maps", type=int, default=3, help="Number of maps to create"
)
parser.add_argument(
"--outdir", type=pathlib.Path, default="./maps", help="Out directory"
Expand Down
4 changes: 2 additions & 2 deletions examples/run_in_empty_track.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from waypoint_follow import PurePursuitPlanner
from f110_gym.envs.track import Track
from f1tenth_gym.envs.track import Track
import gymnasium as gym


Expand All @@ -20,7 +20,7 @@ def main():

# env and planner
env = gym.make(
"f110_gym:f110-v0",
"f1tenth_gym:f1tenth-v0",
config={
"map": track,
"num_agents": 1,
Expand Down
2 changes: 1 addition & 1 deletion examples/video_recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def main():
}

env = gym.make(
"f110_gym:f110-v0",
"f1tenth_gym:f1tenth-v0,
config={
"map": "Spielberg",
"num_agents": 1,
Expand Down
2 changes: 1 addition & 1 deletion examples/waypoint_follow.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def main():

num_agents = 3
env = gym.make(
"f110_gym:f110-v0",
"f1tenth_gym:f1tenth-v0",
config={
"map": "Spielberg",
"num_agents": num_agents,
Expand Down
6 changes: 6 additions & 0 deletions f1tenth_gym/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import gymnasium as gym

gym.register(
id="f1tenth-v0",
entry_point="f1tenth_gym.envs:F110Env",
)
File renamed without changes.
2 changes: 1 addition & 1 deletion gym/f110_gym/envs/action.py → f1tenth_gym/envs/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import warnings
import gymnasium as gym
import numpy as np
from f110_gym.envs.dynamic_models import pid_steer, pid_accl
from .dynamic_models import pid_steer, pid_accl


class LongitudinalActionEnum(Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"""
from __future__ import annotations
import numpy as np
from f110_gym.envs.dynamic_models import DynamicModel
from f110_gym.envs.action import CarAction
from f110_gym.envs.collision_models import collision_multiple, get_vertices
from f110_gym.envs.integrator import EulerIntegrator, IntegratorType
from f110_gym.envs.laser_models import ScanSimulator2D, check_ttc_jit, ray_cast
from f110_gym.envs.track import Track
from .dynamic_models import DynamicModel
from .action import CarAction
from .collision_models import collision_multiple, get_vertices
from .integrator import EulerIntegrator, IntegratorType
from .laser_models import ScanSimulator2D, check_ttc_jit, ray_cast
from .track import Track


class RaceCar(object):
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions gym/f110_gym/envs/f110_env.py → f1tenth_gym/envs/f110_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
# gym imports
import gymnasium as gym

from f110_gym.envs.action import (CarAction,
from .action import (CarAction,
from_single_to_multi_action_space)
from f110_gym.envs.integrator import IntegratorType
from f110_gym.envs.rendering import make_renderer
from .integrator import IntegratorType
from .rendering import make_renderer

from f110_gym.envs.track import Track
from .track import Track

# base classes
from f110_gym.envs.base_classes import Simulator, DynamicModel
from f110_gym.envs.observation import observation_factory
from f110_gym.envs.reset import make_reset_fn
from f110_gym.envs.track import Track
from f110_gym.envs.utils import deep_update
from .base_classes import Simulator, DynamicModel
from .observation import observation_factory
from .reset import make_reset_fn
from .track import Track
from .utils import deep_update


# others
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import unittest

import numpy as np
from f110_gym.envs.track import Track
from .track import Track
from numba import njit
from scipy.ndimage import distance_transform_edt as edt

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pathlib
from typing import Any, Optional

from f110_gym.envs.rendering.renderer import RenderSpec, EnvRenderer
from f110_gym.envs.track import Track
from .renderer import RenderSpec, EnvRenderer
from ..track import Track


def make_renderer(
Expand All @@ -28,7 +28,7 @@ def make_renderer(
render_fps : int, optional
rendering frames per second, by default 100
"""
from f110_gym.envs.rendering.rendering_pygame import PygameEnvRenderer
from .rendering_pygame import PygameEnvRenderer

cfg_file = pathlib.Path(__file__).parent.absolute() / "rendering.yaml"
render_spec = RenderSpec.from_yaml(cfg_file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import numpy as np
import pygame

from f110_gym.envs.collision_models import get_vertices
from f110_gym.envs.rendering import RenderSpec
from ..collision_models import get_vertices
from . import RenderSpec


class TextObject:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import pygame
from PIL import ImageColor

from f110_gym.envs.rendering.objects import (
from .objects import (
Map,
Car,
TextObject,
)
from f110_gym.envs.track import Track
from f110_gym.envs.rendering.renderer import EnvRenderer, RenderSpec
from ..track import Track
from .renderer import EnvRenderer, RenderSpec

# one-line instructions visualized at the top of the screen (if show_info=True)
INSTRUCTION_TEXT = "Mouse click (L/M/R): Change POV - 'S' key: On/Off"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from f110_gym.envs.reset.masked_reset import GridResetFn, AllTrackResetFn
from f110_gym.envs.reset.reset_fn import ResetFn
from f110_gym.envs.track import Track
from .masked_reset import GridResetFn, AllTrackResetFn
from .reset_fn import ResetFn
from ..track import Track


def make_reset_fn(type: str | None, track: Track, num_agents: int, **kwargs) -> ResetFn:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import numpy as np

from f110_gym.envs.reset.reset_fn import ResetFn
from f110_gym.envs.reset.utils import sample_around_waypoint
from f110_gym.envs.track import Track, Raceline
from .reset_fn import ResetFn
from .utils import sample_around_waypoint
from ..track import Track, Raceline


class MaskedResetFn(ResetFn):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from f110_gym.envs.track import Raceline
from ..track import Raceline


def sample_around_waypoint(
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import numpy as np

from f110_gym.envs.rendering import EnvRenderer
from f110_gym.envs.track.cubic_spline import CubicSpline2D
from ..rendering import EnvRenderer
from .cubic_spline import CubicSpline2D


class Raceline:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from PIL.Image import Transpose
from yamldataclassconfig.config import YamlDataClassConfig

from f110_gym.envs.track import Raceline
from f110_gym.envs.track.cubic_spline import CubicSpline2D
from f110_gym.envs.track.utils import find_track_dir
from . import Raceline
from .cubic_spline import CubicSpline2D
from .utils import find_track_dir


@dataclass
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions gym/f110_gym/__init__.py

This file was deleted.

Loading

0 comments on commit 07aa0af

Please sign in to comment.