Making a known turn behavior
The known turn behavior is a variation of the always face North behavior. The idea is to measure the angle at the start of the turn and then make the set point the new intended angle.
We’ll make it so that the whole app will accept a difference in the intended angle, offsetting the last intended angle, with the whole app starting based on the robot’s current heading. The user can send +30
to turn 30 degrees and -90
to rotate 90 degrees back.
The block diagram is exactly as before, as we only need to manipulate the expected heading. Make a copy of face_north
in a folder called known_turn
. Let’s rename the controller IMUTurnController
:
class IMUTurnController: def __init__(self): self.pid = pid_controller.PIDController(0.01, 0.008, 0) self.target = 0
The update
method doesn’t change, as shown here...