I was working on sensor programming for team 785 using the gyro sensor but i ran into a road block when trying to do ellipses my issue is once i turn one direction i cant turn back to the original direction there aren’t any errors in the code i just don’t know what i have to change in order to go in reverse after i already made a turn
#include "robot-config.h"
void preauton()
{
vex::task::sleep(300);
Gyro.startCalibration();
while(Gyro.isCalibrating())
{
vex::task::sleep(1);
}
}
void autodrive(int speed)
{
leftMotor.spin(vex::directionType::fwd,speed,vex::velocityUnits::rpm);
rightMotor.spin(vex::directionType::fwd,speed,vex::velocityUnits::rpm);
}
void autoturn(int speed)
{
leftMotor.spin(vex::directionType::fwd,speed,vex::velocityUnits::rpm);
rightMotor.spin(vex::directionType::fwd,-speed,vex::velocityUnits::rpm);
}
void autoelip(int speed, int speed2)
{
leftMotor.spin(vex::directionType::fwd,speed2,vex::velocityUnits::rpm);
rightMotor.spin(vex::directionType::fwd,speed,vex::velocityUnits::rpm);
}
void autoturntime(int speed, int mSec)
{
autoturn(speed);
vex::task::sleep(1000);
autodrive(0);
}
void elip(int speed, int speed2, int deg)
{
Gyro.isCalibrating();
while( fabs(Gyro.value(vex::rotationUnits::deg)) < deg*.6)
{
autoelip(speed, speed2);
}
while( fabs(Gyro.value(vex::rotationUnits::deg)) < deg*.8)
{
autoelip(speed*.8, speed2*.8);
}
while( fabs(Gyro.value(vex::rotationUnits::deg)) < deg)
{
autoelip(speed*.6, speed2*.6);
}
autoturntime(-speed/2, 50);
}
int main ()
{
preauton();
if (Gyro.value(vex::rotationUnits::deg)<60)
{
elip(50, -100, 60);
}
preauton();
if (Gyro.value(vex::rotationUnits::deg)>1)
{
elip(100, -50, 1);
}
}
the robot config is
vex::brain Brain;
vex::motor rightMotor = vex::motor(vex::PORT1);
vex::motor leftMotor = vex::motor(vex::PORT2,false);
vex::gyro Gyro = vex::gyro(Brain.ThreeWirePort.A);
anything helps thank you