Search in sources :

Example 36 with Angle

use of me.wobblyyyy.pathfinder2.geometry.Angle in project Pathfinder2 by Wobblyyyy.

the class RelativeMecanumKinematics method calculate.

@Override
public MecanumState calculate(Translation translation) {
    double xyMagnitude = MinMax.clip(Math.hypot(translation.vx(), translation.vy()), minMagnitude, maxMagnitude);
    Angle angle = Angle.atan2(translation.vy(), translation.vx()).add(angleOffset);
    double turn = translation.vz() * turnMagnitude;
    double fl = (calculatePower(angle, WHEEL_ANGLES[0]) * xyMagnitude) + turn;
    double fr = (calculatePower(angle, WHEEL_ANGLES[1]) * xyMagnitude) - turn;
    double bl = (calculatePower(angle, WHEEL_ANGLES[2]) * xyMagnitude) + turn;
    double br = (calculatePower(angle, WHEEL_ANGLES[3]) * xyMagnitude) - turn;
    return new MecanumState(fl, fr, bl, br).normalizeFromMaxUnderOne();
}
Also used : Angle(me.wobblyyyy.pathfinder2.geometry.Angle)

Example 37 with Angle

use of me.wobblyyyy.pathfinder2.geometry.Angle in project Pathfinder2 by Wobblyyyy.

the class AngleDeltaController method calculate.

@Override
public double calculate(double value) {
    boolean isDegrees = angleUnit == Angle.AngleUnit.DEGREES;
    Angle current = Angle.fixedDeg(value);
    Angle target = Angle.fixedRad(this.getTarget());
    double delta = isDegrees ? Angle.angleDeltaDeg(current, target) : Angle.angleDeltaRad(current, target);
    return delta * this.coefficient;
}
Also used : Angle(me.wobblyyyy.pathfinder2.geometry.Angle)

Aggregations

Angle (me.wobblyyyy.pathfinder2.geometry.Angle)26 PointXYZ (me.wobblyyyy.pathfinder2.geometry.PointXYZ)21 Translation (me.wobblyyyy.pathfinder2.geometry.Translation)6 LinearTrajectory (me.wobblyyyy.pathfinder2.trajectory.LinearTrajectory)6 Trajectory (me.wobblyyyy.pathfinder2.trajectory.Trajectory)6 PointXY (me.wobblyyyy.pathfinder2.geometry.PointXY)4 Pathfinder (me.wobblyyyy.pathfinder2.Pathfinder)2 NullPointException (me.wobblyyyy.pathfinder2.exceptions.NullPointException)2 TaskTrajectory (me.wobblyyyy.pathfinder2.trajectory.TaskTrajectory)2 AdvancedSplineTrajectoryBuilder (me.wobblyyyy.pathfinder2.trajectory.spline.AdvancedSplineTrajectoryBuilder)2 Test (org.junit.jupiter.api.Test)2 ChassisSpeeds (edu.wpi.first.math.kinematics.ChassisSpeeds)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 InvalidSpeedException (me.wobblyyyy.pathfinder2.exceptions.InvalidSpeedException)1 InvalidToleranceException (me.wobblyyyy.pathfinder2.exceptions.InvalidToleranceException)1 NullAngleException (me.wobblyyyy.pathfinder2.exceptions.NullAngleException)1 SwerveModuleState (me.wobblyyyy.pathfinder2.kinematics.SwerveModuleState)1 SwerveState (me.wobblyyyy.pathfinder2.kinematics.SwerveState)1 ApacheSpline (me.wobblyyyy.pathfinder2.math.ApacheSpline)1