Skip to content

BlazeFTC

Using the BlazeFTC library, you may run your code much faster than is typically possible. Blaze runs in the background, “behind” the SDK and polls data without any user input at all. On the Control Hub or on a USB Expansion Hub, a slow mode Bulk Read hook can easily provide data at 500 hz. For more information on how that works, or to accelerate i2c calls, check out the BlazeFTC Readme.

Open TeamCode/build.gradle and add the following to your dependencies block:

implementation 'dev.anygeneric:blazeftc:0.1.67'

Then add the following to the repositories block to allow Gradle to find it:

maven {
url 'https://maven.anygeneric.dev/'
}

To take advantage of Blaze, extend BlazeOpMode instead of NextOpMode. This turns Blaze on for the whole OpMode and routes motor writes through it. Then pass a BlazeBulkReadHook as an extra constructor argument to have Blaze provide bulk data:

@NextTeleop(name = "My Teleop")
class MyTeleop(robot: MyRobot) :
BlazeOpMode(robot, BlazeBulkReadHook(NextLynxModule.Type.EXPANSION_HUB, false)) {
override fun periodic() {
Telemetry.log("Status", "Running")
}
override fun onExpansionHubBulkData() {
//Run PID loops here
}
}

BlazeOpMode provides these callbacks on top of the usual NextOpMode lifecycle:

Method Called
onControlHubBulkData() When Blaze provides new Control Hub bulk data.
onExpansionHubBulkData() When Blaze provides new Expansion Hub bulk data.
onLocalizationData() When Blaze provides new localization data (work in progress).

The two bulk data callbacks require a BlazeBulkReadHook on the matching hub.

BlazeBulkReadHook(hub, fastMode) takes the hub to accelerate, either NextLynxModule.Type.CONTROL_HUB or NextLynxModule.Type.EXPANSION_HUB, and a fastMode flag:

  • false runs at about 500 hz and is very stable.
  • true is stable, but doing too many writes with it enabled could make it unstable.

Do not use it together with BulkReadHook, and do not put two hooks on the same hub. The hook does nothing unless the OpMode extends BlazeOpMode.