I cant get our code to work we a a new team for FRC

hi my team and i are new to frc we have done ftc and fll before and we cant fix our code we have some variables not used because we always make our variables first and when ever i put motor type this happens kBrushless cannot be resolved or is not a field and we our programming our can bus for it to our motor controllers are victorspx and talonsrx

here is our code since new accounts cant upload files

package frc.robot;

import edu.wpi.first.wpilibj.Joystick;

import edu.wpi.first.wpilibj.SpeedControllerGroup;

import edu.wpi.first.wpilibj.Talon;

import edu.wpi.first.wpilibj.TimedRobot;

import edu.wpi.first.wpilibj.VictorSP;

import edu.wpi.first.wpilibj.drive.RobotDriveBase.MotorType;

import edu.wpi.first.wpilibj.drive.DifferentialDrive;

import frc.robot.VictorSPX;

import frc.robot.CANTalon;

/**

  • The VM is configured to automatically run this class, and to call the

  • functions corresponding to each mode, as described in the TimedRobot

  • documentation. If you change the name of this class or the package after

  • creating this project, you must also update the build.gradle file in the

  • project.

*/

public class Robot extends TimedRobot {

private static final int leftdeviceid = 2;

private static final int rightdeviceid = 3;

private VictorSPX m_leftmotor;

private VictorSPX m_rightmotor;

// right motors

private final VictorSP rightmotor1 = new VictorSP(9);

private final VictorSP rightmotor2 = new VictorSP(1);

private final VictorSP leftmotor1 = new VictorSP(0);

private final VictorSP leftmotor2 = new VictorSP(2);

// shoot

private final Talon intakeleft = new Talon(3);

private final VictorSP intakeright = new VictorSP(2);

// intake

//speed controllers for movement

private final SpeedControllerGroup rightspeedGroup = new SpeedControllerGroup(rightmotor1, rightmotor2);

private final SpeedControllerGroup leftspeedGroup = new SpeedControllerGroup(leftmotor1, leftmotor2);

// the drivetrain

DifferentialDrive drivetrain = new DifferentialDrive(rightspeedGroup, leftspeedGroup);

//controlls

Joystick stick = new Joystick(0);

@Override

public void robotInit() {

m_rightmotor = new VictorSPX(rightdeviceid, MotorType.kBrushless);

m_leftmotor = new VictorSPX(rightdeviceid, MotorType.kBrushless);

}

@Override

public void robotPeriodic() {}

@Override

public void autonomousInit() {}

@Override

public void autonomousPeriodic() {}

@Override

public void teleopInit() {}

@Override

public void teleopPeriodic() {

drivetrain.arcadeDrive(stick.getY(), stick.getZ());

//shoot controlls 

if(stick.getRawButton(1)){

  intakeleft.set(1);

 intakeright.set(1);

   }else{

    intakeleft.stopMotor();

     intakeright.stopMotor();

}

}

@Override

public void disabledInit() {}

@Override

public void disabledPeriodic() {}

@Override

public void testInit() {}

@Override

public void testPeriodic() {}

}

You’re mixing information from the Talon & Victor CAN objects and the SparkMax Object. While both are CAN Controllers, their respective libraries are independently developed by their respective manufactures. The MotorType.kBrushless bit is only relavent to Rev’s Spark Max controllers.

Oh wait, did you define your own VictorSPX and CANTalon classes as well? I assume then you haven’t gone through and installed the Pheonix Libraries for the CTRE CAN Motor Controllers.

WPILIB only has the Classes for PWM operation, all the CAN stuff is developed by the manufactures, so you need to install the relevent 3rd party libraries

For the Cross the Road Electronics Controllers, this would be the Phoenix Framework/Library

1 Like

thx would you mind doing a discord with me and my team some time to teach us some stuff???

The FRC discord has a programming channel that you might find useful for getting more real-time coding help.

I would suggest reading through as much of the official WPILib docs as you can, and possibly to work through an introductory online java course to make sure you’re fully comfortable with the language syntax and semantics before trying to control a robot with it.

3 Likes

Additional Resources that might be helpful:
FRC Help
Compass Alliance Pathways - Lots of very useful information for teams of all levels
Compass Alliance Tag Teams - Find Team to partner with in your quest for better code

Learning Java
CodingBat - Practice basic logic and method writing
How To Think Like A Computer Scientist - A free book that does a very good job covering the basic. Great for someone looking for a starting point for teaching multiple other people.
Codecdemy - Learn code through an interactive web browser

3 Likes

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