Control System Homework 2
Control System Homework 2
Controllability:
Observability:
Purpose:
How it Works:
1. Prediction Step:
o Predict the next state and its covariance based on the current
state and process model.
x^k∣k−1=Ax^k−1+Buk\hat{x}_{k|k-1} = A \hat{x}_{k-1} + B
u_kx^k∣k−1=Ax^k−1+Buk Pk∣k−1=APk−1AT+QP_{k|k-1} = A P_{k-1}
A^T + QPk∣k−1=APk−1AT+Q
where:
2. Update Step:
where:
o zkz_kzk: Measurement,
Applications:
3. Implementation
Python Code:
import numpy as np
np.random.seed(42)
n_steps = 50
measurements[k] = H @ true_state[k] +
np.random.normal(0, np.sqrt(R[0, 0]))
# Kalman filter
estimated_state = np.zeros_like(true_state)
# Prediction step
x_pred = A @ estimated_state[k-1]
P_pred = A @ P @ A.T + Q
# Update step
P = (np.eye(1) - K @ H) @ P_pred
# Plot results
plt.figure(figsize=(10, 6))
plt.legend()
plt.xlabel("Time step")
plt.ylabel("State")
plt.show()56
Example:
In a self-driving car, GPS data might be inaccurate due to noise, and IMU
data might drift over time. The Kalman filter combines these sources to
provide a reliable estimate of the car's position and velocity.