VingVing Robot LogoVingVing Robot

Documentation v0.0.3

VingVing Robot Docs

Path Constraints

Limit robot velocity and acceleration for safety and mechanism protection

Why Constraints?

Constraints prevent the robot from moving too fast or accelerating too quickly, protecting mechanisms and ensuring stable operation during critical tasks.

Velocity Constraints

Setting Maximum Velocity:

// Global constraint in RobotConfig
public static FollowerConstants followerConstants = new FollowerConstants()
    .maxVelocity(45.0);  // Never exceed 45 in/s

// Per-path constraint
Path safePath = new BezierLine(new Point(48, 0, Point.CARTESIAN))
    .setConstantHeadingInterpolation(0)
    .setMaxVelocity(30.0);  // This path limited to 30 in/s

Common Use Cases:

  • Carrying Game Elements: Reduce speed when holding pixels/cones to prevent dropping
  • Extended Mechanisms: Limit velocity when arm is extended to prevent tipping
  • Vision Processing: Slower movement for clearer camera images
  • Testing/Debugging: Run paths at reduced speed while tuning

Acceleration Constraints

Limiting Acceleration:

// In RobotConfig - prevent aggressive acceleration
public static FollowerConstants followerConstants = new FollowerConstants()
    .maxAcceleration(40.0);  // Limit to 40 in/s²

// Prevents:
// - Wheel slip on rapid starts
// - Game elements falling off robot
// - Tipping with high center of gravity

When to Use Acceleration Limits:

  • Robot with high center of gravity (tall mechanisms) - prevent tipping
  • Slippery field surface - reduce wheel slip
  • Carrying delicate game elements - gentle movements
  • After picking up heavy objects - stability during acceleration

Rotational Constraints

// Limit how fast robot can rotate
public static FollowerConstants followerConstants = new FollowerConstants()
    .maxAngularVelocity(Math.toRadians(120));  // Max 120°/sec rotation

// Prevents:
// - Excessive centrifugal force on game elements
// - IMU errors from rapid rotation
// - Unstable heading control

Dynamic Constraints

Changing Constraints During Path:

Path adaptiveConstraints = new BezierCurve(/* ... */)
    .setTangentHeadingInterpolation()
    .addCallback(0.3, () -> {
        // Picked up pixel - slow down
        follower.setMaxVelocity(35.0);
        follower.setMaxAcceleration(30.0);
    })
    .setPathEndCallback(() -> {
        // Delivered pixel - back to full speed
        follower.setMaxVelocity(55.0);
        follower.setMaxAcceleration(50.0);
    });

Complete Example

ConstrainedAuto.java
@Autonomous
public class ConstrainedAuto extends LinearOpMode {
    @Override
    public void runOpMode() {
        Robot robot = new Robot(hardwareMap, RobotConfig.class);
        robot.initializeLocalizer(hardwareMap);
        Follower follower = new Follower(hardwareMap);

        waitForStart();

        // Path 1: Fast approach (no constraints)
        follower.followPath(
            new BezierLine(new Point(30, 0, Point.CARTESIAN))
                .setConstantHeadingInterpolation(0)
        );

        while (!follower.isPathComplete() && opModeIsActive()) {
            robot.update();
            follower.update();
            robot.setDrivePowers(follower.getMotorPowers());
        }

        // Pick up pixel
        intake.grab();
        sleep(300);

        // Path 2: Careful movement with pixel (constrained)
        follower.followPath(
            new BezierCurve(
                new Point(30, 0, Point.CARTESIAN),
                new Point(30, 0, Point.CARTESIAN),
                new Point(35, 20, Point.CARTESIAN),
                new Point(20, 40, Point.CARTESIAN),
                new Point(8, 48, Point.CARTESIAN)
            ).setLinearHeadingInterpolation(Math.toRadians(90))
                .setMaxVelocity(30.0)        // Slower
                .setMaxAcceleration(25.0)    // Gentler
        );

        while (!follower.isPathComplete() && opModeIsActive()) {
            robot.update();
            follower.update();
            robot.setDrivePowers(follower.getMotorPowers());
        }

        // Score pixel
        intake.release();
    }
}

Constraint Tips

💡 Test Without Constraints First

Run paths at full speed first to establish baseline performance. Add constraints only where needed.

Constraints vs. Deceleration Zones

Constraints set hard limits (never exceed). Deceleration zones target specific speeds. Use constraints for safety, deceleration for precision.

💡 Balance Speed and Safety

Over-constraining makes autonomous slow. Under-constraining risks damage. Find the sweet spot through testing.