diff --git a/.gitignore b/.gitignore index 0739e8c..b077322 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,10 @@ deploy/ target/ *.class -# The wpilib directory should never be committed +# The 3rd party dependencies should never be committed libs/wpilib +libs/ctre +libs/navx-mxp downloads/ .DS_Store/ diff --git a/.travis.yml b/.travis.yml index 7c71f15..cfe49cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,13 @@ sudo: false language: java +before_install: + - ant -version + - wget http://apache.mirrors.pair.com//ant/binaries/apache-ant-1.10.0-bin.tar.gz + - tar -xf apache-ant-1.10.0-bin.tar.gz + - export ANT_HOME=$PWD/apache-ant-1.10.0 + - export PATH=$ANT_HOME/bin:$PATH + - ant -version + install: ant deps script: ant test jdk: diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 7e99beb..897da41 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -1,7 +1,9 @@ -Braden Steffaniak Matthew Alonso +Zach Anderson Nathan Brown +Adam Gausmann +Colin Hauch Randall Hauch -Zach Anderson +Filip Kernan Rothanak So -Filip Kernan \ No newline at end of file +Braden Steffaniak \ No newline at end of file diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index 83853d0..d52dadb 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -1,9 +1 @@ -Copyright 2015, Strongback and individual contributors by the @authors tag. - -The following have contributed to the Strongback Java codebase. - -Randall Hauch -Zach Anderson -Nathan Brown -Adam Gausmann -Colin Hauch \ No newline at end of file +Copyright 2015-2017, Strongback and individual contributors identified by the @authors tags and in the CONTRIBUTORS file. diff --git a/README.md b/README.md index 877ef9a..e2da38e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Strongback is a new open source software library that makes your robot code ligh # Building locally -If you want to build Strongback locally, you will need to have installed JDK 1.8, Eclipse Mars (version 4.5.0 or later), Ant 1.9.2 or later, and Git 2.2.1 or later. Then, use Git to clone this repository (or your GitHub fork). Before importing into Eclipse, build the code and run the unit tests using Ant: +If you want to build Strongback locally, you will need to have installed JDK 1.8, Eclipse Mars (version 4.5.0 or later), Ant 1.10.0 or later, and Git 2.2.1 or later. Then, use Git to clone this repository (or your GitHub fork). Before importing into Eclipse, build the code and run the unit tests using Ant: $ ant test @@ -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". diff --git a/ant/strongback/build.xml b/ant/strongback/build.xml index 784f562..c83cb3d 100644 --- a/ant/strongback/build.xml +++ b/ant/strongback/build.xml @@ -11,17 +11,19 @@ - - - - - - - + + - @@ -37,46 +39,6 @@ - - - - - - - - - - - - - - - Making jar ${dist.jar}. - - - - Copying jars from ${strongback.classpath} to ${build.jars}. - - - - - - - - - - - - - - - - - - - - - diff --git a/build-common.xml b/build-common.xml index b82a0d4..968d915 100644 --- a/build-common.xml +++ b/build-common.xml @@ -4,6 +4,8 @@ + + @@ -17,6 +19,8 @@ + + @@ -35,6 +39,8 @@ + + diff --git a/build.properties b/build.properties index 764c9cb..22495d0 100644 --- a/build.properties +++ b/build.properties @@ -1,8 +1,19 @@ -strongback.version=1.2.1 +strongback.version=2017.1.0.RC1 # # The build will download a specific version of the WPILib given by the following URL # and install it into the 'libs/wpilib' folder. To use a different version of WPILib, # replace the value with the URL of the WPILib Eclipse Update Site # -wpilib.updatesite.url=http://first.wpi.edu/FRC/roborio/release/eclipse +wpilib.updatesite.url=http://first.wpi.edu/FRC/roborio/beta/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=http://www.ctr-electronics.com/downloads/lib/CTRE_FRCLibs_NON-WINDOWS.zip + +# +# The navX-MXP library is available in a ZIP file that has only the Java and C++ libraries. +# +navx.download.url=http://www.kauailabs.com/public_files/navx-mxp/navx-mxp-libs.zip \ No newline at end of file diff --git a/build.xml b/build.xml index 5f63fe3..7769940 100644 --- a/build.xml +++ b/build.xml @@ -16,6 +16,10 @@ + + + + @@ -35,8 +39,15 @@ There are a few other targets that are automatically run when the above targets are used, but which you may want to run manually: - deps Install the dependencies required to compile, run tests, and create the distribution. - remove-deps Remove the dependencies installed by `dep` + deps Install the WPILib and other dependencies required to compile, run tests, + and create the distribution. This does not affect files outside of this + `strongback-java` directory + remove-deps Remove the dependencies installed by `deps` + + The following target is used during a Strongback release and is equivalent to removing + dependencies, cleaning, compiling, and creating the distribution: + + release Equivalent to `ant remove-deps clean dist` @@ -76,6 +87,8 @@ + + @@ -87,7 +100,7 @@ Strongback Java Library]]> - Copyright © ${current.year} Strongback and individual contributors. All Rights Reserved.]]> + Copyright © 2015-${current.year} Strongback and individual contributors. All Rights Reserved.]]> @@ -95,6 +108,7 @@ + @@ -104,35 +118,55 @@ + + + + + + + + + + + + + + + + + + + - + - + + @@ -141,7 +175,10 @@ - + + + + @@ -150,7 +187,11 @@ - + + + + + @@ -179,7 +220,8 @@ - + + @@ -215,4 +257,61 @@ + + + + + + + + + + Downloading the CTRE library and installing into '${ctre.dir}'. + + + + + + + + + + + + + + + + + + # Downloaded and installed by Strongback build system${line.separator} + ${ctre.version.properties} + + + + + + + + + + + + Downloading the navX-MXP library and installing into '${navx.dir}'. + + + + + + + + + + + + + + + + diff --git a/strongback-examples/.classpath b/strongback-examples/.classpath index 3735578..9d8e522 100644 --- a/strongback-examples/.classpath +++ b/strongback-examples/.classpath @@ -4,6 +4,10 @@ + + + + diff --git a/strongback-examples/src/org/strongback/example/simple/SimpleTankDriveRobot.java b/strongback-examples/src/org/strongback/example/simple/SimpleTankDriveRobot.java index 37a7f36..4bbc288 100644 --- a/strongback-examples/src/org/strongback/example/simple/SimpleTankDriveRobot.java +++ b/strongback-examples/src/org/strongback/example/simple/SimpleTankDriveRobot.java @@ -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)); diff --git a/strongback-testing/.classpath b/strongback-testing/.classpath index 01b32f0..2f9fc28 100644 --- a/strongback-testing/.classpath +++ b/strongback-testing/.classpath @@ -7,5 +7,9 @@ + + + + diff --git a/strongback-testing/src/org/strongback/ExecutableTimer.java b/strongback-testing/src/org/strongback/ExecutableTimer.java index 8ebee41..d387b2a 100644 --- a/strongback-testing/src/org/strongback/ExecutableTimer.java +++ b/strongback-testing/src/org/strongback/ExecutableTimer.java @@ -21,6 +21,7 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; +import org.strongback.Executor.Priority; import org.strongback.Strongback.Configurator; import org.strongback.annotation.ThreadSafe; @@ -82,7 +83,7 @@ public static ExecutableTimer measureTiming(Executor executor, int numberOfSampl if (atCompletion != null) atCompletion.accept(theTimer.getResults()); }); // Register the timer with the executor ... - executor.register(timer); + executor.register(timer, Priority.HIGH); return timer; } diff --git a/strongback-tests/.classpath b/strongback-tests/.classpath index 1a3a353..14437d4 100644 --- a/strongback-tests/.classpath +++ b/strongback-tests/.classpath @@ -9,6 +9,10 @@ + + + + diff --git a/strongback-tests/src/org/strongback/ExecutableTimerTest.java b/strongback-tests/src/org/strongback/ExecutableTimerTest.java index 0d38e6c..4115af1 100644 --- a/strongback-tests/src/org/strongback/ExecutableTimerTest.java +++ b/strongback-tests/src/org/strongback/ExecutableTimerTest.java @@ -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 @@ -74,7 +74,7 @@ protected void runTimer(int millisecondExecutionPeriod, int sampleTimeInMillisec assertThat(ExecutableTimer.measureTimingAndPrint(Strongback.executor(), " for " + millisecondExecutionPeriod + " ms", sampleTimeInMilliseconds / millisecondExecutionPeriod) - .await(10, TimeUnit.SECONDS) + .await(4, TimeUnit.SECONDS) .isComplete()); } catch (InterruptedException e) { Thread.interrupted(); diff --git a/strongback/.classpath b/strongback/.classpath index 65ab72f..8e39e72 100644 --- a/strongback/.classpath +++ b/strongback/.classpath @@ -4,5 +4,9 @@ + + + + diff --git a/strongback/src/org/strongback/Strongback.java b/strongback/src/org/strongback/Strongback.java index 2673502..e15a2cd 100644 --- a/strongback/src/org/strongback/Strongback.java +++ b/strongback/src/org/strongback/Strongback.java @@ -22,12 +22,10 @@ import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.function.Function; -import java.util.function.LongConsumer; import java.util.function.Supplier; import org.strongback.AsyncEventRecorder.EventWriter; import org.strongback.Executor.Priority; -import org.strongback.annotation.NotImplemented; import org.strongback.annotation.ThreadSafe; import org.strongback.command.Command; import org.strongback.command.Scheduler; @@ -108,8 +106,9 @@ *

