-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v1.0.0' into dev_dynamics_updates
# Conflicts: # gym/f110_gym/envs/base_classes.py # gym/f110_gym/envs/dynamic_models.py
- Loading branch information
Showing
19 changed files
with
1,193 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import time | ||
import gymnasium as gym | ||
import gymnasium.wrappers | ||
import numpy as np | ||
|
||
from waypoint_follow import PurePursuitPlanner | ||
|
||
|
||
def main(): | ||
work = { | ||
"mass": 3.463388126201571, | ||
"lf": 0.15597534362552312, | ||
"tlad": 0.82461887897713965, | ||
"vgain": 1, | ||
} | ||
|
||
env = gym.make( | ||
"f110_gym:f110-v0", | ||
config={ | ||
"map": "Spielberg", | ||
"num_agents": 1, | ||
"timestep": 0.01, | ||
"integrator": "rk4", | ||
"control_input": "speed", | ||
"model": "st", | ||
"observation_config": {"type": "kinematic_state"}, | ||
"params": {"mu": 1.0}, | ||
}, | ||
render_mode="rgb_array", | ||
) | ||
env = gymnasium.wrappers.RecordVideo(env, f"video_{time.time()}") | ||
track = env.unwrapped.track | ||
|
||
planner = PurePursuitPlanner(track=track, wb=0.17145 + 0.15875) | ||
|
||
poses = np.array( | ||
[ | ||
[ | ||
track.raceline.xs[0], | ||
track.raceline.ys[0], | ||
track.raceline.yaws[0], | ||
] | ||
] | ||
) | ||
|
||
obs, info = env.reset(options={"poses": poses}) | ||
done = False | ||
|
||
laptime = 0.0 | ||
start = time.time() | ||
|
||
frames = [env.render()] | ||
while not done and laptime < 15.0: | ||
action = env.action_space.sample() | ||
for i, agent_id in enumerate(obs.keys()): | ||
speed, steer = planner.plan( | ||
obs[agent_id]["pose_x"], | ||
obs[agent_id]["pose_y"], | ||
obs[agent_id]["pose_theta"], | ||
work["tlad"], | ||
work["vgain"], | ||
) | ||
action[i] = [steer, speed] | ||
|
||
obs, step_reward, done, truncated, info = env.step(action) | ||
laptime += step_reward | ||
|
||
frame = env.render() | ||
frames.append(frame) | ||
|
||
print("Sim elapsed time:", laptime, "Real elapsed time:", time.time() - start) | ||
|
||
# close env to trigger video saving | ||
env.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import gymnasium as gym | ||
|
||
gym.register( | ||
id="f110-v0", | ||
entry_point="f110_gym.envs:F110Env", | ||
id="f110-v0", entry_point="f110_gym.envs:F110Env", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.