Quote:
Originally Posted by curtis0gj
Hey all, newbie programmer here looking for some help with my autonomous code. At the moment I need to be able to turn 90 on the spot using a gyro stop and drive straight also using a gyro and encoder for distance.
Code:
public void autonomous() {
while(isAutonomous() && isEnabled()) {
SmartDashboard.putNumber("angle", gyro1.getAngle());
double angle = gyro1.getAngle();
robot.drive(-0.20, 1);
if(angle > 83) {
robot.drive(0,0);
break;
The issue I have is the robot won't stop turning  . I need a basic tutorial on setting up an encoder for distance. Also if anyone could show me how I could start driving straight after this turn, Thanks for the help.
|
I think I have solved this but I don't have a way of testing it until tomorrow, I think the issue is the double angle = gyro1.getAngle(); is in the while loop so it's just getting the angle over and over... But I still need help with setting up an encoder if anyone could help that would be great!