Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Logan-Nash authored and Logan-Nash committed Oct 17, 2024
2 parents f5ac5ea + e0a96df commit 1b27bab
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class OTOSLocalizer extends Localizer {
private HardwareMap hardwareMap;
private Pose startPose;
private SparkFunOTOS otos;
private SparkFunOTOS.Pose2D otosPose;
private SparkFunOTOS.Pose2D otosVel;
private SparkFunOTOS.Pose2D otosAcc;
private double previousHeading;
private double totalHeading;

Expand Down Expand Up @@ -89,6 +92,9 @@ public OTOSLocalizer(HardwareMap map, Pose setStartPose) {
otos.resetTracking();

setStartPose(setStartPose);
otosPose = new SparkFunOTOS.Pose2D();
otosVel = new SparkFunOTOS.Pose2D();
otosAcc = new SparkFunOTOS.Pose2D();
totalHeading = 0;
previousHeading = startPose.getHeading();

Expand All @@ -102,8 +108,7 @@ public OTOSLocalizer(HardwareMap map, Pose setStartPose) {
*/
@Override
public Pose getPose() {
SparkFunOTOS.Pose2D pose = otos.getPosition();
return MathFunctions.addPoses(startPose, new Pose(pose.x, pose.y, pose.h));
return MathFunctions.addPoses(startPose, new Pose(otosPose.x, otosPose.y, otosPose.h));
}

/**
Expand All @@ -113,8 +118,7 @@ public Pose getPose() {
*/
@Override
public Pose getVelocity() {
SparkFunOTOS.Pose2D OTOSVelocity = otos.getVelocity();
return new Pose(OTOSVelocity.x, OTOSVelocity.y, OTOSVelocity.h);
return new Pose(otosVel.x, otosVel.y, otosVel.h);
}

/**
Expand Down Expand Up @@ -156,8 +160,9 @@ public void setPose(Pose setPose) {
*/
@Override
public void update() {
totalHeading += MathFunctions.getSmallestAngleDifference(otos.getPosition().h, previousHeading);
previousHeading = otos.getPosition().h;
otos.getPosVelAcc(otosPose,otosVel,otosAcc);
totalHeading += MathFunctions.getSmallestAngleDifference(otosPose.h, previousHeading);
previousHeading = otosPose.h;
}

/**
Expand Down

0 comments on commit 1b27bab

Please sign in to comment.