I’m a rookie programmer and I am trying to make a simple program that moves a single motor with increasing speed. I have 3 values the motor can hit based on the position of the joystick, these are constants creep, slow drive and, fast drive. This is the command I wrote, I get an error “the method getRawAxis(int) is undefined for the type Joystick Java(6710864)” whenever I use “getRawAxis”. I think that for some reason getRawAxis isn’t importing, but I looked it up and edu.wpi.first.wpilibj.GenericHID; should work. I have no idea what to do and no other programmer in my team can figure it out. Forgive my weird code, I’m a scrub.
package frc.robot.commands;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.command.Command;
import frc.robot.constants;
import frc.robot.Robot;
import edu.wpi.first.wpilibj.GenericHID;
public class JoyStick extends Command {
private JoyStick stick;
public JoyStick(JoyStick stick, double deadzone) {
super("Joystick");
requires(Robot.drivetrain);
this.stick = stick;
this.deadzone = deadzone;
}
protected void initialize() {
}
protected void execute() {
double thrust=0;
double turn=stick.getRawAxis(3);
if(stick.getRawAxis(3)){
thrust = 0;
}
else if (stick.getRawAxis(3)>=0.1&&stick.getRawAxis(3)<=0.4){
thrust = constants.kCreep;
}
else if (stick.getRawAxis(3)>0.4&&stick.getRawAxis(3)<=0.7){
thrust = constants.kSlowDrive;
}
else if (stick.getRawAxis(3)>0.7&&stick.getRawAxis(3)<=1.0){
thrust = constants.kFastDrive;
}
}
}
@Override
protected boolean isFinished() {
return false;
}
@Override
protected void end() {
}
@Override
protected void interrupted() {
}
}