Jengles
06-02-2012, 19:57
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick.AxisType;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.Timer;
import java.lang.Math;
public class RobotTemplate extends IterativeRobot {
RobotDrive drive;
Joystick leftStick;
Joystick rightStick;
// Left and Right Drive Motors
Jaguar leftMotor1;
Jaguar leftMotor2;
Jaguar rightMotor1;
Jaguar rightMotor2;
// Channels for Left and Right mobility motors.
static final int leftMotorChannel1 = 1;
static final int leftMotorChannel2 = 2;
static final int rightMotorChannel1 = 3;
static final int rightMotorChannel2 = 4;
// Deadzone Variables
static final double deadzonePercent = .05;
public void robotInit() {
//Initialize Drive Motors
leftMotor1=new Jaguar(leftMotorChannel1);
leftMotor2=new Jaguar(leftMotorChannel2);
rightMotor1=new Jaguar(rightMotorChannel1);
rightMotor2=new Jaguar(rightMotorChannel2);
drive = new RobotDrive(leftMotor2,leftMotor1,rightMotor2,right Motor1);
leftStick = new Joystick(1);
rightStick = new Joystick(2);
}
public void teleopPeriodic() {
Watchdog.getInstance().feed();
drive.tankDrive(deadzone(leftStick.getY()),deadzon e(rightStick.getY()));
}
public double deadzone(double joyVal) {
if (joyVal < deadzonePercent && joyVal > -deadzonePercent)
return 0;
else if(joyVal > deadzonePercent)
return (joyVal/(1-deadzonePercent) - (1/(1-deadzonePercent)*deadzonePercent));
else
return (joyVal/(1-deadzonePercent) + (1/(1-deadzonePercent)*deadzonePercent));
}
}
We are experiencing this problem. Our motors are running fine, though we continue to get this error, we're wondering if it's because iterative robot is checking for output and we are not giving it Joystick output fast enough.
Is there a way we can modify the delay time it requires or is the only option to set setSafteyEnabled to false?
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick.AxisType;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.Timer;
import java.lang.Math;
public class RobotTemplate extends IterativeRobot {
RobotDrive drive;
Joystick leftStick;
Joystick rightStick;
// Left and Right Drive Motors
Jaguar leftMotor1;
Jaguar leftMotor2;
Jaguar rightMotor1;
Jaguar rightMotor2;
// Channels for Left and Right mobility motors.
static final int leftMotorChannel1 = 1;
static final int leftMotorChannel2 = 2;
static final int rightMotorChannel1 = 3;
static final int rightMotorChannel2 = 4;
// Deadzone Variables
static final double deadzonePercent = .05;
public void robotInit() {
//Initialize Drive Motors
leftMotor1=new Jaguar(leftMotorChannel1);
leftMotor2=new Jaguar(leftMotorChannel2);
rightMotor1=new Jaguar(rightMotorChannel1);
rightMotor2=new Jaguar(rightMotorChannel2);
drive = new RobotDrive(leftMotor2,leftMotor1,rightMotor2,right Motor1);
leftStick = new Joystick(1);
rightStick = new Joystick(2);
}
public void teleopPeriodic() {
Watchdog.getInstance().feed();
drive.tankDrive(deadzone(leftStick.getY()),deadzon e(rightStick.getY()));
}
public double deadzone(double joyVal) {
if (joyVal < deadzonePercent && joyVal > -deadzonePercent)
return 0;
else if(joyVal > deadzonePercent)
return (joyVal/(1-deadzonePercent) - (1/(1-deadzonePercent)*deadzonePercent));
else
return (joyVal/(1-deadzonePercent) + (1/(1-deadzonePercent)*deadzonePercent));
}
}
We are experiencing this problem. Our motors are running fine, though we continue to get this error, we're wondering if it's because iterative robot is checking for output and we are not giving it Joystick output fast enough.
Is there a way we can modify the delay time it requires or is the only option to set setSafteyEnabled to false?