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

Commit a2d896b

Browse files
authored
Merge pull request #22 from Logan-Nash/master
Fixed loop times on OTOS localizer. Updated the pinpoint to the lates…
2 parents d34d56d + f494271 commit a2d896b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/localization/GoBildaPinpointDriver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,16 @@ public void setOffsets(double xOffset, double yOffset){
314314
* @param yEncoder FORWARD or REVERSED, Y (strafe) pod should increase when the robot is moving left
315315
*/
316316
public void setEncoderDirections(EncoderDirection xEncoder, EncoderDirection yEncoder){
317+
if (xEncoder == EncoderDirection.FORWARD){
318+
writeInt(Register.DEVICE_CONTROL,1<<5);
319+
}
317320
if (xEncoder == EncoderDirection.REVERSED) {
318321
writeInt(Register.DEVICE_CONTROL,1<<4);
319322
}
323+
324+
if (yEncoder == EncoderDirection.FORWARD){
325+
writeInt(Register.DEVICE_CONTROL,1<<3);
326+
}
320327
if (yEncoder == EncoderDirection.REVERSED){
321328
writeInt(Register.DEVICE_CONTROL,1<<2);
322329
}

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/pedroPathing/localization/localizers/OTOSLocalizer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ public OTOSLocalizer(HardwareMap map, Pose setStartPose) {
108108
*/
109109
@Override
110110
public Pose getPose() {
111-
SparkFunOTOS.Pose2D rawPose = otos.getPosition();
112-
Pose pose = new Pose(rawPose.x, rawPose.y, rawPose.h);
111+
Pose pose = new Pose(otosPose.x, otosPose.y, otosPose.h);
113112

114-
return MathFunctions.addPoses(startPose, MathFunctions.rotatePose(pose, startPose.getHeading(), false));
113+
Vector vec = pose.getVector();
114+
vec.rotateVector(startPose.getHeading());
115+
116+
return MathFunctions.addPoses(startPose, new Pose(vec.getXComponent(), vec.getYComponent(), pose.getHeading()));
115117
}
116118

117119
/**

0 commit comments

Comments
 (0)