Using TalonSRX in with GradleRIO 2020

Hi there, my team is having a little trouble with TalonSRX motor controllers. It would seem that creating an instance of TalonSRX class causes the following error:

java.lang.UnsatisfiedLinkError: /usr/local/frc/third-party/lib/libCTRE_PhoenixCCI.so: libFRC_NetworkCommunication.so.19: cannot open shared object file: No such file or directory
 	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
 	at java.base/java.lang.ClassLoader$NativeLibrary.load(Unknown Source)
 	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(Unknown Source)
 	at java.base/java.lang.ClassLoader.loadLibrary0(Unknown Source)
 	at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
 	at java.base/java.lang.Runtime.loadLibrary0(Unknown Source)
 	at java.base/java.lang.System.loadLibrary(Unknown Source)
 	at com.ctre.phoenix.CTREJNIWrapper.<clinit>(CTREJNIWrapper.java:9)
 	at com.ctre.phoenix.motorcontrol.can.BaseMotorController.<init>(BaseMotorController.java:59)
 	at com.ctre.phoenix.motorcontrol.can.BaseTalon.<init>(BaseTalon.java:31)
 	at com.ctre.phoenix.motorcontrol.can.TalonSRX.<init>(TalonSRX.java:29)
 	at org.sert2521.infiniterecharge2020.MainKt.main(Main.kt:7)
 	at org.sert2521.infiniterecharge2020.MainKt.main(Main.kt)

The program seems to be failing to load the ctre api dll, but I have no idea why. I have tried using different versions of gradleRIO and the ctre api, and I tried reimaging the roborio and reinstalling the 2020 game tools, but to no effect. My build.gradle is as follows:

import edu.wpi.first.gradlerio.GradleRIOPlugin

plugins {
    id "org.jetbrains.kotlin.jvm" version "1.3.61"
    id "edu.wpi.first.GradleRIO" version "2020.1.2"
}

def mainClass = "org.sert2521.infiniterecharge2020.MainKt"
def kotlinVersion = "1.3.61"

deploy {
    targets {
        roboRIO("roborio") {
            team = 2521
        }
    }
    artifacts {
        frcJavaArtifact('frcJava') {
            targets << "roborio"
            // Debug can be overridden by command line, for use with VSCode
            debug = frc.getDebugOrDefault(false)
        }
        // Built in artifact to deploy arbitrary files to the roboRIO.
        fileTreeArtifact('frcStaticFileDeploy') {
            // The directory below is the local directory to deploy
            files = fileTree(dir: 'src/main/deploy')
            // Deploy to RoboRIO target, into /home/lvuser/deploy
            targets << "roborio"
            directory = '/home/lvuser/deploy'
        }
    }
}

repositories {
    jcenter()
    mavenCentral()
    maven { url "http://first.wpi.edu/FRC/roborio/maven/release" }
    maven { url "https://frcmaven.wpi.edu/artifactory/release/" }
    maven { url "http://devsite.ctr-electronics.com/maven/release" }
    maven { url "https://www.kauailabs.com/maven2" }
    maven { url "http://www.revrobotics.com/content/sw/max/sdk/maven/" }
    maven { url "http://www.revrobotics.com/content/sw/color-sensor-v3/sdk/maven/" }
    google()
    maven { url 'https://jitpack.io' }
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
    compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
    compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"

    implementation wpi.deps.wpilib()
    nativeZip wpi.deps.wpilibJni(wpi.platforms.roborio)
    nativeDesktopZip wpi.deps.wpilibJni(wpi.platforms.desktop)

    implementation wpi.deps.vendor.java()
    nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
    nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)

    compile "com.kauailabs.navx.frc:navx-java:3.1.344"
    compile "com.ctre.phoenix:api-java:5.17.4"
    compile 'com.github.SouthEugeneRoboticsTeam:sertain:0.0.8'
}

jar {
    from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
    manifest GradleRIOPlugin.javaManifest(mainClass)
}

and here is my settings.gradle:

import org.gradle.internal.os.OperatingSystem

pluginManagement {
    repositories {
        mavenLocal()
        gradlePluginPortal()
        String frcYear = '2020'
        File frcHome
        if (OperatingSystem.current().isWindows()) {
            String publicFolder = System.getenv('PUBLIC')
            if (publicFolder == null) {
                publicFolder = "C:\\Users\\Public"
            }
            def homeRoot = new File(publicFolder, "wpilib")
            frcHome = new File(homeRoot, frcYear)
        } else {
            def userFolder = System.getProperty("user.home")
            def homeRoot = new File(userFolder, "wpilib")
            frcHome = new File(homeRoot, frcYear)
        }
        def frcHomeMaven = new File(frcHome, 'maven')
        maven {
            name 'frcHome'
            url frcHomeMaven
        }
    }
}

We would be deeply appreciative of any help.

Please use the vendordeps method instead of trying to include the relevant maven dependencies yourself.

Take a look here: https://phoenix-documentation.readthedocs.io/en/latest/ch05a_CppJava.html

Hi! Thanks for the help. We do have vendordeps/Pheonix.json in our gradle project. I don’t think having it in our build file as well would cause the problem because I tested the code without it.

It looks like we resolved the problem. Our Pheonix.json file was outdated, so we replaced it with the one at http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/Phoenix-latest.json.

1 Like

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