frc error

// 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 com.revrobotics.CANSparkMax;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.motorcontrol.MotorController;
import edu.wpi.first.wpilibj.motorcontrol.PWMSparkMax;

/**

  • This is a demo program showing the use of the DifferentialDrive class, specifically it contains
  • the code necessary to operate a robot with tank drive.
    */
    public class Robot extends TimedRobot {
    private DifferentialDrive m_myRobot;
    private Joystick m_leftStick;
    private Joystick m_rightStick;

/**
*
/
private final CANSparkMax m_leftMotora = new CANSparkMax(0, null);
/
*
*
/
private final CANSparkMax m_rightMotora = new CANSparkMax(1, null);
/
*
*
/
private final CANSparkMax m_leftMotorb = new CANSparkMax(0, null);
/
*
*
*/
private final CANSparkMax m_rightMotorb = new CANSparkMax(1, null);

//
private Object new_left_motor = m_leftMotorb, m_leftmotora;

private Object new_right_motor = m_rightMotorb, m_rightmotora;
//speedgroups
private final speed_controller_group right_speed_group = new speed_controller_group(new_right_motor);

private final speed_controller_group left_speed_group = new speed_controller_group(new_left_motor);
//drivetrain
/**
*
*/
DifferentialDrive drivetrain = new DifferentialDrive (left_speed_group, right_speed_group);

//joystick
Joystick drivecontroller = new Joystick(0);
Joystick subsystems = new Joystick(1);

@Override
public void robotInit() {
MotorController m_rightMotor;
// We need to invert one side of the drivetrain so that positive voltages
// result in both sides moving forward. Depending on how your robot’s
// gearbox is constructed, you might have to invert the left side instead.
m_rightMotor.setInverted(true);

MotorController new_leftMotor;
m_myRobot = new DifferentialDrive(new_leftMotor, m_rightMotor);
m_leftStick = new Joystick(0);
m_rightStick = new Joystick(1);

}

@Override
public void teleopPeriodic() {
m_myRobot.tankDrive(-m_leftStick.getY(), -m_rightStick.getY());

}
}
The constructor DifferentialDrive(speed_controller_group, speed_controller_group) is undefined

Quick style note: use triple backticks to make your foldable and easier on the eyes.
``` like this ```. Also make sure to title your post with the error you are receiving.

Motor controllers (and the drive train in general) should be defined in a subsystem and called with a command - not in robot container. To learn more see this tutorial on the WPILib docs. Once you do that, we can help you review your code.

Best of luck, Vlad

P.S. motor controllers are usually model specific - there is no “one size fits all” class. Many of those custom classes require vendor dependencies, something you can learn about in the WPILib documentation.

1 Like

speed_controller_group is not a valid type. Youre likely looking for MotorControllerGroup as a type, and “speed_controller_group” as the variable name. You can find it mentioned in the docs here, but be sure to read the other pages near this one for more info.

1 Like

Theyre using TimedRobot directly, not command-based, so suggestions around subsystems/commands are not relevant to this vode snippet (though not a terrible suggestion as general guidance)

Fair, but the team should consider a transition to the modern command based approach - especially for beginners.

1 Like

Heh. You’ll find me one of the few WPILib folks who suggest the opposite for beginners. I consider command based the “next step” but extremely difficult for teams unfamiliar with programming at all!

2 Likes

I agree with this sentiment, if you can’t program a timed robot and realize that by it’s worse then you’re not ready to design command based code

1 Like

I suspect you’ll also have trouble with passing null to the CANSparkMax constructor.

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