This assignment focuses on improving control of the balancing robot. I am providing example code for balancing, which will allow you to collect data, make a better model, and improve the control (or at least walk through the steps of designing a controller).
My modeling approach is described by the elegoo web pages. You have already (turn in Assignment 5 if you haven't already) modeled the motors driving the wheels. I talk about modeling the body and using the IMU on the web page Estimating missing measurements: wheel velocity and body angle. I talk about designing a controller on the web page Getting the robot to balance.
balance10 is the updated example balance software. After updating ay0 and gx0 from your IMU test above, try running this program on your robot. In theory the robot starts leaning on the plastic part that sticks out front. You can make it easier for the robot (and more likely that the balance program will work) by reducing this initial lean by taping some cardboard or foam to the bottom of the plastic part it leans on. You can make it safer for the robot by attaching some chopsticks to the sides of the robot sticking out the back, so it can't fall on its back, or attaching some more foam to the back. Be sure to strain relief both ends of the USB cable, so when the robot zooms off in some random direction you don't break the connector on the Arduino or your laptop.
Here is some example data from my robot balancing. The last run f003 is a failed launch.
What did you have to do to get the robot to balance at all? Just adjust the sensor biases? Change the controller gains? Change the state estimator? Something else?
The model can be a linear state space model with A, B, C, and D matrices, or a nonlinear model that covers a wider range. The model can be anything else you want to try out, like a neural network model.
The most important thing to turn in for this section is a writeup of what you did and why you did it. What were the hypotheses or questions you were exploring, and what were the results? What did you learn?
One direction that is interesting to explore is to make the controller adaptive. Can you eliminate the need to measure the sensor biases in advance by estimating them as the robot moves? Can you handle loads added to the robot (added weights on the robot, or having the robot drag something) by estimating these perturbations during operation and compensating for them?
How can you demonstrate your controller works better? You could show that launches work from a wider range of initial conditions. You could show that the robot could handle bigger feedforward perturbations added to the motor commands, or biases or noise added to the sensors. You could add weights which change the body mass and the height of the body center of mass, and show the new controller handles a wider range of robot modifications.
Make a video of your improved controller working (and hopefully some exciting tests) and put it on YouTube. Put "16299 Elegoo Tumbller Robot" in the video title (along with anything else you want) so it will later show up when people google any of those terms. Make the video public. Turn in the URL along with the writeup for this part.
The most important thing to turn in for this section is a writeup of what you did and why you did it. What were the hypotheses or questions you were exploring, and what were the results? What did you learn?