Stopping versus disabling

*

* When the robot is disabled we recommend calling {@link #disable()} rather than {@link #stop()}, since {@link #disable()} will - * stop the execution but will keep most of the services ready to run again. You can use {@link #stop()} to completely shutdown - * all Strongback resources, although on most robots this will be unnecessary. + * stop things from executing but will keep most of the services ready to run again. If you prefer, you can use {@link #stop()} + * to completely shutdown all Strongback resources when needed, although on most robots and during most competitions + * {@link #disable()} should be sufficient. * *

Execution

*

@@ -314,87 +313,19 @@ public static interface ExcessiveExecutionHandler { public static final class Configurator { /** - * The available options for how the Strongback executor thread waits between - * {@link Strongback.Configurator#useExecutionPeriod execution periods}. - * - * @deprecated this is no longer used and will be removed in 2.0 - */ - @Deprecated - public static enum TimerMode { - BUSY, SLEEP, PARK; - } - - /** - * Log messages to {@link SystemLogger System.out} at the specified level - * - * @param level the global logging level; may not be null - * @return this configurator so that methods can be chained together; never null - * @deprecated use {@link #setLogLevel(org.strongback.Logger.Level)} instead - */ - @Deprecated - public Configurator useSystemLogger(Logger.Level level) { - return setLogLevel(level); - } - - /** - * Log messages to {@link SystemLogger System.out} at the specified level + * Log messages to {@link SystemLogger System.out} at the specified level. + *

+ * 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) { - if (level == null) throw new IllegalArgumentException("The system logging level may not be null"); Strongback.setLogLevel(level); return this; } - /** - * Strongback no longer supports custom loggers, so this method does nothing. - * - * @param loggers unused - * @return this configurator so that methods can be chained together; never null - * @deprecated this is no longer used and will be removed in 2.0 - */ - @Deprecated - public Configurator useCustomLogger(Function loggers) { - return this; - } - - /** - * Strongback no longer supports using the FPGA time, so this method does nothing. - * - * @return this configurator so that methods can be chained together; never null - * @deprecated this is no longer used and will be removed in 2.0 - */ - @Deprecated - public Configurator useFpgaTime() { - return this; - } - - /** - * Strongback always uses the JRE's {@link Clock#system() time system}, so this method is no longer necessary and does - * nothing. - * - * @return this configurator so that methods can be chained together; never null - * @deprecated this is no longer used and will be removed in 2.0 - */ - @Deprecated - public Configurator useSystemTime() { - return this; - } - - /** - * Strongback no longer supports using custom clocks, so this method does nothing. - * - * @param clock no longer used - * @return this configurator so that methods can be chained together; never null - * @deprecated this is no longer used and will be removed in 2.0 - */ - @Deprecated - public Configurator useCustomTime(Clock clock) { - return this; - } - /** * Turn off the data recorder so that it does not record anything. * @@ -410,12 +341,13 @@ public Configurator recordNoData() { * "{@code /home/lvuser/robot}" as the prefix means that the data will be recorded in files named * "{@code /home/lvuser/robot-data-.dat}", where {@code } will be 1, 2, 3, etc. *

- * Make sure that the user has privilege to write to the directory specified in the filename prefix. Typically the robot - * is run from the root directory, and the user running the code does not have privilege to write to the {@code /} - * directory. + * Note: Make sure that the user has privilege to write to the directory specified in the filename + * prefix. Typically the robot is run from the root directory, and the user running the code does not have + * privilege to write to the {@code /} directory but does have privilege in the user's home directory (e.g., + * {@code /home/lvuser}). *

- * This method sizes the files such that they can hold data for approximately 3 minutes of robot run time. Use - * {@link #recordDataToFile(String, int)} to specify a different estimate. + * This method estimates the size of the files so that each file can hold data for approximately 3 minutes of robot run + * time. Use {@link #recordDataToFile(String, int)} to specify a different estimate. * * @param filenamePrefix the prefix for filenames, which includes the path to the files; may not be null * @return this configurator so that methods can be chained together; never null @@ -431,9 +363,10 @@ public Configurator recordDataToFile(String filenamePrefix) { * "{@code /home/lvuser/robot}" as the prefix means that the data will be recorded in files named * "{@code /home/lvuser/robot-data-.dat}", where {@code } will be 1, 2, 3, etc. *

- * Make sure that the user has privilege to write to the directory specified in the filename prefix. Typically the robot - * is run from the root directory, and the user running the code does not have privilege to write to the {@code /} - * directory. + * Note: Make sure that the user has privilege to write to the directory specified in the filename + * prefix. Typically the robot is run from the root directory, and the user running the code does not have + * privilege to write to the {@code /} directory but does have privilege in the user's home directory (e.g., + * {@code /home/lvuser}). *

* This method allows a robot to estimate the total number of seconds the recorder will capture data, and this is used * to compute an approximate amount of memory used to buffer the information. If the data record runs for a longer @@ -452,18 +385,6 @@ public Configurator recordDataToFile(String filenamePrefix, int estimatedTotalNu return this; } - /** - * This method no longer does anything. - * - * @return this configurator so that methods can be chained together; never null - * @deprecated - */ - @Deprecated - @NotImplemented - public Configurator recordDataToNetworkTables() { - return this; - } - /** * Record data to a custom {@link DataWriter} by supplying the factory that will create the data writer. * @@ -476,18 +397,6 @@ public Configurator recordDataTo(Function, DataWri return this; } - /** - * This is no longer used. - * - * @param numberOfSeconds unused - * @return this configurator so that methods can be chained together; never null - * @deprecated - */ - @Deprecated - public Configurator recordDuration(int numberOfSeconds) { - return this; - } - /** * Enable the recording of events and write them to local files whose paths begin with the given prefix. For example, * supplying "{@code /home/lvuser/robot}" as the prefix means that the events will be recorded in files named @@ -565,34 +474,18 @@ public Configurator enableSwitchReactor() { return this; } - /** - * Strongback's executor thread always uses a busy loop to wait for the next period, and so this method is no longer - * needed. - * - * @param mode unused - * @return this configurator so that methods can be chained together; never null - * @see #useExecutionPeriod(long, TimeUnit) - * @deprecated this is no longer used - */ - @Deprecated - public Configurator useExecutionTimerMode(TimerMode mode) { - return this; - } - /** * Use the specified execution rate for Strongback's {@link Strongback#executor() executor}. The default execution rate * is 5 milliseconds. *

- * The clock that Strongback is configured to use will also affect the precision of the execution rate: the - * {@link #useFpgaTime() FPGA clock} will likely support rates down to around a few milliseconds, whereas the - * {@link #useSystemTime() system clock} may only support rates of 10-15 milliseconds. Therefore, this method does not - * currently allow sub-microsecond intervals. + * The clock that Strongback is configured to use will also affect the precision of the execution rate. This rate is + * measured using the JVM's {@link System#nanoTime()} method and therefore may not support periods smaller than 10 or 15 + * milliseconds. * * @param interval the interval for calling all registered {@link Executable}s; must be positive * @param unit the time unit for the interval; may not be null * @return this configurator so that methods can be chained together; never null - * @see #useExecutionTimerMode(TimerMode) - * @throws IllegalArgumentException if {@code unit} is {@link TimeUnit#MICROSECONDS} or {@link TimeUnit#NANOSECONDS} + * @throws IllegalArgumentException if the interval is smaller than 1 millisecond */ public Configurator useExecutionPeriod(long interval, TimeUnit unit) { if (interval <= 0) throw new IllegalArgumentException("The execution interval must be positive"); @@ -604,22 +497,6 @@ public Configurator useExecutionPeriod(long interval, TimeUnit unit) { return this; } - /** - * Every time the executor takes longer than the {@link #useExecutionPeriod(long, TimeUnit) execution period} to execute - * each interval, report this to the given handler. - * - * @param handler the receiver for notifications of excessive execution times - * @return this configurator so that methods can be chained together; never null - * @deprecated use {@link Strongback.Configurator#reportExcessiveExecutionTimes} instead - */ - @Deprecated - public Configurator reportExcessiveExecutionPeriods(LongConsumer handler) { - ENGINE.handleExecutionDelays((actual, desired) -> { - handler.accept(actual); - }); - return this; - } - /** * Every time the executor takes longer than the {@link #useExecutionPeriod(long, TimeUnit) execution period} to execute * each interval, report this to the given handler. @@ -683,9 +560,16 @@ public Configurator when(BooleanSupplier condition, Consumer confi } /** - * This method no longer does anything. Be sure to call {@link Strongback#start()}, {@link Strongback#restart()}, and - * {@link Strongback#shutdown()} + * This method no longer does anything. + *

+ * Be sure to call {@link Strongback#start()} or {@link Strongback#restart()} during + * {@link edu.wpi.first.wpilibj.IterativeRobot#teleopInit()} and + * {@link edu.wpi.first.wpilibj.IterativeRobot#autonomousInit()}, and either {@link Strongback#stop()} or + * {@link Strongback#disable()} during {@link edu.wpi.first.wpilibj.IterativeRobot#disabledInit()}. + * + * @deprecated this is no longer needed and does nothing */ + @Deprecated public synchronized void initialize() { } } @@ -726,29 +610,22 @@ public static void restart() { * Stop all currently-scheduled activity and flush all recorders. This is typically called by robot code when when the robot * becomes disabled. Should the robot re-enable, all aspects of Strongback will continue to work as before it was disabled. * + * @see #start() * @see #stop() * @see #restart() + * @see #killAllCommands() */ public static void disable() { ENGINE.killCommandsAndFlush(); ENGINE.pause(); } - /** - * Stop Strongback from running commands, reading switch states, and recording data and events. - * - * @deprecated use {@link #stop()} instead - */ - @Deprecated - public static void shutdown() { - stop(); - } - /** * Stop Strongback from running commands, reading switch states, and recording data and events. * * @see #start() * @see #restart() + * @see #disable() * @see #killAllCommands() */ public static void stop() { @@ -784,37 +661,12 @@ public static Executor executor() { * Get Strongback's global {@link Logger} implementation. * * @return Strongback's logger instance; never null - * @see Configurator#useSystemLogger(org.strongback.Logger.Level) - * @see Configurator#useCustomLogger(Function) + * @see #setLogLevel(org.strongback.Logger.Level) */ public static Logger logger() { return LOGGER; } - /** - * Get Strongback's global {@link Logger} implementation. - * - * @param context the context of the logger - * @return Strongback's logger instance; never null - * @deprecated use {@link #logger()} instead - */ - @Deprecated - public static Logger logger(String context) { - return LOGGER; - } - - /** - * Get Strongback's global {@link Logger} implementation. - * - * @param context the context of the logger - * @return Strongback's logger instance; never null - * @deprecated use {@link #logger()} instead - */ - @Deprecated - public static Logger logger(Class context) { - return LOGGER; - } - /** * Set the level at which log messages should be recorded. * @@ -829,9 +681,6 @@ public static void setLogLevel(Logger.Level level) { * Get Strongback's {@link Clock time system} implementation. * * @return Strongback's time system instance; never null - * @see Configurator#useFpgaTime() - * @see Configurator#useSystemTime() - * @see Configurator#useCustomTime(Clock) */ public static Clock timeSystem() { return CLOCK; @@ -842,7 +691,6 @@ public static Clock timeSystem() { * * @param command the command to be submitted * @see Configurator#useExecutionPeriod(long, TimeUnit) - * @see Configurator#useExecutionTimerMode(org.strongback.Strongback.Configurator.TimerMode) */ public static void submit(Command command) { if (command != null) { @@ -943,8 +791,6 @@ public static SwitchReactor switchReactor() { * @see DataRecorder * @see Configurator#recordDataTo(Function) * @see Configurator#recordDataToFile(String) - * @see Configurator#recordDataToNetworkTables() - * @see Configurator#recordDuration(int) * @see Configurator#recordNoData() */ public static DataRecorder dataRecorder() { @@ -1296,7 +1142,7 @@ protected boolean doStart() { } // Create the scheduler that runs commands ... - scheduler = new Scheduler(logger, createCommandListener(eventRecorder,listenToCommands)); + scheduler = new Scheduler(logger, createCommandListener(eventRecorder, listenToCommands)); scheduler.execute(CLOCK.currentTimeInMillis()); executables.register(scheduler, SCHEDULER_PRIORITY); diff --git a/strongback/src/org/strongback/command/CommandRunner.java b/strongback/src/org/strongback/command/CommandRunner.java index 13260c8..b7bfceb 100644 --- a/strongback/src/org/strongback/command/CommandRunner.java +++ b/strongback/src/org/strongback/command/CommandRunner.java @@ -50,8 +50,7 @@ public Logger logger() { } private static final CommandListener NO_OP_LISTENER = CommandListener.noOp(); - private static final Context DEFAULT_CONTEXT = Context.with(NO_OP_LISTENER, - Strongback.logger(CommandRunner.class.getName())); + private static final Context DEFAULT_CONTEXT = Context.with(NO_OP_LISTENER, Strongback.logger()); private boolean timed = false; private long timeoutInMillis; diff --git a/strongback/src/org/strongback/components/Clock.java b/strongback/src/org/strongback/components/Clock.java index 346e063..36b346e 100644 --- a/strongback/src/org/strongback/components/Clock.java +++ b/strongback/src/org/strongback/components/Clock.java @@ -101,7 +101,7 @@ public static Clock system() { return new Clock() { @Override public long currentTimeInMicros() { - return (long) (currentTimeInNanos() / 1000.0); + return (long) (currentTimeInNanos() / 1_000.0); } @Override @@ -111,7 +111,7 @@ public long currentTimeInNanos() { @Override public long currentTimeInMillis() { - return System.currentTimeMillis(); + return (long) (currentTimeInNanos() / 1_000_000.0); } }; } diff --git a/strongback/src/org/strongback/components/Fuse.java b/strongback/src/org/strongback/components/Fuse.java index 03ffeb9..ecb259e 100644 --- a/strongback/src/org/strongback/components/Fuse.java +++ b/strongback/src/org/strongback/components/Fuse.java @@ -94,7 +94,7 @@ public Fuse trigger() { try { whenTriggered.run(); } catch (Throwable t) { - Strongback.logger(Fuse.class).error(t, "Error when calling fuse trigger function"); + Strongback.logger().error(t, "Error when calling fuse trigger function"); } } return this; @@ -155,7 +155,7 @@ public synchronized Fuse trigger() { try { whenTriggered.run(); } catch (Throwable t) { - Strongback.logger(Fuse.class).error(t, "Error when calling fuse trigger function"); + Strongback.logger().error(t, "Error when calling fuse trigger function"); } } return this; diff --git a/strongback/src/org/strongback/components/TalonSRX.java b/strongback/src/org/strongback/components/TalonSRX.java index 74388e9..e0d1031 100644 --- a/strongback/src/org/strongback/components/TalonSRX.java +++ b/strongback/src/org/strongback/components/TalonSRX.java @@ -349,7 +349,22 @@ public enum FeedbackDevice { * Talon SRX Software * Reference Manual, section 21.3 */ - ENCODER_FALLING(5); + ENCODER_FALLING(5), + + /** + * CTRE magnetic encoder with relative position + */ + MAGNETIC_ENCODER_RELATIVE(6), + + /** + * CTRE magnetic encoder with absolute position + */ + MAGNETIC_ENCODER_ABSOLUTE(7), + + /** + * Pulse width + */ + PULSE_WIDTH(8); public int value; diff --git a/strongback/src/org/strongback/hardware/Hardware.java b/strongback/src/org/strongback/hardware/Hardware.java index e18babf..e5eb76c 100644 --- a/strongback/src/org/strongback/hardware/Hardware.java +++ b/strongback/src/org/strongback/hardware/Hardware.java @@ -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; @@ -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; diff --git a/strongback/src/org/strongback/hardware/HardwareTalonController.java b/strongback/src/org/strongback/hardware/HardwareTalonController.java index efedd2f..5f85a4e 100644 --- a/strongback/src/org/strongback/hardware/HardwareTalonController.java +++ b/strongback/src/org/strongback/hardware/HardwareTalonController.java @@ -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. @@ -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; } diff --git a/strongback/src/org/strongback/hardware/HardwareTalonSRX.java b/strongback/src/org/strongback/hardware/HardwareTalonSRX.java index 95c5478..cfe9ec7 100644 --- a/strongback/src/org/strongback/hardware/HardwareTalonSRX.java +++ b/strongback/src/org/strongback/hardware/HardwareTalonSRX.java @@ -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 @@ -355,14 +355,14 @@ 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: if ( selectedAnalogInput != null ) { selectedInput = selectedAnalogInput; } else { - Strongback.logger(getClass()).error("Unable to use the analog input for feedback, since the Talon SRX (device " + getDeviceID() + ") was not instantiated with an analog input. Check how this device was created using Strongback's Hardware class."); + Strongback.logger().error("Unable to use the analog input for feedback, since the Talon SRX (device " + getDeviceID() + ") was not instantiated with an analog input. Check how this device was created using Strongback's Hardware class."); selectedInput = NO_OP_SENSOR; } break; @@ -371,7 +371,7 @@ public TalonSRX setFeedbackDevice(FeedbackDevice device) { if ( selectedEncoderInput != null ) { selectedInput = selectedEncoderInput; } else { - Strongback.logger(getClass()).error("Unable to use the quadrature encoder input for feedback, since the Talon SRX (device " + getDeviceID() + ") was not instantiated with an encoder input. Check how this device was created using Strongback's Hardware class."); + Strongback.logger().error("Unable to use the quadrature encoder input for feedback, since the Talon SRX (device " + getDeviceID() + ") was not instantiated with an encoder input. Check how this device was created using Strongback's Hardware class."); selectedInput = NO_OP_SENSOR; } break; @@ -379,13 +379,22 @@ public TalonSRX setFeedbackDevice(FeedbackDevice device) { // for 2015 the Talon SRX firmware did not support the falling or rising mode ... selectedInput = NO_OP_SENSOR; break; + case MAGNETIC_ENCODER_ABSOLUTE: + selectedInput = NO_OP_SENSOR; + break; + case MAGNETIC_ENCODER_RELATIVE: + selectedInput = NO_OP_SENSOR; + break; + case PULSE_WIDTH: + selectedInput = NO_OP_SENSOR; + break; } return this; } @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: