Adding Vendor Libraries

Adding a vendor library is straightforward. Open VS Code, then the command palette using Ctrl+Shift+P or F1 and type the following command WPILib: Manage Vendor Libraries. This will open a list of choices, as shown.

../../../_images/adding-vendor-libraries-1.png
  • Manage current libraries - Shows the existing libraries installed and allows you to remove them.

  • Check for updates(offline) - Checks if there is an update for a library in the offline folder.

  • Check for updates(online) - Checks if there is an update for a library online.

  • Install new libraries(offline) - Installs a new library in the offline folder.

  • Install new libraries(online) - Installs a new library from the internet.

For this guide select Install new libraries(online).

There are multiple vendor libraries available. The ones supported on the VMXpi are listed below.

  • Kauailabs’ NavX Library

  • Studica’s Titan Library

  • REVRobotics SparkMax Library

    https://www.kauailabs.com/dist/frc/2020/REVRobotics.json

    Enabling the SparkMax requires adding some code to two sections.

    In Robot.java, add the following lines of code where appropriate.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    import com.revrobotics.jni.CANSparkMaxJNI;
    
    @Override
    public void autonomousPeriodic()
    {
       CANSparkMaxJNI.c_SparkMax_SetEnable(true); // Periodically ensure motor controller outputs are enabled
    }
    
    @Override
    public void teleopPeriodic()
    {
       CANSparkMaxJNI.c_SparkMax_SetEnable(true); // Periodically ensure motor controller outputs are enabled
    }
    

    In Robot.cpp add the following lines of code where appropriate

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    #include <rev/CANSparkMaxLowLevel.h>
    
    void Robot::AutonomousPeriodic()
    {
       rev::CANSparkMaxLowLevel::SetEnable(true); // Periodically ensure motor controller outputs are enabled
    }
    
    void Robot::TeleopPeriodic()
    {
       rev::CANSparkMaxLowLevel::SetEnable(true); // Periodically ensure motor controller outputs are enabled
    }
    
  • CTRE Phoenix Library

    http://www.kauailabs.com/dist/frc/2020/Phoenix-vmx.json

    Enabling a Phoenix controlled device requires adding some code to two sections.

    In Robot.java, add the following lines of code where appropriate.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    import com.ctre.phoenix.unmanaged.UnmanagedJNI;
    
    @Override
    public void autonomousPeriodic()
    {
       UnmanagedJNI.JNI_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds
    }
    
    @Override
    public void teleopPeriodic()
    {
       UnmanagedJNI.JNI_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds
    }
    

    In Robot.cpp add the following lines of code where appropriate

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    #include <ctre/phoenix/cci/Unmanaged_CCI.h>
    
    void AutonomousPeriodic() override
    {
       c_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds
    }
    
    void TeleopPeriodic() override
    {
       c_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds
    }