Skip to content

Commit

Permalink
Issue 83 - Upgrade to 2017 WPILib
Browse files Browse the repository at this point in the history
Upgrade to the 2017 version of WPILib for Java, which is currently only available to those in the Beta program but will be generally available on January 7, 2017. This version removes the `CANTalon` class and instead replaces it with a 3rd party library from Cross The Road Electronics (CTRE), who is now going to be responsible for that class.

The CTRE library is also currently accessible only to those teams in the Beta program, so the build installs it from a local file during the `deps` Ant build target. This is specified in the `build.properties` file and will be changed once we have a public URL for the download.
  • Loading branch information
rhauch committed Jan 3, 2017
1 parent 357d9c7 commit bec7c21
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -12,8 +12,9 @@ deploy/
target/
*.class

# The wpilib directory should never be committed
# The 3rd party dependencies should never be committed
libs/wpilib
libs/ctre
downloads/

.DS_Store/
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -33,8 +33,8 @@ If you have any problems getting this far, please check our [developers discussi
To release a new version of Strongback:

1. Change the `strongback.properties` file to reference the correct version number, and commit that to the repository.
1. Build the distribution by running `ant clean dist` and verifying it completed correctly.
1. Go to the [Strongback releases page](https://github.com/strongback/strongback-java/releases) and draft a new release, filling in the correct release candidate version number as the tag (e.g., `v1.0.0.RC1` for "release candidate 1") and giving an appropriate release title (e.g., `1.0.0 Release Candidate 1`) and description, and uploading the ZIP and compressed TAR file in the `build` directory. Then check "This is a pre-release" and press "Publish Release".
1. Build the distribution by running `ant release` and verifying it completed correctly.
1. Go to the [Strongback releases page](https://github.com/strongback/strongback-java/releases) and draft a new release, filling in the correct release candidate version number as the tag (e.g., `v2017.1.0.RC1` for "release candidate 1") and giving an appropriate release title (e.g., `2017.1.0.RC1`) and description, and uploading the ZIP and compressed TAR file in the `build` directory. Then check "This is a pre-release" and press "Publish Release".
1. Notify the developer forum so that other community members can test the release candidate by downloading and unpacking the pre-release distribution into their local home directory, using it in one or more robot codebases, and verifying the robots behave as expected. Each community member that tests it locally should respond to your forum post with their results.
1. If the pre-release distribution has problems that need to be fixed, they should be reported, fixed, and merged into the correct branch, and then go to Step 3 using a new pre-release tag (e.g., `v1.0.0.RC2`) and title (e.g., `1.0.0 Release Candidate 1`).
1. When enough community members have verified the pre-release distribution is acceptable, go to the [Strongback releases page](https://github.com/strongback/strongback-java/releases) and create a new release with the same tag as the pre-release, but with the appropriate release title (e.g., `1.0.0`) and description. Do not check "This is a pre-release" and press "Publish Release".
1. If the pre-release distribution has problems that need to be fixed, they should be reported, fixed, and merged into the correct branch, and then go to Step 3 using a new pre-release tag (e.g., `v2017.1.0.RC2`) and title (e.g., `2017.1.0.RC2`).
1. When enough community members have verified the pre-release distribution is acceptable, go to the [Strongback releases page](https://github.com/strongback/strongback-java/releases) and create a new release with the same tag as the pre-release, but with the appropriate release tag (e.g., `v2017.1.0`), title (e.g., `2017.1.0`) and description. Do not check "This is a pre-release" and press "Publish Release".
3 changes: 3 additions & 0 deletions build-common.xml
Expand Up @@ -4,6 +4,7 @@
<property name="strongback.dir" location=".."/>
<property file="${strongback.dir}/build.properties"/>
<property name="wpilib.dir" value="${strongback.dir}/libs/wpilib"/>
<property name="ctre.dir" value="${strongback.dir}/libs/ctre"/>

<property name="java.compile.arg" value=""/>
<property name="java.source.version" value="1.8"/>
Expand All @@ -17,6 +18,7 @@
<property name="project.test.output.dir" value="${project.build.dir}/test-classes"/>
<property name="project.test.report.dir" value="${project.build.dir}/test-reports"/>
<property name="wpi.libs.dir" value="${wpilib.dir}/java/current/lib"/>
<property name="ctre.libs.dir" value="${ctre.dir}/java/lib"/>
<property name="test.libs.dir" value="${strongback.dir}/libs/test"/>
<property name="compile.libs.dir" value="${strongback.dir}/libs"/>
<property name="project.jar.name" value="${ant.project.name}.jar"/>
Expand All @@ -35,6 +37,7 @@
<pathelement location="${project.output.dir}" />
<fileset dir="${compile.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${wpi.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${ctre.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
</path>

<path id="test.class.path">
Expand Down
7 changes: 7 additions & 0 deletions build.properties
Expand Up @@ -6,3 +6,10 @@ strongback.version=2017.1.0.RC1
#
wpilib.updatesite.url=http://first.wpi.edu/FRC/roborio/release/eclipse

#
# Starting in 2017, WPILib will no longer have built-in support for the TalonSRX
# from Cross the Road Electronics (CTRE). Instead, the `CANTalon` class and associated
# functionality is available directly from CTRE as a separate JAR.
#
ctre.download.url=file:///Users/rhauch/Downloads/CTRE_FRCLibs_NON-WINDOWS.zip

48 changes: 42 additions & 6 deletions build.xml
Expand Up @@ -16,6 +16,8 @@
<property name="wpilib.dir" value="libs/wpilib"/>
<property name="wpi.libs.dir" value="${wpilib.dir}/java/current/lib"/>
<property file="${wpilib.dir}/wpilib.properties"/>
<property name="ctre.dir" value="libs/ctre"/>
<property name="ctre.libs.dir" value="${ctre.dir}/java/lib"/>
<property name="build.dir" value="build"/>

<target name="help">
Expand All @@ -35,8 +37,15 @@
<echo>There are a few other targets that are automatically run when the above targets are used,</echo>
<echo>but which you may want to run manually:</echo>
<echo></echo>
<echo> deps Install the dependencies required to compile, run tests, and create the distribution.</echo>
<echo> remove-deps Remove the dependencies installed by `dep`</echo>
<echo> deps Install the WPILib and other dependencies required to compile, run tests, </echo>
<echo> and create the distribution. This does not affect files outside of this</echo>
<echo> `strongback-java` directory</echo>
<echo> remove-deps Remove the dependencies installed by `deps`</echo>
<echo></echo>
<echo>The following target is used during a Strongback release and is equivalent to removing</echo>
<echo>dependencies, cleaning, compiling, and creating the distribution:</echo>
<echo></echo>
<echo> release Equivalent to `ant remove-deps clean dist`</echo>
<echo></echo>
</target>

Expand Down Expand Up @@ -76,6 +85,7 @@
<classpath>
<fileset dir="libs" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${wpi.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${ctre.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<pathelement path="${classpath}" />
</classpath>
<sourcefiles>
Expand All @@ -87,7 +97,7 @@
</packageset>

<doctitle><![CDATA[<h1>Strongback Java Library</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright &#169; ${current.year} Strongback and individual contributors. All Rights Reserved.</i>]]></bottom>
<bottom><![CDATA[<i>Copyright &#169; 2015-${current.year} Strongback and individual contributors. All Rights Reserved.</i>]]></bottom>
<group title="Strongback" packages="org.strongback"/>
<group title="Components" packages="org.strongback.components*:org.strongback.hardware*"/>
<group title="Drives" packages="org.strongback.drive"/>
Expand Down Expand Up @@ -141,7 +151,9 @@
<!-- Remove and clean dependencies -->
<target name="remove-deps" depends="clean-downloads" description="Removes the locally-installed dependencies">
<!-- !!!! Always remove the *local* installation; never the one in ${wpilib.dir} !!!! -->
<delete dir="libs/wpilib" />
<delete dir="${wpilib.dir}" />
<!-- TODO: Uncomment these when we automatically install them -->
<delete dir="${ctre.dir}" />
</target>

<!-- Remove and clean dependencies -->
Expand All @@ -150,7 +162,10 @@
</target>

<!-- Install Dependencies -->
<target name="deps" depends="download-wpilib,clean-downloads" description="Downloads and installs the dependencies required for the build">
<target name="deps" depends="download-wpilib,download-ctre,clean-downloads" description="Downloads and installs the dependencies required for the build">

<!-- Release -->
<target name="release" depends="remove-deps,clean,dist" description="Removes and installs 3rd party libraries, compiles, and builds distribution.">
</target>

<!-- Check if the WPI directory exists -->
Expand Down Expand Up @@ -179,7 +194,8 @@
</if>
</sequential>
</for>
<propertyregex property="wpilib.version" input="${javaFeatureUrl}" regexp="_([\d.]*).jar" select="\1" casesensitive="false" />
<!-- Grab the WPILib version, of the form "2017.1.1.rc-2" -->
<propertyregex property="wpilib.version" input="${javaFeatureUrl}" regexp="_([\w\d.-]*).jar" select="\1" casesensitive="false" />
<!-- The feature URL can be converted to the plugin URL -->
<loadresource property="javaPluginUrl">
<propertyresource name="javaFeatureUrl"/>
Expand Down Expand Up @@ -215,4 +231,24 @@
</propertyfile>
</target>

<!-- Download and install the CTRE library -->
<target name="check-for-ctre">
<condition property="ctre-missing">
<not>
<available file="${ctre.dir}" type="dir"/>
</not>
</condition>
</target>
<target name="download-ctre" depends="check-for-ctre" if="ctre-missing" >
<echo>Downloading the CTRE library and installing into '${ctre.dir}'.</echo>
<!-- Get and extra the ZIP file -->
<get src="${ctre.download.url}" dest="downloads/ctre.zip"/>
<!--copy file="/Users/rhauch/Downloads/CTRE_FRCLibs_NON-WINDOWS.zip" tofile="downloads/ctre.zip"/-->
<mkdir dir="${ctre.dir}"/>
<unzip src="downloads/ctre.zip" dest="${ctre.dir}">
</unzip>
</target>

</target>

</project>
3 changes: 3 additions & 0 deletions strongback-examples/.classpath
Expand Up @@ -4,6 +4,9 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/WPILib.jar" sourcepath="/libs/wpilib/java/current/lib/WPILib-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/NetworkTables.jar" sourcepath="/libs/wpilib/java/current/lib/NetworkTables-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/opencv.jar" sourcepath="/libs/wpilib/java/current/lib/opencv-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/cscore.jar" sourcepath="/libs/wpilib/java/current/lib/cscore-sources.jar"/>
<classpathentry kind="lib" path="/libs/ctre/java/lib/TalonSRXLibJava.jar"/>
<classpathentry kind="lib" path="/libs/test/fest-assert-1.4.jar" sourcepath="/libs/test/fest-assert-1.4-sources.jar"/>
<classpathentry kind="lib" path="/libs/test/fest-util-1.1.6.jar" sourcepath="/libs/test/fest-util-1.1.6-sources.jar"/>
<classpathentry kind="lib" path="/libs/test/junit-4.11.jar" sourcepath="/libs/test/junit-4.11-sources.jar"/>
Expand Down
Expand Up @@ -49,7 +49,7 @@ public class SimpleTankDriveRobot extends IterativeRobot {
public void robotInit() {
// Set up Strongback using its configurator. This is entirely optional, but we won't use events so it's slightly better
// if we turn them off. All other defaults are fine.
Strongback.configure().recordNoEvents().initialize();
Strongback.configure().recordNoEvents();

// Set up the robot hardware ...
Motor left = Motor.compose(Hardware.Motors.talon(LF_MOTOR_PORT), Hardware.Motors.talon(LR_MOTOR_PORT));
Expand Down
3 changes: 3 additions & 0 deletions strongback-testing/.classpath
Expand Up @@ -7,5 +7,8 @@
<classpathentry kind="lib" path="/libs/test/metrics-core-3.1.0.jar" sourcepath="/libs/test/metrics-core-3.1.0-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/WPILib.jar" sourcepath="/libs/wpilib/java/current/lib/WPILib-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/NetworkTables.jar" sourcepath="/libs/wpilib/java/current/lib/NetworkTables-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/opencv.jar" sourcepath="/libs/wpilib/java/current/lib/opencv-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/cscore.jar" sourcepath="/libs/wpilib/java/current/lib/cscore-sources.jar"/>
<classpathentry kind="lib" path="/libs/ctre/java/lib/TalonSRXLibJava.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
3 changes: 3 additions & 0 deletions strongback-tests/.classpath
Expand Up @@ -9,6 +9,9 @@
<classpathentry kind="lib" path="/libs/test/metrics-core-3.1.0.jar" sourcepath="/libs/test/metrics-core-3.1.0-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/WPILib.jar" sourcepath="/libs/wpilib/java/current/lib/WPILib-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/NetworkTables.jar" sourcepath="/libs/wpilib/java/current/lib/NetworkTables-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/opencv.jar" sourcepath="/libs/wpilib/java/current/lib/opencv-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/cscore.jar" sourcepath="/libs/wpilib/java/current/lib/cscore-sources.jar"/>
<classpathentry kind="lib" path="/libs/ctre/java/lib/TalonSRXLibJava.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/strongback"/>
<classpathentry combineaccessrules="false" kind="src" path="/strongback-testing"/>
<classpathentry kind="output" path="build/classes"/>
Expand Down
Expand Up @@ -40,7 +40,7 @@ public class ExecutableTimerTest {

@BeforeClass
public static void beforeAll() {
Strongback.configure().setLogLevel(Level.ERROR).recordNoData().recordNoEvents().initialize();
Strongback.configure().setLogLevel(Level.ERROR).recordNoData().recordNoEvents();
}

@AfterClass
Expand Down
3 changes: 3 additions & 0 deletions strongback/.classpath
Expand Up @@ -4,5 +4,8 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/WPILib.jar" sourcepath="/libs/wpilib/java/current/lib/WPILib-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/NetworkTables.jar" sourcepath="/libs/wpilib/java/current/lib/NetworkTables-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/opencv.jar" sourcepath="/libs/wpilib/java/current/lib/opencv-sources.jar"/>
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/cscore.jar" sourcepath="/libs/wpilib/java/current/lib/cscore-sources.jar"/>
<classpathentry kind="lib" path="/libs/ctre/java/lib/TalonSRXLibJava.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
14 changes: 14 additions & 0 deletions strongback/src/org/strongback/Strongback.java
Expand Up @@ -312,6 +312,20 @@ public static interface ExcessiveExecutionHandler {
*/
public static final class Configurator {

/**
* Log messages to {@link SystemLogger System.out} at the specified level.
* <p>
* This is a convenience that simply delegates to {@link Strongback#setLogLevel(org.strongback.Logger.Level)}.
*
* @param level the global logging level; may not be null
* @return this configurator so that methods can be chained together; never null
* @see Strongback#setLogLevel(org.strongback.Logger.Level)
*/
public Configurator setLogLevel(Logger.Level level) {
Strongback.setLogLevel(level);
return this;
}

/**
* Turn off the data recorder so that it does not record anything.
*
Expand Down
5 changes: 3 additions & 2 deletions strongback/src/org/strongback/hardware/Hardware.java
Expand Up @@ -37,6 +37,9 @@
import org.strongback.function.DoubleToDoubleFunction;
import org.strongback.util.Values;

import com.ctre.CANTalon;
import com.ctre.CANTalon.TalonControlMode;

import edu.wpi.first.wpilibj.ADXL345_I2C;
import edu.wpi.first.wpilibj.ADXL345_SPI;
import edu.wpi.first.wpilibj.ADXRS450_Gyro;
Expand All @@ -46,8 +49,6 @@
import edu.wpi.first.wpilibj.AnalogPotentiometer;
import edu.wpi.first.wpilibj.AnalogTrigger;
import edu.wpi.first.wpilibj.BuiltInAccelerometer;
import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.CANTalon.TalonControlMode;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.DoubleSolenoid;
Expand Down
Expand Up @@ -26,8 +26,8 @@
import org.strongback.control.PIDController;
import org.strongback.control.TalonController;

import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.CANTalon.TalonControlMode;
import com.ctre.CANTalon;
import com.ctre.CANTalon.TalonControlMode;

/**
* A hardware-based Talon SRX PID controller.
Expand Down Expand Up @@ -180,7 +180,7 @@ public TalonController setFeedbackDevice(FeedbackDevice device) {

@Override
public TalonController setStatusFrameRate(StatusFrameRate frameRate, int periodMillis) {
talon.setStatusFrameRateMs(edu.wpi.first.wpilibj.CANTalon.StatusFrameRate.valueOf(frameRate.value()), periodMillis);
talon.setStatusFrameRateMs(CANTalon.StatusFrameRate.valueOf(frameRate.value()), periodMillis);
return this;
}

Expand Down
8 changes: 4 additions & 4 deletions strongback/src/org/strongback/hardware/HardwareTalonSRX.java
Expand Up @@ -27,8 +27,8 @@
import org.strongback.components.TemperatureSensor;
import org.strongback.components.VoltageSensor;

import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.CANTalon.TalonControlMode;
import com.ctre.CANTalon;
import com.ctre.CANTalon.TalonControlMode;

/**
* Talon speed controller with position and current sensor
Expand Down Expand Up @@ -355,7 +355,7 @@ public Gyroscope getSelectedSensor() {

@Override
public TalonSRX setFeedbackDevice(FeedbackDevice device) {
talon.setFeedbackDevice(edu.wpi.first.wpilibj.CANTalon.FeedbackDevice.valueOf(device.value()));
talon.setFeedbackDevice(CANTalon.FeedbackDevice.valueOf(device.value()));
switch(device) {
case ANALOG_POTENTIOMETER:
case ANALOG_ENCODER:
Expand Down Expand Up @@ -385,7 +385,7 @@ public TalonSRX setFeedbackDevice(FeedbackDevice device) {

@Override
public TalonSRX setStatusFrameRate(StatusFrameRate frameRate, int periodMillis) {
talon.setStatusFrameRateMs(edu.wpi.first.wpilibj.CANTalon.StatusFrameRate.valueOf(frameRate.value()), periodMillis);
talon.setStatusFrameRateMs(CANTalon.StatusFrameRate.valueOf(frameRate.value()), periodMillis);
double periodInSeconds = periodMillis / 1000.0;
switch(frameRate) {
case FEEDBACK:
Expand Down

0 comments on commit bec7c21

Please sign in to comment.