1- package pioneer
1+ package pioneer.constants
22
33import com.acmerobotics.dashboard.config.Config
44import com.qualcomm.hardware.gobilda.GoBildaPinpointDriver
@@ -10,129 +10,93 @@ import org.firstinspires.ftc.robotcore.external.navigation.YawPitchRollAngles
1010import pioneer.helpers.Pose
1111import kotlin.math.PI
1212
13+ // -------- Odometry (3-wheel) --------
14+ object Odometry {
15+ // geometry (cm)
16+ const val TRACK_WIDTH_CM = 26.5
17+ const val FORWARD_OFFSET_CM = 15.1
18+ const val WHEEL_DIAMETER_CM = 4.8
19+
20+ // encoder
21+ const val TICKS_PER_REV = 2000.0
22+ }
23+
24+ // -------- Drivebase (mecanum) --------
25+ object Drive {
26+ // geometry (cm)
27+ const val TRACK_WIDTH_CM = 0.0
28+ const val WHEEL_BASE_CM = 0.0
29+
30+ // limits
31+ const val MAX_MOTOR_VELOCITY_TPS = 2500.0
32+ const val MAX_FWD_VEL_CMPS = 150.0
33+ const val MAX_STRAFE_VEL_CMPS = 125.0
34+ const val DEFAULT_POWER = 0.7
35+
36+ // Feedforward gains using Pose(x,y,theta)
37+ val kV = Pose (x = 0.006 , y = 0.0052 , theta = 0.025 )
38+ val kA = Pose (x = 0.0 , y = 0.0 , theta = 0.0 )
39+ val kS = Pose (x = 0.0 , y = 0.0 , theta = 0.0 )
40+
41+ }
42+
43+ // -------- Pinpoint (odometry pods) --------
44+ object Pinpoint {
45+ // offsets from tracking point (mm): +forward, +left
46+ const val Y_POD_OFFSET_MM = - 107.0
47+ const val X_POD_OFFSET_MM = 125.0
48+
49+ // encoder configuration. Y should increase left, X should increase forward
50+ val Y_ENCODER_DIRECTION = GoBildaPinpointDriver .EncoderDirection .REVERSED
51+ val X_ENCODER_DIRECTION = GoBildaPinpointDriver .EncoderDirection .REVERSED
52+
53+ val ENCODER_RESOLUTION = GoBildaPinpointDriver .GoBildaOdometryPods .goBILDA_SWINGARM_POD
54+ }
55+
56+ // -------- Follower (path following) --------
1357@Config
14- object Constants {
15- object HardwareNames {
16- // Drive motors
17- const val DRIVE_LEFT_FRONT = " driveLF"
18- const val DRIVE_LEFT_BACK = " driveLB"
19- const val DRIVE_RIGHT_FRONT = " driveRF"
20- const val DRIVE_RIGHT_BACK = " driveRB"
21-
22- // Other motors
23- const val FLYWHEEL = " flywheel"
24-
25- // Odometry
26- const val ODO_LEFT = " odoLeft"
27- const val ODO_RIGHT = " odoRight"
28- const val ODO_CENTER = " odoCenter"
29-
30- // Pinpoint
31- const val PINPOINT = " pinpoint"
32-
33- // Servos
34- const val LAUNCH_SERVO_L = " launchServoL"
35- const val LAUNCH_SERVO_R = " launchServoR"
36-
37- // Other
38- const val WEBCAM = " Webcam 1"
39- }
40-
41- // -------- Odometry (3-wheel) --------
42- object Odometry {
43- // geometry (cm)
44- const val TRACK_WIDTH_CM = 26.5
45- const val FORWARD_OFFSET_CM = 15.1
46- const val WHEEL_DIAMETER_CM = 4.8
47-
48- // encoder
49- const val TICKS_PER_REV = 2000.0
50- const val TICKS_TO_CM : Double = (WHEEL_DIAMETER_CM * PI ) / TICKS_PER_REV
51- }
52-
53- // -------- Drivebase (mecanum) --------
54- object Drive {
55- // geometry (cm)
56- const val TRACK_WIDTH_CM = 0.0
57- const val WHEEL_BASE_CM = 0.0
58-
59- // limits
60- const val MAX_MOTOR_VELOCITY_TPS = 2500.0
61- const val MAX_FWD_VEL_CMPS = 150.0
62- const val MAX_STRAFE_VEL_CMPS = 125.0
63- const val DEFAULT_POWER = 0.7
64-
65- // Feedforward gains using Pose(x,y,theta)
66- val kV = Pose (x = 0.006 , y = 0.0052 , theta = 0.025 )
67- val kA = Pose (x = 0.0 , y = 0.0 , theta = 0.0 )
68- val kS = Pose (x = 0.0 , y = 0.0 , theta = 0.0 )
69-
70- // Motor configuration
71- val MOTOR_CONFIG = mapOf (
72- HardwareNames .DRIVE_LEFT_FRONT to DcMotorSimple .Direction .REVERSE ,
73- HardwareNames .DRIVE_LEFT_BACK to DcMotorSimple .Direction .REVERSE ,
74- HardwareNames .DRIVE_RIGHT_FRONT to DcMotorSimple .Direction .FORWARD ,
75- HardwareNames .DRIVE_RIGHT_BACK to DcMotorSimple .Direction .FORWARD
76- )
77- }
78-
79- // -------- Pinpoint (odometry pods) --------
80- object Pinpoint {
81- // offsets from tracking point (mm): +forward, +left
82- const val Y_POD_OFFSET_MM = - 107.0
83- const val X_POD_OFFSET_MM = 125.0
84-
85- // encoder configuration. Y should increase left, X should increase forward
86- val Y_ENCODER_DIRECTION = GoBildaPinpointDriver .EncoderDirection .REVERSED
87- val X_ENCODER_DIRECTION = GoBildaPinpointDriver .EncoderDirection .REVERSED
88-
89- val ENCODER_RESOLUTION = GoBildaPinpointDriver .GoBildaOdometryPods .goBILDA_SWINGARM_POD
90- }
91-
92- // -------- Follower (path following) --------
93- object Follower {
94- /* * The threshold in cm to consider the target reached. */
95- const val POSITION_THRESHOLD = 0.5
96-
97- /* * The threshold in radians to consider the target heading reached. */
98- const val ROTATION_THRESHOLD = 0.01
99-
100- /* * The maximum drive velocity in cm per second. */
101- const val MAX_DRIVE_VELOCITY = 100.0
102-
103- /* * The maximum drive acceleration in cm per second squared. */
104- const val MAX_DRIVE_ACCELERATION = 50.0
105-
106- /* * The maximum centripetal acceleration that the robot can handle in cm/s^2. */
107- const val MAX_CENTRIPETAL_ACCELERATION = (70.0 * 70.0 ) / 25.0
108-
109- // X-axis PID coefficients for the trajectory follower
110- @JvmField var X_KP = 0.0
111- @JvmField var X_KI = 0.0
112- @JvmField var X_KD = 0.0
113-
114- // Y-axis PID coefficients for the trajectory follower
115- @JvmField var Y_KP = 0.0
116- @JvmField var Y_KI = 0.0
117- @JvmField var Y_KD = 0.0
118- }
119-
120- object Camera {
121- // Camera position constants (cm)
122- private const val X_OFFSET_CM = 0.0
123- private const val Y_OFFSET_CM = 0.0
124- private const val Z_OFFSET_CM = 0.0
125-
126- // Camera orientation constants (degrees)
127- private const val DEG_TO_RAD = Math .PI / 180.0
128- private const val YAW_DEG = 0.0
129- private const val PITCH_DEG = 0.0
130- private const val ROLL_DEG = 0.0
131-
132- val POSITION_CM : Position
133- get() = Position (DistanceUnit .CM , X_OFFSET_CM , Y_OFFSET_CM , Z_OFFSET_CM , 0 )
134-
135- val ORIENTATION_RAD : YawPitchRollAngles
136- get() = YawPitchRollAngles (AngleUnit .RADIANS , YAW_DEG * DEG_TO_RAD , PITCH_DEG * DEG_TO_RAD , ROLL_DEG * DEG_TO_RAD , 0 )
137- }
58+ object Follower {
59+ /* * The threshold in cm to consider the target reached. */
60+ const val POSITION_THRESHOLD = 0.5
61+
62+ /* * The threshold in radians to consider the target heading reached. */
63+ const val ROTATION_THRESHOLD = 0.01
64+
65+ /* * The maximum drive velocity in cm per second. */
66+ const val MAX_DRIVE_VELOCITY = 100.0
67+
68+ /* * The maximum drive acceleration in cm per second squared. */
69+ const val MAX_DRIVE_ACCELERATION = 50.0
70+
71+ /* * The maximum centripetal acceleration that the robot can handle in cm/s^2. */
72+ const val MAX_CENTRIPETAL_ACCELERATION = (70.0 * 70.0 ) / 25.0
73+
74+ // X-axis PID coefficients for the trajectory follower
75+ @JvmField var X_KP = 0.0
76+ @JvmField var X_KI = 0.0
77+ @JvmField var X_KD = 0.0
78+
79+ // Y-axis PID coefficients for the trajectory follower
80+ @JvmField var Y_KP = 0.0
81+ @JvmField var Y_KI = 0.0
82+ @JvmField var Y_KD = 0.0
83+ }
84+
85+ object Camera {
86+ // Camera position constants (cm)
87+ private const val X_OFFSET_CM = 0.0
88+ private const val Y_OFFSET_CM = 0.0
89+ private const val Z_OFFSET_CM = 0.0
90+
91+ // Camera orientation constants (degrees)
92+ private const val DEG_TO_RAD = PI / 180.0
93+ private const val YAW_DEG = 0.0
94+ private const val PITCH_DEG = 0.0
95+ private const val ROLL_DEG = 0.0
96+
97+ val POSITION_CM : Position
98+ get() = Position (DistanceUnit .CM , X_OFFSET_CM , Y_OFFSET_CM , Z_OFFSET_CM , 0 )
99+
100+ val ORIENTATION_RAD : YawPitchRollAngles
101+ get() = YawPitchRollAngles (AngleUnit .RADIANS , YAW_DEG * DEG_TO_RAD , PITCH_DEG * DEG_TO_RAD , ROLL_DEG * DEG_TO_RAD , 0 )
138102}
0 commit comments