VingVing Robot LogoVingVing Robot

Documentation v0.0.3

VingVing Robot Docs

Deceleration Zones

Control robot speed at specific points along paths for precision and safety

Why Deceleration Zones?

By default, the path follower maintains maximum velocity throughout the path. Deceleration zones allow you to slow down at critical moments for precision, safety, or mechanism operations.

Without zones: Robot at full speed everywhere, may overshoot or damage mechanisms
With zones: Strategic slow-downs for accurate positioning and safe operation

Creating Deceleration Zones

Define zones as a percentage along the path where the robot should reduce velocity.

Basic Deceleration Zone:

Path path = new BezierLine(new Point(48, 0, Point.CARTESIAN))
    .setConstantHeadingInterpolation(0)
    .addDeceleration(
        0.8,   // Start slowing at 80% of path
        1.0,   // Slow until 100% (end)
        0.3    // Reduce to 30% of max velocity
    );

// Robot runs full speed for 80%, then slows to 30% for final 20%

Parameters Explained:

  • startT (0.0 - 1.0): Where along path to begin slowing (0 = start, 1 = end)
  • endT (0.0 - 1.0): Where to finish slowing (must be > startT)
  • targetVelocity (0.0 - 1.0): Velocity multiplier (0.5 = 50% speed, 0.2 = 20% speed)

Example: Slow Approach to Goal

// Fast approach, slow down for precision at end
Path toBackdrop = new BezierCurve(
    new Point(0, 0, Point.CARTESIAN),
    new Point(0, 0, Point.CARTESIAN),
    new Point(24, 12, Point.CARTESIAN),
    new Point(36, 36, Point.CARTESIAN),
    new Point(48, 48, Point.CARTESIAN)
).setLinearHeadingInterpolation(Math.toRadians(90))
    .addDeceleration(0.75, 1.0, 0.25);

// 75% at full speed, final 25% at 25% speed for accurate positioning

Multiple Deceleration Zones

Add multiple zones to control speed at different points along the path.

Chaining Deceleration Zones:

Path complexPath = new BezierCurve(/* ... */)
    .setTangentHeadingInterpolation()
    // Slow at 30-40% for first obstacle
    .addDeceleration(0.3, 0.4, 0.4)
    // Speed up after
    // Slow at 70-85% for second obstacle
    .addDeceleration(0.7, 0.85, 0.35)
    // Final slow approach
    .addDeceleration(0.9, 1.0, 0.2);

// Robot varies speed throughout path based on requirements

Use Cases for Multiple Zones:

  • Obstacle Avoidance: Slow near obstacles, speed up in open areas
  • Multiple Scoring: Slow at each scoring location along path
  • Vision Targeting: Reduce speed when camera needs clear view
  • Complex Mechanisms: Slow for intake, arm movements, or releases

Dynamic Speed Control

Adjust robot speed in real-time based on conditions, not just predetermined zones.

Using Path Callbacks for Dynamic Speed:

Path adaptivePath = new BezierLine(new Point(48, 0, Point.CARTESIAN))
    .setConstantHeadingInterpolation(0)
    .addCallback(0.5, () -> {
        // Slow down if vision detects obstacle
        if (visionSeesObstacle()) {
            follower.setMaxVelocity(0.3);  // Reduce to 30%
        }
    })
    .addCallback(0.7, () -> {
        // Speed back up if clear
        if (!visionSeesObstacle()) {
            follower.setMaxVelocity(1.0);  // Back to 100%
        }
    });

Dynamic Control Methods:

// In your autonomous loop
while (!follower.isPathComplete() && opModeIsActive()) {
    robot.update();
    follower.update();

    // Conditional speed adjustment
    if (intake.hasPiece()) {
        follower.setMaxVelocity(0.5);  // Slow when carrying game piece
    } else {
        follower.setMaxVelocity(1.0);  // Full speed when empty
    }

    // Or based on distance to target
    double distanceToTarget = getDistanceToBackdrop();
    if (distanceToTarget < 12.0) {
        follower.setMaxVelocity(0.25);  // Very slow when close
    }

    robot.setDrivePowers(follower.getMotorPowers());
}

Deceleration Smoothness

The follower automatically smooths velocity transitions to prevent jerky movements.

How Smoothing Works:

VingVing Robot uses acceleration limiting to gradually transition between speeds. You don't need to manually smooth - the follower handles it automatically based on your RobotConfig settings.

// In RobotConfig - acceleration limits smooth all speed changes
public static FollowerConstants followerConstants = new FollowerConstants()
    .mass(10.0)
    .forwardZeroPowerAcceleration(-38.2)
    .lateralZeroPowerAcceleration(-42.1)
    // These determine how quickly speed can change
    // Lower values = more aggressive transitions
    // Higher values = smoother, gentler transitions
    // ...

Tuning Deceleration Smoothness:

If deceleration feels too abrupt or too gradual, adjust zero-power acceleration values. More negative = harder braking. Less negative = gentler braking.

Practical Examples

Example 1: Precise Backdrop Approach

// High-speed approach, precise final positioning
follower.followPath(
    new BezierCurve(
        new Point(0, 0, Point.CARTESIAN),
        new Point(0, 0, Point.CARTESIAN),
        new Point(30, 15, Point.CARTESIAN),
        new Point(42, 42, Point.CARTESIAN),
        new Point(48, 54, Point.CARTESIAN)
    ).setLinearHeadingInterpolation(Math.toRadians(90))
        .addDeceleration(0.85, 1.0, 0.2)  // Very slow final approach
        .setPathEndCallback(() -> {
            // Score pixel when stopped
            scoreOnBackdrop();
        })
);

Example 2: Navigate Through Tight Space

// Slow down when passing between obstacles
follower.followPath(
    new BezierLine(new Point(48, 0, Point.CARTESIAN))
        .setConstantHeadingInterpolation(0)
        // Slow from 40-60% (tight gap in middle)
        .addDeceleration(0.4, 0.6, 0.3)
        // Full speed before and after
);

Example 3: Vision-Controlled Speed

// Slow when AprilTag is in view for better detection
Path toBackdrop = new BezierCurve(/* ... */)
    .setTangentHeadingInterpolation()
    .addCallback(0.6, () -> {
        if (aprilTagDetected()) {
            follower.setMaxVelocity(0.35);  // Slow for vision
        }
    })
    .addCallback(0.9, () -> {
        // Final precision approach
        follower.setMaxVelocity(0.15);
    });

Deceleration Tips

💡 Don't Over-Slow

Excessively slow speeds (below 0.15) can cause PID control issues and make the robot "creep" instead of moving smoothly. Use the slowest speed that still maintains good control.

💡 Test Zone Placement

Use FTC Dashboard to visualize where deceleration zones start/end. Adjust the t values until the robot slows exactly where you want it to.

💡 Balance Speed and Precision

Faster autonomous routines score more points, but only if they're accurate. Find the minimum deceleration needed for reliable operation, not the maximum.

💡 Consider Battery Levels

Deceleration that works at full battery may be too slow at low battery (reduced motor power). Test autonomous at various battery levels during practice.

Performance Considerations

Cycle Time Impact: Each deceleration zone adds time to your autonomous routine. A 2-second path with a 0.2x deceleration on the final 20% might become a 2.5-second path. Calculate total time including slow zones.

PID Tuning: Well-tuned PID allows higher speeds and less aggressive deceleration. If you need very slow approaches, check if better PID tuning could let you run faster instead.

Mechanism Coordination: Deceleration zones are great for coordinating with mechanism timings. If your intake needs 0.5 seconds to grab a pixel, plan a 0.5-second deceleration zone.