<jupyter_start><jupyter_text>Example 1: Basics Begin by importing AutoMPC.<jupyter_code>import autompc as ampc
import numpy as np<jupyter_output>Loading AutoMPC...
Finished loading AutoMPC<jupyter_text>SystemsLet's begin by showing how to define a System.  In AutoMPC, a System defines the variables of control and observation for a particular robot.  Here we define `simple_sys` which has to observation variables (x and y) and one control variable (u).  Optionally, the system can also include the time step at which is data is sampled for the system.  Here we define the time step as 0.05 s.<jupyter_code>simple_sys = ampc.System(["x", "y"], ["u"], dt=0.05)<jupyter_output><empty_output><jupyter_text>Given a system, we can access its properties as follows<jupyter_code>print("Observation Dimension: ", simple_sys.obs_dim)
print("Observation Variables: ", simple_sys.observations)

print("Control Dimension: ", simple_sys.ctrl_dim)
print("Control Variables: ", simple_sys.controls)<jupyter_output>Observation Dimension:  2
Observation Variables:  ['x', 'y']
Control Dimension:  1
Control Variables:  ['u']<jupyter_text>TrajectoriesThe Trajectory class stores a sequence of controls and observations.  Trajectories are defined with respect to a particular system.Here we define a zero trajectory for `simple_sys` with 10 time steps.<jupyter_code>traj = ampc.zeros(simple_sys, 10)<jupyter_output><empty_output><jupyter_text>There are a couple different ways to set trajectory values.  We demonstrate a few below:<jupyter_code>traj[0, "x"] = 1.0  # Set x to 1 at timestep 0
traj[1, "u"] = 2.0  # Set u to 2 at timestep 1
traj[2].obs[:] = np.array([3.0, 4.0])  # Set the observation (x and y) to [3,4] at timestep 2
traj[3].ctrl[:] = np.array([5.0])      # Set the control (u) to [5] at timestep 3<jupyter_output><empty_output><jupyter_text>Similarly, there are a number of reading trajectory values.<jupyter_code>print("Value of y at timestep 2: ", traj[2, "y"])
print("Observation at timestep 0: ", traj[0].obs)
print("Control at timestep 1: ", traj[1].ctrl)<jupyter_output>Value of y at timestep 2:  4.0
Observation at timestep 0:  [1. 0.]
Control at timestep 1:  [2.]<jupyter_text>We can also access the entire set of observations and controls for a trajectory as numpy arrays:<jupyter_code>print("Observations")
print("------------")
print(traj.obs)

print("")
print("Controls")
print("--------")
print(traj.ctrls)<jupyter_output>Observations
------------
[[1. 0.]
 [0. 0.]
 [3. 4.]
 [0. 0.]
 [0. 0.]
 [0. 0.]
 [0. 0.]
 [0. 0.]
 [0. 0.]
 [0. 0.]]

Controls
--------
[[0.]
 [2.]
 [0.]
 [5.]
 [0.]
 [0.]
 [0.]
 [0.]
 [0.]
 [0.]]
StarcoderdataJupyterStructuredCleanDedup