Gobilda Starter Bot Auto Code

Hello Everyone

Hoping someone can help out.

We’re currently working with the goBILDA StarBot and have made several mechanical improvements to its design. Using the goBILDA starter code, we’ve successfully programmed basic movement and customized the TeleOp mode — including speed adjustments — which are all functioning correctly.

Our next goal is to integrate state machines into the autonomous code. While the TeleOp implementation works as expected, we’re running into some difficulties incorporating the same logic into the Auto program. We’re coding in Java and would appreciate any guidance on the best practices for integrating state machines into the autonomous framework.

Greetings @ridehoyos011!

I like to refer to two paradigms of programming commonly used in FTC as “deterministic programming” and “stateful programming”.

  • Deterministic Programming - When you call a deterministic function, it will always produce a predictable result based on its input parameters free of side-effects and hidden dependencies outside the stated function purpose.
  • Stateful Programming - This is virtually the opposite of deterministic programming. When you call a stateful function, it usually requires calling it repeatedly in a loop until the stated behavior has been accomplished (which may or may not be returned via a return status). This function will have side-effects which are inherent to its use.

In this case, notice that the Autonomous and Teleop programs extend OpMode, and not LinearOpMode. The OpMode is also called an “iterative OpMode”, meaning it has looping functions that constantly repeat (using loop functions that the OpMode construct constantly calls) and iterate through their functions over and over again until the program is cancelled. The OpMode class is designed for “Stateful” programming, since unlike a LinearOpMode there is no “context” between calls in a loop() function. Iterative OpModes can be very difficult for rookie programmers to understand, which is why the LinearOpMode construct was designed.

This isn’t something I can easily walk you through on a forum post. Are you borrowing the functions that goBILDA created for your own Java classes that derive from LinearOpMode, or are you trying to use the goBILDA Java sample code as-is using the default OpMode construct? This will guide how we proceed.

-Danny