This should let the driver press X at any time and the robot would turn to face the starting point. I am going to evolve this so that it turns to face the high goal at any point of time in the game. Please give me tips on this, because I am relatively new to C++
/*
/*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp */
/* Author: C:\Users\100039046 */
/* Created: Fri May 06 2022 */
/* Description: V5 project */
/* */
/*----------------------------------------------------------------------------*/
// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// Drivetrain drivetrain 1, 2, 3, 4, 6
// Vision5 vision 5
// Controller1 controller
// ---- END VEXCODE CONFIGURED DEVICES ----
#include "vex.h"
using namespace vex;
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
DrivetrainGPS.setOrigin(0, 0, mm);
if (Controller1.ButtonA.pressing()){
double xPos=DrivetrainGPS.xPosition(mm) ;
double yPos=DrivetrainGPS.yPosition(mm) ;
double slope=yPos/xPos;
double angle =(round(100*((1/tan(slope * M_PI / 180)))/100));
Drivetrain.turnToRotation(angle, degrees);
};
}
*/