I used a step size of 50, which was slightly higher than the PWM value of 40 I used in lab 6.
I found that the steady state speed was roughly 1318 mm/s and that the 90% rise time was 1.353 seconds.
Using the equations given in lecture, I found that d = 0.00077 and m = 0.00045.
I used u=1 in my calculation of d.
In Jupyter Lab, I initialized my A, B, C, process noise, and sensor noise covariance matrices, as well as my state vector. I used the ballpack variance values given in lecture, as I found them to work very well for my system.
The time required for each TOF sensor sample was 0.51 seconds.
I implemented my Kalman Filter in Jupyter lab and tested it on data from a straight run towards a wall.
The Kalman filter was pretty close to the actual data after the first couple of seconds, taking some time to match up to the actual values. In this plot, it looks like it took a significant amount of time, but that was because the total run was less than five seconds. Changing the values of the covariance matrices did not show a significant improvement.
I used the following function to extrapolate every third distance data point based on the previous two TOF sensor readings. I called this function every time two TOF sensor readings had been taken.
A video of a trial with the extrapolated data points is below. I found that the car would reach roughly the correct distance from the wall, but would then oscillate excessively before stopping, even when the TOF and extrapolated distance data showed that the target distance had been reached quickly. After filming this video, I found that I needed to call the function to stop the motors outside of the PID control function to fix the oscillation issue.
The extrapolated data was somewhat close to the actual data, but it did not predict that the robot would reach the target distance before it did.