Better way to do Heading PID?

what would be a better way to do my heading PID?

Option #1 - compare current angle of the robot to the angle you should be facing to drive straight (since we use odom) and power the left and right sides of the chassis more or less based on that.\

Option #2 - compares the left rotational sensor value to the right rotational sensor value (sees how much more the left sensor has traveled than the right encoder)

Option 2 only modifies the right side, making it move slower/faster based on the error, while option 1 affects both sides to move slower on one side and faster on the other

Option #1 is the simpler option as it is much easier to input the target in degrees using the IMU. Option #2 is not the best as your center of rotation will be on the left side of the drivebase instead of in the center of your drivebase if you use option #1.

thanks! what are other good ways to do it other than what i proposed?

Iā€™m assuming you are talking about driving straight . What my team is doing is adjusting the motor power based on how much distance the back encoder has traveled and changing the difference in speed between the 2 sides based on that.

1 Like

Yes I am talking about drive straight. Are encoders the same as rotation sensors? What is a back encoder?

Encoders are the same as rotation sensors. The back encoder is the encoder wheel perpendicular to your main drive direction in a 2 or 3 wheel odometry set-up.