correctHeading

void correctHeading(float finalHeading, float power)

Uses RPS to correct the heading, relative to the global (course) coordinates.

Parameters
  • finalHeading: the desired heading. 0 <= finalHeading < 359.9

  • power: the motor percent speeds. A low power will be accurate, but slow. A high power will be fast, but not as accurate.

Examples

1
correctHeading(0.0, 25.0);

Corrects the robot’s global heading to 0 degrees, setting the motors at 25%.


1
correctHeading(190.0, 14.0);

Corrects the robot’s global heading to 190 degrees, setting the motors at 14%.

Function Variables

Type

Name

Description

float

currHeading

Stores the current heading from RPS

float

angle

Stores the absolute angle difference between the final and current heading