Closed WillXuCodes closed 1 year ago
void opcontrol() {
pros::Controller master(pros::E_CONTROLLER_MASTER);
pros::Motor left_mtr(1);
pros::Motor right_mtr(2);
printf("Initializing GPS\n");
pros::Gps gps(11);
DCHECKPOINT
printf("GPS Initialized\n");
pros::gps_position_s_t position;
pros::gps_position_s_t offset;
while (true) {
// printf("Getting Position\n");
DCHECKPOINT
position = gps.get_position();
DCHECKPOINT
offset = gps.get_offset();
DCHECKPOINT
printf("Position: x: %.4lf %.4lf\n", position.x, position.y);
printf("Offset: x: %.4lf %.4lf\n", offset.x, offset.y);
int left = master.get_analog(ANALOG_LEFT_Y);
int right = master.get_analog(ANALOG_RIGHT_Y);
left_mtr = left;
right_mtr = right;
pros::delay(20);
}
}
Works, outputs properly
Summary:
Updated behavior of GPS's
get_offset
to return a struct with offset, added aget_position
while I was at it to return just the X and Y position.Motivation:
Community pointed it out, I was always bothered by how we did this.
Test Plan:
get_position
andget_offset
with an actual GPS.