I ran into a error with groupRight.setInverted and groupLeft.setInverted

here is the error: The method setInverted(boolean) in the type MotorControllerGroup is not applicable for the arguments (TalonFXInvertType)Java(67108979)

here is my code: // Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.TimedRobot;

import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.TalonFXInvertType;
import com.ctre.phoenix.motorcontrol.can.TalonFX;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;

import edu.wpi.first.wpilibj.motorcontrol.MotorController;
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;

public class Robot extends TimedRobot
{

WPI_TalonFX motorRight1 = new WPI_TalonFX(9);
WPI_TalonFX motorRight2 = new WPI_TalonFX(5);
WPI_TalonFX motorRight3 = new WPI_TalonFX(10);
MotorControllerGroup groupRight = new MotorControllerGroup(motorRight1, motorRight2, motorRight3);

WPI_TalonFX motorLeft1 = new WPI_TalonFX(2);
WPI_TalonFX motorLeft2 = new WPI_TalonFX(3);
WPI_TalonFX motorLeft3 = new WPI_TalonFX(4);
MotorControllerGroup groupLeft = new MotorControllerGroup(motorLeft1, motorLeft2, motorLeft3);

//Controller
Joystick gamePad = new Joystick(0);
Joystick joystick = new Joystick(1);

@Override
public void robotInit() {
//Inverted setting
groupRight.setInverted(TalonFXInvertType.CounterClockwise);
groupLeft.setInverted(TalonFXInvertType.Clockwise);

motorLeft1.setNeutralMode(NeutralMode.Brake);
motorLeft2.setNeutralMode(NeutralMode.Brake);
motorLeft3.setNeutralMode(NeutralMode.Brake);
motorRight1.setNeutralMode(NeutralMode.Brake);
motorRight2.setNeutralMode(NeutralMode.Brake);
motorRight3.setNeutralMode(NeutralMode.Brake);

}

@Override
public void teleopPeriodic()
{
// Drive control - Arcade Drive
double moveSpeed = -gamePad.getRawAxis(1); // inverted for proper control direction
double turnSpeed = gamePad.getRawAxis(4);

// adjust move speed for better control at lower speeds
moveSpeed = Math.copySign(Math.pow(moveSpeed, 2.0), moveSpeed);

// combine move and turn speeds
double leftSpeed = moveSpeed + turnSpeed;
double rightSpeed = moveSpeed - turnSpeed;

// limit motor speed to maximum allowed value
double maxSpeed = 0.8;
leftSpeed = Math.copySign(Math.min(Math.abs(leftSpeed), maxSpeed), leftSpeed);
rightSpeed = Math.copySign(Math.min(Math.abs(rightSpeed), maxSpeed), rightSpeed);

// set motor speeds
groupLeft.set(leftSpeed);
groupRight.set(rightSpeed);

}

@Override
public void disabledInit() {
groupLeft.stopMotor();
groupRight.stopMotor();
}
}

It’s not a true/false value - the error is telling you you’re looking for a value from the TalonFXInvertType class (kForward/kReverse, probably)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.