Skip to content

Instantly share code, notes, and snippets.

@rbrott
rbrott / Coroutines.kt
Last active June 30, 2022 02:24
Coroutines in FF Auto
// inspired by https://github.com/JDroids/FreightFrenzy/blob/master/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/CyclingWarehouseSideAuto.java
import kotlinx.coroutines.*
typealias TrajectorySequence = String
interface MecanumDrive {
fun followTrajectorySequenceAsync(ts: TrajectorySequence)
fun update()
fun isBusy(): Boolean
@rbrott
rbrott / SealedCommands.kt
Last active June 30, 2022 02:24
Sealed Commands in FF Auto
// inspired by https://github.com/JDroids/FreightFrenzy/blob/master/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/CyclingWarehouseSideAuto.java
fun clock() = 0.0
typealias TrajectorySequence = String
interface MecanumDrive {
fun followTrajectorySequenceAsync(ts: TrajectorySequence)
fun update()
fun isBusy(): Boolean
@rbrott
rbrott / PolymorphicCommands.kt
Last active July 8, 2022 03:28
Polymorphic Commands in FF Auto
// inspired by https://github.com/JDroids/FreightFrenzy/blob/master/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/opmode/CyclingWarehouseSideAuto.java
fun clock() = 0.0
typealias TrajectorySequence = String
interface MecanumDrive {
fun followTrajectorySequenceAsync(ts: TrajectorySequence)
fun update()
fun isBusy(): Boolean
@rbrott
rbrott / threads.md
Last active April 28, 2022 01:28
Multithreading FTC SDK Hardware Calls

Multithreading FTC SDK hardware calls cannot improve call throughput and unpredictably increases call latency.

(Based on FTC SDK v7.1. You decide whether changes in subsequent releases compromise the argument.)

The bulk of time spent in a hardware call is waiting for a Lynx message response in the body of LynxRespondable#send() or LynxRespondable#sendReceive(). Both methods need to acquire the network lock before any data transmission occurs.

package org.firstinspires.ftc.teamcode;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import com.qualcomm.hardware.bosch.BNO055IMU;
import com.qualcomm.hardware.lynx.LynxEmbeddedIMU;
import com.qualcomm.hardware.lynx.LynxI2cDeviceSynch;
import com.qualcomm.hardware.lynx.LynxI2cDeviceSynchV1;
@rbrott
rbrott / proguard-rules.pro
Created October 13, 2018 19:30
FTC SDK/Road Runner Proguard Rules
# Avoid touching the FTC SDK
-keep class com.qualcomm.** {*;}
-keep class org.firstinspires.** {*;}
-keep class com.google.blocks.** {*;}
-keep class com.vuforia.** {*;}
-keep class javax.** {*;}
-dontwarn com.qualcomm.**
-dontwarn org.firstinspires.**
-dontwarn com.vuforia.**
package com.qualcomm.hardware.lynx;
import com.qualcomm.hardware.stmicroelectronics.VL53L0X;
import com.qualcomm.robotcore.hardware.I2cDeviceSynch;
import com.qualcomm.robotcore.hardware.configuration.I2cSensor;
/**
* {@link REVLaserDistanceSensor} implements support for the REV Robotics time-of-flight distance sensor.
*
* @see <a href="http://revrobotics.com">REV Robotics Website</a>