grosh
August 6, 2019, 6:23am
1
Just started learning JAVA (command based) this week and we are struggling to interpret REV examples because they are not using command based programming. Below is the last code we have written. What do we need to fix it?
public CANSparkMax motorHabArm_Master;
public CANSparkMax motorHabArm_Slave;
public HabSubsystem() {
CANSparkMax motorHabArm_Master = new CANSparkMax(RobotMap.MOTOR_HAB_ROTATE_MASTER, MotorType.kBrushless);
CANSparkMax motorHabArm_Slave = new CANSparkMax(RobotMap.MOTOR_HAB_ROTATE_SLAVE, MotorType.kBrushless);
// FOLLOW
motorHabArm_Slave.follow(motorHabArm_Master);
What kind of errors are you getting?
The examples are kept generic so that you can grab parts of it if needed (such as for Command Based).
grosh
August 8, 2019, 3:13am
3
I’ve got the code to run without errors. The robot motors now reacts to changes in the tuning variable (setInverted and setIdleMode).
HOWEVER, the motorHabArm_Slave is not FOLLOWING the motorHab_Master . Below is my code…any ideas?
public class HabSubsystem extends Subsystem {
// HAB ARM MOTORS W/ TUNABLE SETTINGS
CANSparkMax motorHabArm_Master = new CANSparkMax(RobotMap.MOTOR_HAB_ROTATE_MASTER, MotorType.kBrushless);
CANSparkMax motorHabArm_Slave = new CANSparkMax(RobotMap.MOTOR_HAB_ROTATE_SLAVE, MotorType.kBrushless);
public HabSubsystem() {
// FOLLOW
motorHabArm_Slave.follow(motorHabArm_Master);
motorHabArm_Master.restoreFactoryDefaults();
motorHabArm_Slave.restoreFactoryDefaults();
motorHabArm_Master.setInverted(false);
motorHabArm_Slave.setInverted(false);
motorHabArm_Master.setIdleMode(IdleMode.kBrake);
motorHabArm_Slave.setIdleMode(IdleMode.kBrake);
// MOTOR SPEED VARIABLES
public double habArmSpeed = 1;
@Override
public void initDefaultCommand() {
setDefaultCommand(new HabPistonRetractCommand());
}
// HAB ARM ROTATE
public void habArmForward() {
motorHabArm_Master.set(-habArmSpeed);
}
public void habArmBack() {
motorHabArm_Master.set(habArmSpeed);
}
// STOP HABARM
public void stop() {
motorHabArm_Master.set(0);
}
}
Move this call before the call to follow()
The restoreFactoryDefaults() command resets most of the settings of the controller to their default state - including the follow settings.
grosh
August 8, 2019, 5:09am
5
That did it… Thank you so much!
system
Closed
August 7, 2020, 5:09am
6
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.