Question: 1 a ) Run the baseline simulator & generate a plot Here's an example of how to run the simulator for a few timesteps. In

1a) Run the baseline simulator & generate a plot
Here's an example of how to run the simulator for a few timesteps. In this assignment, we told the simulator to return the true state of the
environment (in future assignments, we'll only give noisy sensor data).
In this problem, you should make a plot of the system's state over time. This will be helpful as you debug future parts of the assignment. This
part uses the Unicycle kinematic model that's built into the simulator.
Deliverables:
Implement the plot_path method. At a minimum, you should plot the (x,y) position over time (the first 2 elements of the state vector).
You are welcome to add other capabilities to your plot_path function as you go through the assignment (e.g., visualizing the heading
angle and/or the goal coordinate), but this is not necessary for this part. You probably should make your axes have the same scale (e.g.,
using plt.axis ('equal')).
[] def plot_path(env: gymnasium.Env, observation_history: list[np.ndarray]) None:
## Your Implementation Here ##
raise NotImplementedError
[] def dummy_unicycle_controller(current_state: np.ndarray) np.ndarray:
return np.array([3.,0.2]) # [linear speed, angular speed]
def simulate_n_steps(env: gymnasium.Env, num_steps: int, controller: Callable):
observation_history =[]
observation_history.append (obs)
print(f"initial state: {obs}")
# run the simulator for a few steps and see how the state evolves
for _ in range (num_steps):
action = controller(obs)
obs, _, terminated, ,,_= env.step(action)
observation_history.append (obs)
print (f"current state: {obs}")
if terminated:
break
return observation_history
[] # Tell the simulator to its built-in kinematic model
env.unwrapped. motion_model = gym_neu_racing. motion_models.Unicycle()
# Run the simulation and plot the path taken
num_steps =10
observation_history = simulate_n_steps(env, num_steps, dummy_unicycle_controller)
plot_path(env, observation_history)
 1a) Run the baseline simulator & generate a plot Here's an

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!