Programming Help

We are struggling with finding a way to resolve an error that our code is having, here is the robot.java and the error message.

Robot.java:

// 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.ctre.phoenix.motorcontrol.InvertType;
import com.ctre.phoenix.motorcontrol.TalonFXInvertType;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
/import edu.wpi.first.wpilibj.cameraserver;
/
*

  • 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 {

public WPI_TalonFX leftPrime = new WPI_TalonFX(0);
public WPI_TalonFX leftFollow = new WPI_TalonFX(1);
public WPI_TalonFX rghtPrime = new WPI_TalonFX(2);
public WPI_TalonFX rghtFollow = new WPI_TalonFX(3);

private DifferentialDrive driveTrain = new DifferentialDrive(leftPrime, rghtPrime);

private Joystick joyRight = new Joystick(0);

/**

  • This function is run when the robot is first started up and should be used for any
  • initialization code.
    */
    @Override
    public void robotInit() {
rghtPrime.configFactoryDefault();
rghtFollow.configFactoryDefault();
leftPrime.configFactoryDefault();
leftFollow.configFactoryDefault();

rghtFollow.follow(rghtPrime);
leftFollow.follow(leftPrime);

rghtPrime.setInverted(TalonFXInvertType.CounterClockwise); // change Possibly
leftPrime.setInverted(TalonFXInvertType.Clockwise); // possibly change

leftFollow.setInverted(InvertType.FollowMaster);
rghtFollow.setInverted(InvertType.FollowMaster);

/*driveTrain.setRightSideInverted(false); */

}

@Override
public void robotPeriodic() {

}

@Override
public void autonomousInit() {

}

@Override
public void autonomousPeriodic() {

}

@Override
public void teleopInit() {

}

@Override
public void teleopPeriodic() {

String work = "";

/*get gamepad stick values */
double forw = -joyRight.getRawAxis(1); /* positive is forward */
double turn = -joyRight.getRawAxis(2); /* positive is right */
boolean btn1 = joyRight.getRawButton(1); /* If button is down, print jowstick values */


driveTrain.arcadeDrive(forw, turn);

if (btn1){
  System.out.println(work);
}

}
@Override
public void disabledInit() {

}

@Override
public void disabledPeriodic() {

}

@Override
public void testInit() {

}

@Override
public void testPeriodic() {

}
}

Error message:

Driver Station reported IP: 10.49.25.2

Task :downloadDepsPreemptively FAILED

Task :discoverroborio
Discovering Target roborio
Using [email protected]:22 for target roborio

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:downloadDepsPreemptively’.

Could not resolve all files for configuration ‘:roborioRelease’.
Could not resolve com.ctre.phoenix:cci:5.21.4.
Required by:
project :
No cached version of com.ctre.phoenix:cci:5.21.4 available for offline mode.
No cached version of com.ctre.phoenix:cci:5.21.4 available for offline mode.
No cached version of com.ctre.phoenix:cci:5.21.4 available for offline mode.

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 5s
3 actionable tasks: 2 executed, 1 up-to-date
The terminal process “cmd.exe /d /c gradlew deploy -PteamNumber=4925 --offline -Dorg.gradle.java.home=“C:\Users\Public\wpilib\2022\jdk”” terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

1 Like

This means that it couldn’t find the CTRE libraries. Try doing a build while your computer is connected to the Internet, before trying to do a deploy when connected to the robot.

FYI, your post would be more readable if you used triple-backticks (```) to escape the copy-and-paste contents.

2 Likes

100% this… or better yet, a link to github (or other source control system)

Still not working. We tried building it while connecting to the internet and tried again connecting to the robot and we get the same error message.

Did the build succeed when connected to the internet?

No

Have you worked through this guide?
https://docs.ctre-phoenix.com/en/stable/ch05a_CppJava.html

We fixed it, we had an old phoenix.json installed

1 Like

I’m glad that you could find the answer you needed but for future context, don’t just paste-dump and entire file of robot code. In a case like this you should just put whatever exception causes the build to fail.

Or better yet: find the answer yourself.
When I say that it’s with 0 sarcasm/hard feelings. In a case like this, the terminal will tell you what is wrong. If it was a syntax error it will tell you where the issue was, or in your case, the reason the build wouldn’t work had nothing to do with the code. It’s all right here

When you don’t have a cached version of any wpilib or ctre releases availible in offline mode it means that your WPIlib project doesn’t have the files it needs to use all the ctre stuff.

–PS: some of the stuff that the terminal spouts out can look like technical nonsense gobblygook, so if you don’t know what the error report means, then you would go to CD or some other forum and ask what that means.

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