mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 00:38:05 -06:00
Add getRobotTilt
This commit is contained in:
@@ -42,7 +42,7 @@ public class RobotContainer {
|
||||
|
||||
private final LED m_robotLED = new LED(m_robotMap.LEDController);
|
||||
|
||||
private final Climber m_climber = new Climber(m_robotMap.shoulder, m_robotMap.elbow);
|
||||
private final Climber m_climber = new Climber(m_robotMap.shoulder, m_robotMap.elbow, m_robotMap.gyro);
|
||||
/* Controllers */
|
||||
private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID);
|
||||
private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID);
|
||||
|
||||
@@ -44,12 +44,13 @@ public class Climber extends SubsystemBase {
|
||||
|
||||
// The angle to the target point
|
||||
double theta = Math.atan(yTarget / xTarget) + tiltAngle; // TODO rename variable
|
||||
|
||||
// Correct target position for tilt
|
||||
xTarget = Math.cos(theta) * mag;
|
||||
yTarget = Math.sin(theta) * mag;
|
||||
|
||||
// Law and Order: Cosines edition
|
||||
double shoulderAngle = Math.acos((Math.pow(ClimberConstants.LOWER_ARM_LENGTH, 2) + Math.pow(mag, 2) -Math.pow(ClimberConstants.UPPER_ARM_LENGTH, 2)) /
|
||||
double shoulderAngle = Math.acos((Math.pow(ClimberConstants.LOWER_ARM_LENGTH, 2) + Math.pow(mag, 2) - Math.pow(ClimberConstants.UPPER_ARM_LENGTH, 2)) /
|
||||
(2.d * ClimberConstants.LOWER_ARM_LENGTH * mag));
|
||||
shoulderAngle = theta - shoulderAngle;
|
||||
|
||||
@@ -73,6 +74,12 @@ public class Climber extends SubsystemBase {
|
||||
return angles;
|
||||
}
|
||||
|
||||
public double getRobotTilt() {
|
||||
double[] ypr = new double[3];
|
||||
m_gyro.getYawPitchRoll(ypr);
|
||||
return ypr[1]; // Pitch
|
||||
}
|
||||
|
||||
public void setJointAngles(double[] angles) {
|
||||
setJointAngles(angles[0], angles[1]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user