FalconX-Robotics / frc2018

Code for our FRC 2018 robot.
MIT License
2 stars 5 forks source link

@Muying Potential Autonomous Code #3

Open moreheadm opened 6 years ago

moreheadm commented 6 years ago

Edit: (I got his name wrong, should be Minyoung) Minyoung posted this:

Someone please tell me if this is going to work:

//don't delete the comments until you do what it said because they're important

package org.usfirst.frc.team6662.robot.commands;
import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc.team6662.robot.Robot;
public class TurnLeft extends Command{

        public TurnLeft(){
                requires(Robot.drivetrain);
        }

        @Override
        protected void initialize(){
                     //the gyro is already calibrated in robotInit through drivetrain subsystem
        }

        @Override
        protected void execute(){
                while (Robot.drivetrain.getAngle()< 90) {  //someone needs to make getAngle() in Drivetrain
                Robot.drivetrain.drive(-1, 1);
                }

        @Override
        protected boolean isFinished(){
                return false;
        }
}

This code will probably work. However, it has things that could be improved:

  1. The constructor could take an angle parameter to make the code more flexible (you'd have to also store it within the class so execute can use it).
  2. Is the robot turning in high or low gear? I would suggest making it turn only in low gear.
  3. isFinished needs to return true after the while loop finishes. This could be accomplished with a member variable.
  4. It may sense to make drive be implemented so as to store the speed in the counterclockwise direction looking at the wheel. If this is the case you may have to adjust the arguments of drive.

Have you guys bought gyro/encoders?

moreheadm commented 6 years ago

See #1