Skip to content

Commit

Permalink
update library and deal with manual pose setting
Browse files Browse the repository at this point in the history
  • Loading branch information
j5155 committed Jun 4, 2024
1 parent 4f5d8c2 commit f02ae49
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 153 deletions.
4 changes: 2 additions & 2 deletions TeamCode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies {
implementation project(':FtcRobotController')
annotationProcessor files('lib/OpModeAnnotationProcessor.jar')

implementation 'com.github.jdhs-ftc:road-runner-ftc-otos:master-SNAPSHOT'
implementation 'com.github.jdhs-ftc:road-runner-ftc-otos:5f1b6c5a05'
implementation "com.acmerobotics.roadrunner:core:1.0.0-beta8"
implementation "com.acmerobotics.roadrunner:actions:1.0.0-beta8"
implementation "com.acmerobotics.dashboard:dashboard:0.4.14"
implementation "com.acmerobotics.dashboard:dashboard:0.4.15"
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


import static com.acmerobotics.roadrunner.ftc.OTOSKt.OTOSPoseToRRPose;
import static com.acmerobotics.roadrunner.ftc.OTOSKt.RRPoseToOTOSPose;

import com.acmerobotics.roadrunner.Pose2d;
import com.acmerobotics.roadrunner.PoseVelocity2d;
Expand Down Expand Up @@ -58,6 +59,7 @@ public static class Params {

public static SparkFunOTOSDrive.Params PARAMS = new SparkFunOTOSDrive.Params();
public SparkFunOTOS otos;
private Pose2d lastOtosPose = pose;

public SparkFunOTOSDrive(HardwareMap hardwareMap, Pose2d pose) {
super(hardwareMap, pose);
Expand All @@ -69,6 +71,8 @@ public SparkFunOTOSDrive(HardwareMap hardwareMap, Pose2d pose) {
otos.setOffset(PARAMS.offset);
otos.setLinearScalar(PARAMS.linearScalar);
otos.setAngularScalar(PARAMS.angularScalar);

otos.setPosition(RRPoseToOTOSPose(pose));
// The IMU on the OTOS includes a gyroscope and accelerometer, which could
// have an offset. Note that as of firmware version 1.0, the calibration
// will be lost after a power cycle; the OTOS performs a quick calibration
Expand All @@ -86,6 +90,16 @@ public SparkFunOTOSDrive(HardwareMap hardwareMap, Pose2d pose) {
}
@Override
public PoseVelocity2d updatePoseEstimate() {
if (lastOtosPose != pose) {
// rr localizer note:
// something other then this function has modified pose
// probably the user
// so we override otos pose with the new pose
// this could potentially cause up to 1 loops worth of drift
// I don't really like this solution at all, but it preserves compatibility
// the only alternative is to add getter and setters but that breaks compat
otos.setPosition(RRPoseToOTOSPose(pose));
}
SparkFunOTOS.Pose2D otosPose = otos.getPosition();
SparkFunOTOS.Pose2D otosVel = otos.getVelocity();
pose = OTOSPoseToRRPose(otosPose);
Expand Down

0 comments on commit f02ae49

Please sign in to comment.