mirror of
https://github.com/TimeCrafters/FTC_2022
synced 2025-12-16 05:22:36 +00:00
Enable IMU reset from TeleOp, fix robot centric drive
This commit is contained in:
@@ -10,6 +10,7 @@ import org.timecrafters.minibots.cyberarm.chiron.Robot;
|
|||||||
public class DrivetrainDriverControl extends CyberarmState {
|
public class DrivetrainDriverControl extends CyberarmState {
|
||||||
private final Robot robot;
|
private final Robot robot;
|
||||||
private final String groupName, actionName;
|
private final String groupName, actionName;
|
||||||
|
private final double robotCentricRotation;
|
||||||
|
|
||||||
private Gamepad controller;
|
private Gamepad controller;
|
||||||
|
|
||||||
@@ -23,6 +24,8 @@ public class DrivetrainDriverControl extends CyberarmState {
|
|||||||
this.actionName = actionName;
|
this.actionName = actionName;
|
||||||
|
|
||||||
this.controller = engine.gamepad1;
|
this.controller = engine.gamepad1;
|
||||||
|
|
||||||
|
this.robotCentricRotation = robot.tuningConfig("robot_centric_rotation").value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,6 +53,13 @@ public class DrivetrainDriverControl extends CyberarmState {
|
|||||||
double y = invertRobotForward ? controller.left_stick_y : -controller.left_stick_y;
|
double y = invertRobotForward ? controller.left_stick_y : -controller.left_stick_y;
|
||||||
double x = (invertRobotForward && !fieldCentricControl ? controller.left_stick_x : -controller.left_stick_x);
|
double x = (invertRobotForward && !fieldCentricControl ? controller.left_stick_x : -controller.left_stick_x);
|
||||||
|
|
||||||
|
if (!fieldCentricControl) {
|
||||||
|
Vector2d v = new Vector2d(x, y).rotated(robotCentricRotation);
|
||||||
|
|
||||||
|
x = v.getX();
|
||||||
|
y = v.getY();
|
||||||
|
}
|
||||||
|
|
||||||
// Improve control?
|
// Improve control?
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
y = -Math.sqrt(-y);
|
y = -Math.sqrt(-y);
|
||||||
@@ -160,6 +170,10 @@ public class DrivetrainDriverControl extends CyberarmState {
|
|||||||
if (button.equals("right_stick_button")) {
|
if (button.equals("right_stick_button")) {
|
||||||
robotSlowMode = !robotSlowMode;
|
robotSlowMode = !robotSlowMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (button.equals("left_stick_button") && robot.hardwareFault) {
|
||||||
|
robot.imu.resetYaw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user