View Single Post
  #2   Spotlight this post!  
Unread 16-01-2017, 20:34
CSkillet CSkillet is offline
Registered User
FRC #0135
 
Join Date: Jan 2016
Location: Indiana
Posts: 12
CSkillet is an unknown quantity at this point
Re: CANTalon w/Encoder DriveStraight Command example

Quote:
protected boolean isFinished() {
if (numberOfUnits < 0) {
return (driveTrain.talon.getPosition() >= -numberOfUnits);
}
return (driveTrain.talon.getPosition() <= -numberOfUnits);
}
This is just from my perspective because I don't know what values you are getting from driveTrain.talon.getPosition(), but it seems your return equations are off. When the numberOfUnits is negative, driveTrain.talon.getPosition() is also going in the negative direction. So when you take the negative of numberOfUnits when it is already a negative number, its turns to a positive number. So when is driveTrain.talon.getPosition() (a negative number) ever greater than or equal to a positive number? Never. Your return would always be false and so the command would never end. The other equation seems to be off to me to, but I think you get my point now.
Reply With Quote