As a team, we decided to drive our robot with the help of encoders and a joystick. We want to drive our robot straight even though it is controlled by the joystick. We do not know how to achieve this as one motor is obviously slower. Also, we are displaying the encoder values on a screen but they seem to stop after an integer around 25, whereas they should increase as they show the count of rotations. Can you guys help us with this? We are using FRC library. library here
public class Robot extends IterativeRobot {
Victor Motor0= new Victor(0);
Victor Motor1= new Victor(1);
DifferentialDrive drive= new DifferentialDrive(Motor0,Motor1);
Joystick stick=new Joystick(0);
double dist =0.5*3.14/1024;
Encoder esit= new Encoder(0,1,true,Encoder.EncodingType.k4X);
Encoder esit1 = new Encoder(2,3,true,Encoder.EncodingType.k4X);
double m0 = esit.get();
double m1 = esit1.get();
double fark = m1 - m0;
double gidilen_mesafe1 = esit.getDistance();
double gidilen_mesafe2 = esit1.getDistance();
public void robotInit() {
esit.setDistancePerPulse(dist);
esit1.setDistancePerPulse(dist);
esit.reset();
esit1.reset();
}
public void autonomousInit() {
}
public void autonomousPeriodic() {
}
public void teleopPeriodic() {
drive.arcadeDrive(stick.getRawAxis(0), stick.getRawAxis(1));
SmartDashboard.putNumber("Tekerlek1", esit.get());
SmartDashboard.putNumber("Tekerlek2", esit1.get());
SmartDashboard.putNumber("Aradaki Fark", fark);
SmartDashboard.putNumber("Mesafe 1", gidilen_mesafe1);
SmartDashboard.putNumber("Mesafe 2", gidilen_mesafe2);
boolean m_stop = esit.getStopped();
boolean m1_stop = esit1.getStopped();
if(m_stop==false && m1_stop==false) {
esit.reset();
esit1.reset();
}
}
public void testPeriodic() {
}
}