Team 1678 2018 Code Release

Team 1678 is proud to release the code for our 2018 robot, Lemon Zest!

https://github.com/frc1678/robot-code-public

Features:

  • Custom build/deploy system using Bazel
  • HTML dashboard for data viewing and auto selection
  • Automated testing with gtest-based unit tests for each subsystem
  • Message queues for thread-safe communication - every message sent is logged
  • Integration testing using Jenkins CI
  • Automatic encoder fault detection
  • Model-based control (state-space) on the wrist and elevator
  • Trapezoidal motion profiling with time estimation for smooth collision-free movements on the wrist and elevator
  • Real-time reparametrization of quintic Hermite splines via the characteristic differential equation of the system in state-space form.
  • 3 cube auto
  • Field-relative positioning using nonlinear state estimation. *
  • 308 PRs merged to master during build season
  • 2 775pros burnt out
  • 1 Drivetrain CIM plugged in backwards

*It’s just odometry + a Kalman filter

Please feel free to ask questions about what we’ve done - we’re happy to answer!

Yeah but do you do field… oh…

Boo, you’ve ruined the mystique.

There is a …lack… of calls to wpilib in this code.:yikes: I don’t know C++ well at all but when I do this code is going to be fun to explore.

What resources did you use to learn to code this well?

SWEET!!! I’m trying to move our programmers towards Test Driven Development. I had some issues dealing with WPI and unit testing on a laptop. I’m looking forward to looking at your code to see how you isolated WPILIB so you could unit test.

::rtm:: Shh…don’t disturb me, I’m reading code.

Brian

  1. Why did you choose to reorganize your team repository to be monolithic?
  2. I noticed an interesting line of code here…would you mind elaborating on the nature of your collaboration with 971?
  3. Some of your documentation references advanced control theory concepts. How do you teach these things to students? Are there any good resources that you’d recommend for someone who would like to learn more - especially someone whose control theory expertise begins and ends with PID?

The students can reply with specifics, but the quality of our code is dependent on our peer to peer teaching model. 1678 has no software mentors, so it is critical that our older students pass their knowledge down effectively to the next generation.

-Mike

I won’t say that we wrote it just for Adam’s reaction - there was also something about auto modes needing to actually work - but I also won’t say it isn’t a nice benefit :wink: .

The WPILib interface is in “c2018/wpilib” and contains all of the actual calls to WPILib. It reads outputs from message queues (and writes sensor values), which are essentially locked ring buffers. As you mentioned, this lets us unit test everything - it’s nice to be able to rewrite code at competition and have it work without breaking the robot, and comprehensive unit testing has allowed us to do that. I’m a huge fan.

I’ll preface this by saying that our process is constantly changing, and we definitely haven’t narrowed in on a method that works perfectly. That said, our process this year was, in my opinion, the smoothest it’s ever gone (especially considering that (a) we have no programming mentors, so we had to run everything ourselves, and (b) we had a massive amount of programming students this year). We first taught the new students Python, using a curriculum that we developed over the summer - this emphasized the concepts without letting people get hung up on syntax. Then, about halfway through the offseason, we transitioned them to C++, mostly explaining syntax at this point. After they got the hang of syntax (to a point that it was workable - we hand-waved templates as “magic” to a degree), we got into the meat and bones of robot-specific programming - architecture, control loops, mechanisms, etc. For the first few weeks of build season, before we have a robot, most of our time is spent actually writing new code. During this time, we divy up the work by pairing up experienced members with new members and pair programming. Again, all this said, a lot of the work (more than I’d like, to be honest) was done by experienced (year 2+) students.

Like I said, a lot of the code this year was not written by new students. This includes all of the control theory - it’s nearly impossible to teach someone who hasn’t taken calculus concepts from Calc I, Calc II, linear algebra, and differential equations in a single offseason. Most of our students who understand these concepts put a ton of work in over the offseason to self-study, and practiced implementation on our offseason robot. In terms of resources…well, to be honest, I’m always looking for better resources to teach these concepts too. I’ve found UMich’s pages to be a pretty helpful resource, and one of our alums created a few blog posts that are basically equivalent to how I teach interested students.

