I need some help in gps sensor…in my skills when I program it to do rollers, it keeps driving forward and doesn’t stop. I debugged it and tried it from (0,0) to (0,20). It still did the same thing and kept driving forward. What should I do?
Here is my code:

For getting coordinates, these are the quadrants i’m using
Thanks,
-Sumedha
(Note that it helps to include the full text of your code between two sets of three ticks ```)
Is this all of the code? I don’t see where you tell the robot to stop.
Drivetrain.stop();
1 Like
oh thats just a segment of it…heres the full thing:
/*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp */
/* Author: fhdsjfkldsa;fjdkslfjdskal */
/* Created: Thu Dec 29 2022 */
/* Description: V5 project */
/* */
/*----------------------------------------------------------------------------*/
// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Controller1 controller
// Drivetrain drivetrain 1, 12, 16, 6, 18
// Intake motor 19
// Rollers motor 7
// Flywheel motor_group 3, 8
// Indexer digital_out C
// ---- END VEXCODE CONFIGURED DEVICES ----
#include "vex.h"
using namespace vex;
void printPos() {
Brain.Screen.print("X: ");
Brain.Screen.print(DrivetrainGPS.xPosition(mm));
Brain.Screen.print(" Y: ");
Brain.Screen.print(DrivetrainGPS.yPosition(mm));
Brain.Screen.setCursor(2, 1);
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
DrivetrainGPS.calibrate();
DrivetrainGPS.setLocation(0, 0, mm, 0, degrees);
Drivetrain.drive(forward);
waitUntil(DrivetrainGPS.xPosition(mm) > -20);
// IGNORE THIS PART //
// // CALIBRATE //
// DrivetrainGPS.setLocation(620, -750, mm, 90, degrees); // set pos
// printPos();
// // DRIVING TO ROLLER 1 //
// Drivetrain.drive(forward);
// waitUntil(DrivetrainGPS.yPosition(mm) < -1740);
// // while (true) { // go towards rollers. not sure abt the > or <, and -/+ num
// // if (DrivetrainGPS.yPosition(mm) > -1740) {
// // Drivetrain.drive(forward);
// // }
// // if () {
// // break;
// // }
// // }
// Drivetrain.stop(); // stopping it and all
// printPos();
// wait(0.5, seconds);
// // SPINNING ROLLERS //
// Rollers.spinFor(forward, 0.4, turns);
// // // GOING BACK //
// // while (DrivetrainGPS.xPosition(mm) > 1040) { // not sure abt the > 1040
// // Drivetrain.drive(reverse);
// // }
// // Drivetrain.stop();
}
I will try adding the stop… just realized i didn’t add that.