Markers
All of these methods autoconvert to inches/radians/seconds behind the scenes, from the units set up in GlobalUnits.
For example, if GlobalUnits is set-up as inches/degrees/milliseconds, you can do something like
.turn(90)
to turn 90 degrees, and it does Math.toRadians(90)
automatically.
These are the three mappings that correspond to the built-in markers.
All of these functions return the Anvil instance to allow for method chaining (like so)
- Java
- Kotlin
Anvil.forgeTrajectory(drive, startPose)
.forward(...)
.back(...)
.lineTo(...);
Anvil.forgeTrajectory(drive, startPose)
.forward(...)
.back(...)
.lineTo(...)
Click on the 'Roadrunner mapping' link to go to the LearnRoadRunner docs for the method! Heavy credit goes to the Roadrunner/LearnRoadRunner team fo their great library and documentation.
Some resources
Roadrunner marker use examples
Visual explanation of TrajectorySequences & Markers
anvil.addTemporalMarker()
Roadrunner mapping (UNSTABLE_addTemporalMarkerOffset)
This function allows you to set a marker at the current duration plus the offset. The offset runs 'x' time units relative to where it was called. An offset of zero means that it should run immediately when it's called.
Time unit (e.g. milliseconds or centuries or something) can be specified in GlobalUnits
*Defaults to seconds
0
- Java
- Kotlin
Anvil.forgeTrajectory(...)
.addTemporalMarker(10, () -> { // Called 10 sec after traj start
telemetry.addLine("I'm called last!");
})
.waitTime(5) // Waits 5 seconds before continuing
.addTemporalMarker(() -> { // Called 5 sec + 0 sec after traj start
telemetry.addLine("I'm called second!");
})
.addTemporalMarker(-2, () -> { // Called 5 sec - 2 sec after traj start
telemetry.addLine("I'm called first"!);
});
Anvil.forgeTrajectory(...)
.addTemporalMarker(10) { // Called 10 sec after traj start
telemetry.addLine("I'm called last!")
}
.waitTime(5) // Waits 5 seconds before continuing
.addTemporalMarker { // Called 5 sec + 0 sec after traj start
telemetry.addLine("I'm called second!")
}
.addTemporalMarker(-2) { // Called 5 sec - 2 sec after traj start
telemetry.addLine("I'm called first"!)
}
anvil.addDisplacementMarker()
Roadrunner mapping (UNSTABLE_addDisplacementMarkerOffset)
This function allows you to set a marker at the current displacement plus the offset. The offset runs 'x' displacement relative to where it was called. An offset of zero means that it should run immediately when it's called.
Distance unit (e.g. cm or smoots or something) can be specified in GlobalUnits
*Defaults to inches
0
- Java
- Kotlin
Anvil.forgeTrajectory(...)
.splineTo(10, 10, 0)
// Will run at whatever time after the initial splineTo PLUS 3 distance units.
.addDisplacementMarker(3, () -> {
telemetry.addLine("Hi!");
});
Anvil.forgeTrajectory(...)
.splineTo(10, 10, 0)
// Will run at whatever time after the initial splineTo PLUS 3 distance units.
.addDisplacementMarker(3) {
telemetry.addLine("Hi!")
}
anvil.addSpatialMarker()
Roadrunner mapping (addSpatialMarker)
"Spatial markers allow you to run an action based on a specified coordinate. This may be a bit unpredictable as Road Runner will project that coordinate you specified onto the path. This means that it will run at the point in the path closest to your specified coordinate. I personally don't recommend using spatial markers as they aren't very explicit." ~ LRR docs
Distance unit (e.g. cm or smoots or something) can be specified in GlobalUnits
*Defaults to inches