Team 271 2019 Preseason Code Release

So below will be the link to our git release of the code we’ve been working on for the last 3 weeks

First off, we’re extremely grateful to everyone who has contributed to the WPILibs and nothing in the following post is “a dig” or should be taken to heart by the community.

Over the past 2 years or so we’ve slowly decided to use less and less of the supplied libraries for various reasons, but mainly we just like being in full control, having a concrete idea of exactly what is running underneath our code, and being able to get rid of anything that we don’t need. Our goal this off season was to remove all dependencies other then the closed source libraries (NI libraries, FRC Net Comms, ChipObject, Phoenix CCI, etc ) and we are very pleased with our results. Also by no means complete, its missing a ton of features, is in the middle of major refactors, etc so take it all with a grain of salt.

Features/Design/Notes/Future Plans/Rambling:

  • ZMQ for all networking
  • QT Dashboard
    • We have lots of widgets planned but this is the far behind in development
  • Robot Simulator
    • Lots of work to be done here too, but right now lets us do a lot of framework testing without a RIO
  • All robot variables are synced at the end of every loop to all nodes ( dashboard<->robot<->jetson etc )
    • Worst case deign goal is 1mbit max
    • Typically, we were seeing sending the entire robot state at 100Hz was under 0.2mbit
  • Robot Loop
    • Entire loop runs at 100Hz
    • Way less than 1ms of jitter
    • Under 40% RIO CPU usage
    • We run as a realtime prio, and at the end of our loop negatively pad our sleep time and when we come back sit in a tight while loop until we at exactly 10ms since the last loop ran, this tries to exploit the RT-Preempt features of the kernel
    • We sample all inputs at the beginning as tightly as we can, then set all outputs at the end once and as tightly as we can
    • Something we found to work for us is changing the status frame of all slave motors to something real slow, this reduced our CAN usage by as much as 30% without any noticed effects
    • Not doing much for this offseason robot so take all that with a grain of salt
  • Common code base across all builds and platforms and future years/projects
  • Big focus on abstracting out the hardware so we can mix and match/switch in and out motor controllers and sensors easily
    • With a few enum changes be able to switch between SRX/Max
    • Hopefully be able to easily switch between Local and Remote sensors, mainly for if we want use a SRX for our control loop and Max for our output
    • Hot swap SRX with SPX in an emergency without having to change code and it be able to take the appropriate actions such as knowing to use the PDP for current limiting, we seem to be able to do this by reading the firmware version but that call has been flakey depending on how soon we call it relative to getting the phoenix framework initialized message?

Warning: I DO NOT recommend anyone uses any of this code or this approach. While we didn’t use the WPI Library on the field in 2018 we did use the HAL. This code has not been tested on the field, and other teams, FTAs, etc will not be able to help you if you have issues. We do not want to hear that a team lost a match do to using our code :frowning:

1 Like