Offseason Code Release
Team 401 is pleased to release our software written during the offseason. This past summer, we focused on improving our reusable codebase as well as improved vision processing. Below are some brief summaries of the different projects we worked on:
SnakeSkin was our primary focus over the offseason. SnakeSkin is a Kotlin framework that provides a DSL to organize robot subsystems and components. It consists of three modules (Core, FRC, and CTRE), allowing the user to pick only the components that they need. The Core module is platform independent and provides most of the base functionality, including a state machine based subsystem model (based on 254’s 2016 design), as well as many utility classes (such as a fully thread-safe PIDF controller, simple low pass filter, etc.) The FRC module provides the majority of features for an FRC robot, such as access to joysticks (several mappings created so far, as well as the ability to create your own), autonomous scheduling, and sensors. Finally, the CTRE module provides compatibility and drop-in replacements for CTRE’s Phoenix framework, including the “drivetrain model" for organizing motor controllers, and integrates with SnakeSkin’s auto executor. In terms of overhead, SnakeSkin has a very low impact (CPU usage for the user code process measured around 4% on an empty project). SnakeSkin makes heavy use of the Java Executor framework to allow flexibly timed tasks to be executed reliably and concurrently. While SnakeSkin is (we think, at least) stable for competition use, we do plan to add more features in the near future including better logging and power management.
SnakeEyes was created late in the offseason, and is far from completion. In the end, it is intended to provide common, reusable vision utilities (such as data and video streaming, config, etc.) for custom vision code. Deviating from previous years, and attempting to standardize our codebase, this is also written in Kotlin (as opposed to C++ or Python from 2017 or 2016). Despite its similarity in name to SnakeSkin, it does not provide a DSL, but instead many utility classes that can be used in any way needed. This project will experience most of its development during the 2018 season, to ensure that it is usable. Currently SnakeEyes offers tiling picture-in-picture view and configurable targeting crosshairs.
One of our simplest projects this offseason, JV4L2 provides a simple JNI wrapper around the property system in V4L2. It allows Java (and Kotlin, of course) code to set properties such as exposure, contrast, brightness, or any of the other properties from the extensive list available. It was developed to be used within SnakeEyes, however is fully capable of being used standalone.
MP-Generator provides a GUI based motion profiling generator that allows easy creation and previewing of waypoints. Currently MP-Generator can generate profiles using FalconPathPlanner and export them to CSV files. MP-Generator profiles have not yet been tested. We’re working on adding Pathfinder as an option for path generation and adding functionality for displaying velocity graphs.
LightLink and LightLink-Java
LightLink and LightLink-Java provide both RIO and Arduino side code for driving Adafruit’s Neopixel addressable LED strips and rings in a variety of patterns useful for FRC. It employs a simple I2C based command system for transferring commands from the RIO to the Arduino. The Arduino code is fully state machine based, so no calls to “delay" when rendering effects. This means that transitions between effects are instant. In addition, a special mode “SIGNAL" is provided, which quickly pulses the strip in the commanded color 6 times. Signals interrupt any previously running effects, and cannot be interrupted by anything but other signals. When a signal is finished, the strip returns to its previous effect. LightLink supports up to 16 light strips simultaneously, and is fully capable of rendering each strip separately. LightLink-Java provides a simple API that should be accessible to most teams. A C++ API is planned for the future. Oh, and did I mention it has rainbows?
This repository holds the code used on our offseason robot “Kaplan". This robot made it to finals at the Rumble in the Roads offseason in Virginia, and was our first practical test of most of our offseason code. It allowed us to verify SnakeSkin’s reliability in a competition environment, and also made use of LightLink for signaling gear status (and pretty rainbows, of course). We also used this opportunity to test the 2018 beta software with SnakeSkin. Unfortunately, in the heat of the competition, we didn’t maintain our version control “best practices", so the repository is a bit of a mess. The “2018-Beta" branch represents the most recent version of the code.
All of the code we write is always publicly available on our GitHub, so please feel free to take a look at what we’ve been working on!
Of course, if you have any questions, please don’t hesitate to ask!