Search in sources :

Example 11 with Path

use of com.team254.lib_2014.trajectory.Path in project Relic_Main by TeamOverdrive.

the class RedClose_Paths method calculateRedClose.

public static void calculateRedClose(final FieldConfig field) {
    if (bsToRight == null) {
        WaypointSequence waypointSequence = new WaypointSequence(5);
        // Path from Red Far Stone to Right Column
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(0, 0, 0));
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(field.getFarRedCryptoboxToFarStone() - 21, 23 - field.getFarRedCenterToWall(), Math.toRadians(14)));
        bsToRight = PathGenerator.makePath(waypointSequence, defaultTrajectoryConfig, WHEEL_BASE, "");
    }
}
Also used : WaypointSequence(com.team254.lib_2014.trajectory.WaypointSequence)

Example 12 with Path

use of com.team254.lib_2014.trajectory.Path in project Relic_Main by TeamOverdrive.

the class RedFar_Paths method calculateRedFar.

public static void calculateRedFar(final FieldConfig field) {
    if (bsToRight == null) {
        WaypointSequence waypointSequence = new WaypointSequence(5);
        /**
         * Right *
         */
        // Path from Red Far Stone to Right Column
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(0, 0, 0));
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(field.getFarRedCryptoboxToFarStone() - 20, 29 - field.getFarRedCenterToWall(), Math.toRadians(15)));
        bsToRight = PathGenerator.makePath(waypointSequence, defaultTrajectoryConfig, WHEEL_BASE, "");
        /**
         * Center *
         */
        // Path from Red Fat Stone to Center Column
        waypointSequence = new WaypointSequence(5);
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(0, 0, 0));
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(field.getFarRedCryptoboxToFarStone() - 18, 29 - field.getFarRedCenterToWall(), -15));
        bsToCenter = PathGenerator.makePath(waypointSequence, defaultTrajectoryConfig, WHEEL_BASE, "");
        /**
         * Left To Glyph Pit*
         */
        waypointSequence = new WaypointSequence(5);
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(0, 0, 0));
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(33, -10, 0));
        leftToGP = PathGenerator.makePath(waypointSequence, defaultTrajectoryConfig, WHEEL_BASE, "");
        leftToGP.goLeft();
    }
}
Also used : WaypointSequence(com.team254.lib_2014.trajectory.WaypointSequence)

Example 13 with Path

use of com.team254.lib_2014.trajectory.Path in project K-9 by TheGreenMachine.

the class AdaptivePurePursuitController method getDirection.

/**
 * Gives the direction the robot should turn to stay on the path
 *
 * @param pose  robot pose
 * @param point lookahead point
 * @return the direction the robot should turn: -1 is left, +1 is right
 */
public static int getDirection(Pose2d pose, Translation2d point) {
    Translation2d poseToPoint = new Translation2d(pose.getTranslation(), point);
    Translation2d robot = pose.getRotation().toTranslation();
    double cross = robot.x() * poseToPoint.y() - robot.y() * poseToPoint.x();
    // if robot < pose turn left
    return (cross < 0) ? -1 : 1;
}
Also used : Translation2d(com.team254.lib.geometry.Translation2d)

Example 14 with Path

use of com.team254.lib_2014.trajectory.Path in project K-9 by TheGreenMachine.

the class Path method verifySpeeds.

/**
 * Ensures that all speeds in the path are attainable and robot can slow down in time
 */
public void verifySpeeds() {
    double maxStartSpeed = 0.0;
    double[] startSpeeds = new double[segments.size() + 1];
    startSpeeds[segments.size()] = 0.0;
    for (int i = segments.size() - 1; i >= 0; i--) {
        PathSegment segment = segments.get(i);
        maxStartSpeed += Math.sqrt(maxStartSpeed * maxStartSpeed + 2 * Constants.kPathFollowingMaxAccel * segment.getLength());
        startSpeeds[i] = segment.getStartState().vel();
        // System.out.println(maxStartSpeed + ", " + startSpeeds[i]);
        if (startSpeeds[i] > maxStartSpeed) {
            startSpeeds[i] = maxStartSpeed;
        // System.out.println("Segment starting speed is too high!");
        }
        maxStartSpeed = startSpeeds[i];
    }
    for (int i = 0; i < segments.size(); i++) {
        PathSegment segment = segments.get(i);
        double endSpeed = startSpeeds[i + 1];
        MotionState startState = (i > 0) ? segments.get(i - 1).getEndState() : new MotionState(0, 0, 0, 0);
        startState = new MotionState(0, 0, startState.vel(), startState.vel());
        segment.createMotionProfiler(startState, endSpeed);
    }
}
Also used : MotionState(com.team254.lib.motion.MotionState)

Example 15 with Path

use of com.team254.lib_2014.trajectory.Path in project Relic_Main by TeamOverdrive.

the class BlueFar_Paths method calculateBlueFar.

public static void calculateBlueFar(final FieldConfig field) {
    if (bsToRight == null) {
        WaypointSequence waypointSequence = new WaypointSequence(5);
        // Path from Red Far Stone to Right Column
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(0, 0, 0));
        waypointSequence.addWaypoint(new WaypointSequence.Waypoint(field.getFarRedCryptoboxToFarStone() - 21, 23 - field.getFarRedCenterToWall(), Math.toRadians(14)));
        bsToRight = PathGenerator.makePath(waypointSequence, defaultTrajectoryConfig, WHEEL_BASE, "");
    }
}
Also used : WaypointSequence(com.team254.lib_2014.trajectory.WaypointSequence)

Aggregations

Path (com.team254.lib_2014.trajectory.Path)16 WaypointSequence (com.team254.lib_2014.trajectory.WaypointSequence)10 Trajectory (com.team254.lib_2014.trajectory.Trajectory)9 TrajectoryGenerator (com.team254.lib_2014.trajectory.TrajectoryGenerator)9 ElapsedTime (com.qualcomm.robotcore.util.ElapsedTime)2 Twist2d (com.team254.lib.geometry.Twist2d)2 MotionState (com.team254.lib.motion.MotionState)2 FollowPath (com.team2753.splines.FollowPath)2 TrajectoryDriveController (com.team2753.splines.TrajectoryDriveController)2 Drive (com.team2753.subsystems.Drive)2 Pose2d (com.team254.lib.geometry.Pose2d)1 Translation2d (com.team254.lib.geometry.Translation2d)1 MotionProfileConstraints (com.team254.lib.motion.MotionProfileConstraints)1 MotionProfileGoal (com.team254.lib.motion.MotionProfileGoal)1 PhoneLogger (com.team2753.libs.PhoneLogger)1 FollowerConfig (com.team2753.trajectory.FollowerConfig)1 StringTokenizer (java.util.StringTokenizer)1