Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 a ) Run the baseline simulator & generate a plot Here's an example of how to run the simulator for a few timesteps. In
a 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 plotpath method. At a minimum, you should plot the position over time the first elements of the state vector
You are welcome to add other capabilities to your plotpath function as you go through the assignment eg visualizing the heading
angle andor the goal coordinate but this is not necessary for this part. You probably should make your axes have the same scale eg
using pltaxis equal
def plotpathenv: gymnasium.Env, observationhistory: listnpndarray None:
## Your Implementation Here ##
raise NotImplementedError
def dummyunicyclecontrollercurrentstate: npndarray npndarray:
return nparray # linear speed, angular speed
def simulatenstepsenv: gymnasium.Env, numsteps: int, controller: Callable:
observationhistory
observationhistory.append obs
printfinitial state: obs
# run the simulator for a few steps and see how the state evolves
for in range numsteps:
action controllerobs
obs, terminated, env.stepaction
observationhistory.append obs
print fcurrent state: obs
if terminated:
break
return observationhistory
# Tell the simulator to its builtin kinematic model
env.unwrapped. motionmodel gymneuracing. motionmodels.Unicycle
# Run the simulation and plot the path taken
numsteps
observationhistory simulatenstepsenv numsteps, dummyunicyclecontroller
plotpathenv observationhistory
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started