Mechatronics HW0x04: Simulation or Reality?

Step 0: Define System from HW0x02

Imports

Define Constants

Define symbols and functions with respect to time

Define M matrix and f matrix

Step 1: Linearize the system

Convert the M and f matrices to Standard state-space form, then perform Jacobian linearization to get A and B matrices.

Create the h vector

Now linearize h by calculating the Jacobian with respect to x at 0 to calculate A matrix

And do the same to find the B matrix (but with respect to u)

Step 2: Open Loop model

Define a Model class, on which to perform all of the responses:

Define a controller function for open-loop control, where the torque provided is zero.

Step 3: Run the simulation for two open-loop cases

Step 3a)

The ball is initially at rest on a level platform directly above the center of gravity of the platform and there is no torque input from the motor. Run this simulation for 1 [s].

Step 3b)

The ball is initially at rest on a level platform offset horizontally from the center of gravity of the platform by 5 [cm] and there is no torque input from the motor. Run this simulation for 0.4 [s].

Step 4: Run the simulation, implementing a regulator

Define a controller function for closed-loop control that acs as a regulator using full state feedback.

Screenshot%20from%202021-05-08%2017-17-15.png

Test the ball with conditions at 3b) for 20s

The ball is initially at rest on a level platform offset horizontally from the center of gravity of the platform by 5 [cm] and there is no torque input from the motor. Run this simulation for 20 [s].