TheANT
January 27, 2024, 3:45pm
1
We are trying to replace MotorControllerGroup with the .follow() but it is throwing an error. Could you help us. Thanks
// motor controllers for each arm ellement
public CANSparkMax LupDown = new CANSparkMax(ArmConstants.kLUpDownMotorPort, MotorType.kBrushless);
public static CANSparkMax RupDown = new CANSparkMax(ArmConstants.kRUpDownMotorPort, MotorType.kBrushless);
public CANSparkMax lShoot = new CANSparkMax(ArmConstants.kLeftShootMotorPort, MotorType.kBrushless);
public CANSparkMax rShoot = new CANSparkMax(ArmConstants.kRightShootMotorPort, MotorType.kBrushless);
public CANSparkMax intake = new CANSparkMax(ArmConstants.kIntakeMotorPort, MotorType.kBrushless);
// TODO Invert
// TODO use .follow() instead of MotorControllerGroup
// group of the shooting motors
LupDown.follow(RupDown, ture);
lShoot.follow(rShoot, ture);
It would be a lot easier to help if you posted the error.
TheANT:
ture
You have a typo
TheANT
January 27, 2024, 4:06pm
3
I fixed the typo and there are more errors:
Syntax error on token "(", delete this tokenJava(1610612968)
Syntax error on tokens, VariableDeclarator expected insteadJava(1610612973)
TheANT
January 27, 2024, 4:11pm
4
Here is the whole file. There are other errors but I think I know how to fix them after we get the follow method working.
package frc.robot.subsystems;
import com.revrobotics.AbsoluteEncoder;
import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.ArmConstants;
public class ArmSubsystem extends SubsystemBase{
// motor controllers for each arm ellement
public CANSparkMax LupDown = new CANSparkMax(ArmConstants.kLUpDownMotorPort, MotorType.kBrushless);
public static CANSparkMax RupDown = new CANSparkMax(ArmConstants.kRUpDownMotorPort, MotorType.kBrushless);
public CANSparkMax lShoot = new CANSparkMax(ArmConstants.kLeftShootMotorPort, MotorType.kBrushless);
public CANSparkMax rShoot = new CANSparkMax(ArmConstants.kRightShootMotorPort, MotorType.kBrushless);
public CANSparkMax intake = new CANSparkMax(ArmConstants.kIntakeMotorPort, MotorType.kBrushless);
// TODO Invert
// TODO use .follow() instead of MotorControllerGroup
// group of the shooting motors
LupDown.follow(RupDown, true);
lShoot.follow(rShoot, true);
//public final MotorControllerGroup shoot = new MotorControllerGroup(lShoot, rShoot);
//public final MotorControllerGroup upDown = new MotorControllerGroup(LupDown, RupDown);
//Encoder
public final static AbsoluteEncoder upDownEncoder = (AbsoluteEncoder) RupDown.getEncoder();
// Timer
public Timer Armtimer = new Timer();
public void armMove(double upDownSpeed, double shootSpeed, double intakeSpeed){
upDown.set(upDownSpeed);
shoot.set(shootSpeed);
intake.set(intakeSpeed);
}
public void joysticMove(double upDownSpeed, boolean shoot, boolean intake){
double outshoot = 0.0;
double outintake = 0.0;
if(shoot){
outshoot = 1.0; //default commands
}
else if (intake){
outintake = 1.0; //default commands
}
outintake = intakeCheck(SmartDashboard.getNumber("IR", 0.0), outintake);
armMove(upDownSpeed, outshoot, outintake);
}
public void armMoveTime(double upDownSpeed, double shootSpeed, double intakeSpeed, double time){ // I think seconds
Armtimer.restart();
while (Armtimer.get() < time){
armMove(upDownSpeed, shootSpeed, intakeSpeed);
}
}
public void armMoveAngle(double degAngle, double shootSpeed){
double rottations = angleToRotations(degAngle);
while (upDownEncoder.getPosition() < Math.abs(rottations)){
if(rottations < 0){
armMove(-1, shootSpeed, 0);
}
else if(rottations > 0){
armMove(1, shootSpeed, 0);
}
}
}
public double intakeCheck(double IR, double initSpeed){
if(IR > 20.0){
return 0.0;
}
return initSpeed;
}
public double angleToRotations(double degAngle){
return 0.0;
}
}
You can’t call methods like that outsode of a function scope. Move the two .follow(...)
calls to the constructor
system
Closed
January 26, 2025, 4:32pm
7
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.