Class CameraTilt

java.lang.Object
com.crossbotics.ftchelper.vision.CameraTilt

public final class CameraTilt extends Object
Turns what a TILTED camera measures into what a LEVEL one would: the bearing along the floor and the distance along the floor.

Why: a camera reports a target's direction in its OWN view. When the camera is tilted up (to see a high goal), "to the side" in the picture is not "to the side" on the floor: a goal 27 degrees to the left reads only about 21 degrees with a camera tilted 35 degrees up, and its distance is the slanted line from the camera up to the goal. The aim and the shot tables want the floor's numbers.

How: the camera's numbers (right, forward along the lens, up in the picture) are turned down by the tilt, so "forward" lies flat on the floor again. Then bearing = the angle sideways, distance = the length sideways and forward (the height left out). With a tilt of 0 nothing changes.

The tilt: pitchDeg in the camera's Tunables section (degrees, + = tilted UP, as in the simulator's robot file). Measure it on the robot: docs/reference/parts/camera.md.

 double b = CameraTilt.bearingDeg(right, forward, up, 35);   // + = LEFT, along the floor
 
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    bearingDeg(double right, double forward, double up, double pitchDeg)
    The target's direction along the floor.
    static double
    floorDistance(double right, double forward, double up, double pitchDeg)
    The target's distance from the camera along the floor (the height difference left out).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • bearingDeg

      public static double bearingDeg(double right, double forward, double up, double pitchDeg)
      The target's direction along the floor.
      Parameters:
      right - the target's place to the right of the lens, in the camera's own view (any length unit)
      forward - the target's place along the lens's line of sight (same unit)
      up - the target's place up in the picture, square to the line of sight (same unit)
      pitchDeg - how far the camera is tilted up, degrees (0 = level; + = up, - = down)
      Returns:
      degrees, + = to the LEFT (the library's sign, docs/conventions.md); NaN if a number is NaN
    • floorDistance

      public static double floorDistance(double right, double forward, double up, double pitchDeg)
      The target's distance from the camera along the floor (the height difference left out).
      Parameters:
      right - as in bearingDeg(double, double, double, double)
      forward - as in bearingDeg(double, double, double, double)
      up - as in bearingDeg(double, double, double, double)
      pitchDeg - as in bearingDeg(double, double, double, double)
      Returns:
      in the same length unit as the inputs; NaN if a number is NaN