|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can anyone explain why my code will not stop once centerX1 is equal to 237?
package org.usfirst.frc.team1025.robot.commands.Vision; import org.usfirst.frc.team1025.robot.Robot; import org.usfirst.frc.team1025.robot.subsystems.ChassisS ubsystem; import org.usfirst.frc.team1025.robot.subsystems.VisionSu bsystem; import org.usfirst.frc.team1025.robot.subsystems.VisionSu bsystem; import edu.wpi.first.wpilibj.command.Command; /** * */ @SuppressWarnings("unused") public class VisionAuton extends Command { double centerX1; double centerX2; private boolean isCenter = false; public VisionAuton() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); requires(Robot.visionSubsystem); requires(Robot.chassisSubsystem); } // Called just before this Command runs the first time protected void initialize() { } // Called repeatedly when this Command is scheduled to run protected void execute() { synchronized (Robot.visionSubsystem.imgLock) { Robot.visionSubsystem.centerX1 = this.centerX1; Robot.visionSubsystem.centerX2 = this.centerX2; } // double TargetMidpoint = (centerX2 - centerX1) / 2; // double disp = (TargetMidpoint - Robot.vision.IMG_WIDTH / 2); @SuppressWarnings("static-access") double Turn = centerX1 - (Robot.visionSubsystem.IMG_WIDTH / 2); //+ centerX2 - (Robot.visionSubsystem.IMG_WIDTH / 2); // double Turn = (centerX2 - centerX1) / 2 - Robot.vision.IMG_WIDTH / 2; Robot.chassisSubsystem.getRobotDrive().arcadeDrive (-0.6, Turn * 0.005); } // Make this return true when this Command no longer needs to run execute() public boolean isFinished() { if(centerX1 == 237.0 + 10){ return isCenter = true; } else if(centerX1 == 237.0 - 10){ return isCenter = true; } else{ return isCenter == false; } } // Called once after isFinished returns true protected void end() { } // Called when another command which requires one or more of the same // subsystems is scheduled to run protected void interrupted() { } } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|