This is the final project for ME 461 Computer Control of Mechanical Systems. For this project, we added three "arms" to the two-wheel self-balancing Segbot that we have been working with over the semester to allow it to stand back up even if it is pushed pass its balancing limits.
- Below is the demonstration of how our robot works:
segbot normal condition :
segbot pushed past balance limit (and how it self corrects):
- Diagram of code logic:
- Video explaining actuators we used for the project and how they are connected to the Launchpad.
• If any algorithms used, make sure to explain how they were used and have links to websites or papers that explain the algorithm. (Nick/Yongseok)
The code for the self-correcting Segbot makes heavy use of code provided for and worked on during the labs for ME 461. No specific algorithms were created for the self-correcting aspect of the Segbot, but the code makes use of a state machine to keep track of what the Segbot is currently doing and what it should do next.
To adjust the angle of the three servo motors used for each of the arms, the angles are set to specific desired angle values, and the code then rotates each arm at a set angular velocity until the angles are within the desired angle.
To check to see if the segbot has fallen over, the tilt value provided by the IMU is checked to see if it is outside of the allowable tolerance for the segbot to stand up on its own. The function returns 1 if it is tilted too far forward, 0 if it is within the acceptable range, and -1 if it is tilted too far back.
There are five states that the Segbot moves between over the course of the program. The five states can be thought of as "the segbot is waiting idly," "the segbot has just fallen over", "the arms are being lowered," "the arms are being raised," and "the segbot is balancing on its wheels like normal."
The fourth and fifth states, raising the arms and balancing like normal, are not mutually exclusive with each other. In other words, the robot can raise its arms and balance itself with its wheels at the same time. All other states are mutually exclusive.
When the Segbot code first runs, it has the idle period to calibrate the IMU, but after that initial delay, we added another 10 second delay to allow the measured tilt value to steady out. In this first state, the segbot sits idly while gathering more IMU measurements.
After this initial period ends, the logic for the state machine starts being executed. Each time the logic is run, the segbot checks to see if the robot has fallen to either side and saves it. Then, it checks to see if the robot has fallen over and the arms are not currently being lowered. If this is true, the given cycle is the first cycle that the robot detects that it has fallen, so it turns off the balancing and enters the 'lowering arms' state. If it is not true and the wheels are on, the balancing continues.
During the 'lowering arms' state, the code sets the arms to a predetermined angle that props the segbot up enough to reenter the acceptable range of tilt values where the segbot can balance itself. Each cycle, a check is done to see if it is upright again. If it is, the segbot exits the 'lowering arms' state, resumes self-balancing, and enters the 'raising arms' state.
The raising arms state, similarly to the 'lowering arms' state, is when the desired angles of the arms is set to a specific angle and remains in this state until it reaches that angle. In this case, the desired angle is nearly vertical to move the arms out of the way of the segbot balancing. Once the actual angle of the arms is within the bound for reaching the upright position, the 'raising arms' state is exited.
The last state is where the segbot runs its self-balancing code from previous labs. This is the default state if the robot has not fallen and the arms are not being lowered.
Comments