In Autonomous we call for the robot to turn. But it just turns without stopping, so we put the code in a separate Task, called after setting a trigger integer, in the auto portion of main.cpp, that the task reads, to better ensure that the GPS3.heading(degrees) information was being updated.
We know the Brain is getting the GPS3.heading(degrees) data, because it is being printed out on Controller1’s screen real time.
At first we thought maybe the Robot blows right past the Heading and thus doesn’t stop because it now isn’t at the heading. So the code presently has a very wide range of headings within which Drivetrain should stop.
Tried inserting GPS3.value (); to see if that helped, but no. Also tried Bool (True) as the last element of the
Drivetrain.turnToHeading(315, degrees, 100, dps) but that didn’t help. It seems we are missing a method to cause this code to update the GPS data real time. Here is the code. Both the turnFor and the turnTo Heading have the same issue. Thoughts?
#include "declarations.h"
int TurnTo1 () {
while (true) {
GPS3.value();
if (gTurnTrgr == 315 && ((GPS3.heading(degrees) < 300)
|| (GPS3.heading(degrees) > 325)) ){
gHeading = round(GPS3.heading(degrees));
//Drivetrain.turnFor(-10,degrees,100,dps);
Drivetrain.turnToHeading(315, degrees, 100, dps);
}
if (GPS3.heading(degrees)>200 && GPS3.heading(degrees) < 360){
Drivetrain.stop ();
gTurnTrgr = 0;
}
}
task::yield();
task::sleep(20);
return 0;
}