We love to steal from the best and invent the rest. When it comes to controls, 971 is the best. Besides the resources I mentioned above, the single most helpful resource I’ve used for learning some of this stuff is reading through 971’s code. For learning state-space modelling and control, seeing a practical implementation can really solidify understanding in a way that’s hard to do with just theory. We use a version of their drivetrain code, although we’ve modified it to support a few extra features (path reparametrization/following being the big one). The monorepo structure is another technique we’ve borrowed from them - it gets around versioning issues with our year-independent libraries (muan) and lets us check new code against old codebases. Still, it can be a bit of a pain, and I’m somewhat torn on whether or not it’s a net benefit.

1 Like

I’d say the code did its job. :wink:

Congrats on a sixth consecutive Einstein appearance, 1678. Thanks for taking 1619 with you.

Fortunately I’m out of town with little laptop access time, otherwise I’d spend hours digging through this.

What advantages does a Bazel environment have over a more GradleRIO deploy? Integrated testing?

Bazel is much, much faster (almost 20 times faster). Since our code is so large (nearly 6K lines of used SLOC) the difference is very noticeable. It’s integration with Google Test, easy to read BUILD file syntax, and integration with protobuf (especially protobuf) make it a must. Skylark is also nice, as we’ve been able to make a generic build/deploy system.

The only really annoying bit about Bazel is cross-compiling. Bazel’s CROSSTOOL setup can be a real pain, although we have a reasonably funcional setup currently. Since Bazel is still coming out of beta, there are breaking changes more often than you might get with Gradle (although these have been mostly easy to fix).

I love “student driven” teams …
Oh, yeah, and scorch plotters & schemers.

1 Like

Tim, you seem to have strong enough opinions since you’re taking pot shots at 1678 in a thread where they’re sharing their work and resources with the community.

I encourage you… please elaborate.

I don’t know about you but I think “scorch plotters & schemers” are pretty @#@#@#@ing cool.

For those of us who went to the northern post-season expo instead of the southern one can you elaborate?

I don’t see any declines from a scorch on Newton:

Alliance 1: 'frc3310', 'frc118', 'frc6377', 'frc3128'] Declines: ]
Alliance 2: 'frc1678', 'frc1619', 'frc4061', 'frc1723'] Declines: ]
Alliance 3: 'frc3853', 'frc968', 'frc4468', 'frc2367'] Declines: ]
Alliance 4: 'frc3309', 'frc971', 'frc3481', 'frc1251'] Declines: ]
Alliance 5: 'frc1648', 'frc687', 'frc5199', 'frc6474'] Declines: ]
Alliance 6: 'frc624', 'frc5554', 'frc5654', 'frc1982'] Declines: ]
Alliance 7: 'frc4513', 'frc2403', 'frc3164', 'frc5663'] Declines: ]
Alliance 8: 'frc5104', 'frc604', 'frc1011', 'frc6424'] Declines: ]
1 Like

He might be referring to the 2013 scorch of Curie though seems unrelated.

I’m not interested in derailing this thread further, but the data you have is incorrect. 624 declined 1648. If you’re pulling this from TBA, know that the declines field is not accurate - it’s always blank.

Kyle, et. al., I have a few follow-up questions for you:

There’s been some discussion on Github about unit-testable WPILib for 2019. Do you anticipate that 1678 will migrate to the WPI approach if they release it?

Like I said, a lot of the code this year was not written by new students. This includes all of the control theory - it’s nearly impossible to teach someone who hasn’t taken calculus concepts from Calc I, Calc II, linear algebra, and differential equations in a single offseason. Most of our students who understand these concepts put a ton of work in over the offseason to self-study, and practiced implementation on our offseason robot. In terms of resources…well, to be honest, I’m always looking for better resources to teach these concepts too. I’ve found UMich’s pages to be a pretty helpful resource, and one of our alums created a few blog posts that are basically equivalent to how I teach interested students.

I absolutely love those resources you’ve linked. Thanks for sharing. Do you have any idea when Wesley will finish his control theory articles? What resources do you use to teach Kalman filters?

There was the threats of “I have a Zippo and I’m not afraid to use it” that affected the alliance selection process. Teams below us made it plain they would not accept offers from us, which, silly noobs that we were, we believed. In retrospect, we could have scorched the field below us. What is the difference between 2 in alliance 4, and captain of alliance 7? As it turned out, not much.

All honor from us to RAWC (968), Fernbank Links (4684) and Lancer Robotics (2367). Thanks for playing with us, we played hard, together.

More crap tomorrow about sending one’s second string scouting team out to point out that “your advances are not welcome.”