How should we use SpeedControllerGroup with TalonFX because I need them for a differnetialDrive.
Says it doesn’t support TalonFX
Thanks!
How should we use SpeedControllerGroup with TalonFX because I need them for a differnetialDrive.
I think you need to use WPI_TalonFX. When doing stuff with CTRE libraries, their classes such as TalonSRX, VictorSPX, and now TalonFX have subclasses with a WPI_ prefix that inherits interfaces such as Sendable
and SpeedController
.
Because SpeedControllerGroup
s require SpeedController
s, using a WPI_TalonFX will allow it to behave like you want it.
Alternatively, you can set one TalonFX to follow the other using CTRE Master/Slave settings, and then pass only the master TalonFX on each side directly to differentialDrive instead of setting up a SpeedControllerGroup to contain both.
(EDIT: You’ll still need to follow Retro’s advice to use WPI_TalonFX for the rest of the library to work properly)
THANK YOU! this fixed it. (Used WPI_)
Solution … did you use SpeedControllerGroup?
Nope. We address our commands to the master FX, with the object called as a wpi_talonFX, and the commands cascade to the follower automatically on CTRE’s side.
I have never used speedControllerGroup
So the students were able to do this so they had arcade drive with 4 wheels powered by individual motors. (They choose not to use tank, so this robot does a little dance some times)
import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.TalonFXInvertType;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
import edu.wpi.first.wpilibj.SlewRateLimiter;
import edu.wpi.first.wpilibj.SpeedControllerGroup;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
public static WPI_TalonFX MOTOR_FL = new WPI_TalonFX(RobotMap.MOTOR_FL);
public static WPI_TalonFX MOTOR_FR = new WPI_TalonFX(RobotMap.MOTOR_FR);
public static WPI_TalonFX MOTOR_BL = new WPI_TalonFX(RobotMap.MOTOR_BL);
public static WPI_TalonFX MOTOR_BR = new WPI_TalonFX(RobotMap.MOTOR_BR);
public static SlewRateLimiter driveLimit = new SlewRateLimiter(2);
public static SlewRateLimiter turnLimit = new SlewRateLimiter(4);
public static SpeedControllerGroup falconLeft = new SpeedControllerGroup(MOTOR_FL, MOTOR_BL);
public static SpeedControllerGroup falconRight = new SpeedControllerGroup(MOTOR_FR, MOTOR_BR);
public static DifferentialDrive differentialDrive =
new DifferentialDrive(falconLeft, falconRight);
differentialDrive.arcadeDrive(drive, turn);
That’s cool and all but shouldn’t that be done in the subsystem? Just like pass in the motors and have the subsystem make the differential drive there. I get that some teams do these things differently, and being a first year I would love to hear others opinions on reasoning for different ways of doing so
Hey Sumifairy,
That code is in our drivesubsystem, just pasted what they did so there was a solution out there.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.