I am currently trying to get encoders on my teams test bot working so we can then port it over to our competition bot, however I am having so difficulties along the way. Every time I download my code to the bot and enable, I get the message, “Robot Drive… Output not updated often enough.” I have looked over my code several times and had others on my team look it over not finding the cause. We are not sure if we are just missing something rather obvious (we’re all quite tired), or if theyre might be something wrong with my version of netbeans. I am currently leaning more towards the issue with netbeans because when I re-wrote the code on another laptop, the error went away.
I have attached my current code below. If you could take a look over it and point out any issue that may be causing this or something that will be an issue in the near future, that would be much appreciated.
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class RobotTemplate extends IterativeRobot {
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
Joystick driveStick;
RobotDrive mainDrive;
Encoder rightEncoder;
Encoder leftEncoder;
double RDistance, LDistance;
//AutoConfig
double AutoDistance = 60;
double AutoSpeed = 0.5;
int AutoTolerance = 6;
double RSpeed, LSpeed;
boolean DB1;
public void robotInit() {
leftEncoder.setDistancePerPulse(0.000623);
rightEncoder.setDistancePerPulse(0.000623);
driveStick = new Joystick(1);
mainDrive = new RobotDrive(1,2,3,4);
rightEncoder = new Encoder(1,2);
leftEncoder = new Encoder(3,4);
RDistance = rightEncoder.getDistance();
LDistance = leftEncoder.getDistance();
DB1 = driveStick.getRawButton(1);
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
rightEncoder.start();
leftEncoder.start();
if(LDistance < AutoDistance){
LSpeed = AutoSpeed;
}else if(LDistance > AutoDistance+AutoTolerance){
LSpeed = -AutoSpeed;
}else{
RSpeed = 0.0;
}
if(RDistance < AutoDistance){
RSpeed = AutoSpeed;
}else if(LDistance > AutoDistance+AutoTolerance){
LSpeed = -AutoSpeed;
}else{
RSpeed = 0.0;
}
mainDrive.tankDrive(LSpeed, RSpeed);
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
mainDrive.arcadeDrive(driveStick);
rightEncoder.start();
leftEncoder.start();
System.out.println("Right Distance: " + RDistance);
System.out.println("Left Distance: " + LDistance);
if(DB1 = true){
rightEncoder.reset();
leftEncoder.reset();
}
}
/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
}
}
Also I am aware that the method of using the encoders is quite rudimentary however my team just wants to get it working a little before introducing the PID element. That will come shortly after getting this working.