forked from FIRST-Tech-Challenge/FtcRobotController
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPinpointDrive.java
More file actions
135 lines (135 loc) · 6.44 KB
/
PinpointDrive.java
File metadata and controls
135 lines (135 loc) · 6.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//package org.firstinspires.ftc.teamcode;
//
//import com.acmerobotics.roadrunner.Pose2d;
//import com.acmerobotics.roadrunner.PoseVelocity2d;
//import com.acmerobotics.roadrunner.ftc.FlightRecorder;
//import com.acmerobotics.roadrunner.ftc.GoBildaPinpointDriver;
//import com.acmerobotics.roadrunner.ftc.GoBildaPinpointDriverRR;
//import com.qualcomm.robotcore.hardware.HardwareMap;
//import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
//import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
//import org.firstinspires.ftc.robotcore.external.navigation.Pose2D;
//import org.firstinspires.ftc.teamcode.messages.PoseMessage;
//
///**
// * Experimental extension of MecanumDrive that uses the Gobilda Pinpoint sensor for localization.
// * <p>
// * Released under the BSD 3-Clause Clear License by j5155 from 12087 Capital City Dynamics
// * Portions of this code made and released under the MIT License by Gobilda (Base 10 Assets, LLC)
// * Unless otherwise noted, comments are from Gobilda
// */
//public class PinpointDrive extends MecanumDrive {
// public static Params PARAMS = new Params();
// public GoBildaPinpointDriverRR pinpoint;
// private Pose2d lastPinpointPose = pose;
// public PinpointDrive(HardwareMap hardwareMap, Pose2d pose) {
// super(hardwareMap, pose);
// FlightRecorder.write("PINPOINT_PARAMS", PARAMS);
// pinpoint = hardwareMap.get(GoBildaPinpointDriverRR.class, "odo");
//
// // RR localizer note: don't love this conversion (change driver?)
// pinpoint.setOffsets(DistanceUnit.MM.fromInches(PARAMS.xOffset), DistanceUnit.MM.fromInches(PARAMS.yOffset));
// pinpoint.setEncoderResolution(PARAMS.encoderResolution);
// pinpoint.setEncoderDirections(PARAMS.xDirection, PARAMS.yDirection);
//
// /*
// Before running the robot, recalibrate the IMU. This needs to happen when the robot is stationary
// The IMU will automatically calibrate when first powered on, but recalibrating before running
// the robot is a good idea to ensure that the calibration is "good".
// resetPosAndIMU will reset the position to 0,0,0 and also recalibrate the IMU.
// This is recommended before you run your autonomous, as a bad initial calibration can cause
// an incorrect starting value for x, y, and heading.
// */
// //pinpoint.recalibrateIMU();
// pinpoint.resetPosAndIMU();
// // wait for pinpoint to finish calibrating
// try {
// Thread.sleep(300);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
//
// pinpoint.setPosition(pose);
// }
//
// @Override
// public PoseVelocity2d updatePoseEstimate() {
// if (lastPinpointPose != pose) {
// // RR localizer note:
// // Something else is modifying our pose (likely for relocalization),
// // so we override otos pose with the new pose.
// // This could potentially cause up to 1 loop worth of drift.
// // I don't like this solution at all, but it preserves compatibility.
// // The only alternative is to add getter and setters, but that breaks compat.
// // Potential alternate solution: timestamp the pose set and backtrack it based on speed?
// pinpoint.setPosition(pose);
// }
// pinpoint.update();
// pose = pinpoint.getPositionRR();
// lastPinpointPose = pose;
//
// // RR standard
// poseHistory.add(pose);
// while (poseHistory.size() > 100) {
// poseHistory.removeFirst();
// }
//
// FlightRecorder.write("ESTIMATED_POSE", new PoseMessage(pose));
// FlightRecorder.write("PINPOINT_RAW_POSE", new FTCPoseMessage(pinpoint.getPosition()));
// FlightRecorder.write("PINPOINT_STATUS", pinpoint.getDeviceStatus());
//
// return pinpoint.getVelocityRR();
// }
//
// public static class Params {
// /*
// Set the odometry pod positions relative to the point that the odometry computer tracks around.
// The X pod offset refers to how far sideways from the tracking point the
// X (forward) odometry pod is. Left of the center is a positive number,
// right of the center is a negative number. The Y pod offset refers to how far forwards from
// the tracking point the Y (strafe) odometry pod is: forward of the center is a positive number,
// backwards is a negative number.
// */
// // RR localizer note: These units are inches, presets are converted from mm (which is why they are inexact)
// //Distance between pods -- 162mm. 200 - 135mm = 65mm
// public double xOffset = -3.18898; //81 mm
// public double yOffset = -2.55906; //65 mm
//
// /*
// Set the kind of pods used by your robot. If you're using goBILDA odometry pods, select either
// the goBILDA_SWINGARM_POD or the goBILDA_4_BAR_POD.
// If you're using another kind of odometry pod, input the number of ticks per millimeter for that pod.
//
// RR LOCALIZER NOTE: this is ticks per MILLIMETER, NOT inches per tick.
// This value should be more than one; the value for the Gobilda 4 Bar Pod is approximately 20.
// To get this value from inPerTick, first convert the value to millimeters (multiply by 25.4)
// and then take its inverse (one over the value)
// */
// public double encoderResolution = GoBildaPinpointDriverRR.goBILDA_4_BAR_POD;
//
// /*
// Set the direction that each of the two odometry pods count. The X (forward) pod should
// increase when you move the robot forward. And the Y (strafe) pod should increase when
// you move the robot to the left.
// */
// public GoBildaPinpointDriver.EncoderDirection xDirection = GoBildaPinpointDriver.EncoderDirection.REVERSED;
// public GoBildaPinpointDriver.EncoderDirection yDirection = GoBildaPinpointDriver.EncoderDirection.FORWARD;
// }
//
// // for debug logging
// public static final class FTCPoseMessage {
// public long timestamp;
// public double x;
// public double y;
// public double heading;
//
// public FTCPoseMessage(Pose2D pose) {
// this.timestamp = System.nanoTime();
// this.x = pose.getX(DistanceUnit.INCH);
// this.y = pose.getY(DistanceUnit.INCH);
// this.heading = pose.getHeading(AngleUnit.RADIANS);
// }
// }
//
//
//}