Class Shape

java.lang.Object
com.crossbotics.ftchelper.robot.Shape

public final class Shape extends Object
How a part looks and where it sits, for the simulator's 3D view and its size checks: written in Robot.java next to the part, so the simulator robot file comes from the code (./gradlew :sim:fromRobot).

 intakeDeploy = add(Positioner.servo("intake_deploy").part("gobilda-2000-speed")
         .looks(Shape.arm().atMm(140, 0, 110).sizeMm(120, 300, 20)
                 .angle("stowed", 95).angle("deployed", -10)));
 intake = add(Intake.motor("intake").part("gobilda-5203-117").holds(4)
         .looks(Shape.roller("offset-tubing-90", "offset-tubing-60").on(intakeDeploy).atMm(120, 0, 0).lengthMm(240)));
 

Name the part, give only what is not known. A roller or flywheel named by its parts catalog id (Parts) takes its diameter (and width, when the seller gives it) from the catalog. Places are always the robot's own: atMm(forward, left, up) from the parent (the middle of the chassis on the floor, or the hinge of the arm it rides on).

The part that owns the shape moves it: an intake spins its rollers, a positioner swings its arm, an arm motor swings its arm, a turret turns its turret, a hood servo or motor swings its arm. A box(java.lang.String) does not move (fixed(...) in Robot.java, or any part's looks). Docs: docs/reference/robot-java.md (section "Shapes"); the shape types: docs/reference/robot-file.md#robot-shapes

  • Method Summary

    Modifier and Type
    Method
    Description
    angle(String position, double degrees)
    An arm on a servo: its angle at a named position (from Tunables.java).
    static Shape
    arm()
    A part that swings about a hinge (an intake that folds, an arm).
    atIn(double forward, double left, double up)
    atMm(double forward, double left, double up)
    Where it is, in mm from its parent: forward, left, up (the parent: the chassis, or on(com.crossbotics.ftchelper.robot.Module<?>)).
    axis(String axis)
    The line it turns about: "up", "down", "forward", "back", "left" or "right".
    static Shape
    box(String name)
    A part that does not move (a ramp, a tower, a hood).
    static Shape
    Two fingers that a servo opens and closes (a Claw's).
    color(String color)
    Its color in the 3D view, e.g.
    diameterMm(double mm)
    A roller's or flywheel's diameter, mm, for a part not in the catalog.
    dropsWhen(ServoPositions<?> servoPart, String position, double toDegrees)
    A passive arm that a servo pushes over (an intake folded up at the start): when that servo reaches the named position (three quarters of the way there), it falls to toDegrees (its hard stop) and stays, as gravity holds it there on the robot.
    static Shape
    A launcher wheel not in the parts catalog: give diameterMm(double) and lengthMm(double).
    static Shape
    flywheel(String partId)
    A launcher wheel, e.g.
    lengthMm(double mm)
    A roller's length along its axle, mm (needed when the catalog does not give the part's width).
    name(String name)
    Its name in the robot file (default: the part's configuration name, then name_2, name_3...).
    note(String note)
    Where a number came from, written after the line ("est.
    on(Module<?> part)
    Rides on another part's (first) shape: it moves with it, and atMm is from that shape's hinge or middle.
    on(String shapeName)
    Rides on a shape by its name in the robot file (a box(java.lang.String), or a part's second shape).
    Moved by gravity or springs, not by the code (a floating intake, a sprung flywheel mount).
    range(double minDegrees, double maxDegrees)
    A passive arm's hard stops, in degrees (0 = level forward, +90 = straight up).
    A roller that turns the other way from its motor, through gears (for example the left one of two spinners geared to one intake shaft, so both pull pieces in).
    static Shape
    roller(String... partIds)
    A roller (a cylinder; by default its axle runs across the robot, left-right).
    sizeIn(double forward, double left, double up)
    sizeMm(double forward, double left, double up)
    Its box in mm: forward x left-right x up (an arm: length x width x thickness at 0 degrees).
    static Shape
    A part that moves in a straight line along its axis (default up): sizeMm is one stage, atMm the bottom of the fixed stage.
    A soft roller (surgical tubing, flaps): it bends against the field, so in the simulator only game pieces touch it; the field does not stop it.
    startAt(double degrees)
    Where a passive arm is at the start of a match, degrees.
    tiltDeg(double degrees)
    Mounted turned about its parent's left-right line, in degrees (front up +).
    travelMm(double mm)
    How far a slide can move, mm: a passive slide's travel from where it rests, or a Lift's stage from its min to its max (Tunables), so the simulator knows the counts per inch.
    static Shape
    A part that turns about the up line (a turret): atMm is the middle of its bottom, on the line it turns about; sizeMm its box.

    Methods inherited from class java.lang.Object

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

    • roller

      public static Shape roller(String... partIds)
      A roller (a cylinder; by default its axle runs across the robot, left-right). Several parts (for example 90 mm and 60 mm rollers taking turns on one shaft) are drawn as one cylinder as big as the biggest. Its length: lengthMm(double), or the part's width if the catalog has it.
      Parameters:
      partIds - parts catalog ids, e.g. "offset-tubing-90"; none = give diameterMm(double)
    • flywheel

      public static Shape flywheel(String partId)
      A launcher wheel, e.g. Shape.flywheel("gobilda-hogback-96").
    • flywheel

      public static Shape flywheel()
      A launcher wheel not in the parts catalog: give diameterMm(double) and lengthMm(double).
    • arm

      public static Shape arm()
      A part that swings about a hinge (an intake that folds, an arm). atMm is the hinge; sizeMm(length, width, thickness) is the box that reaches forward from it at 0 degrees. On a Positioner, Wrist or Claw servo, give its angle at two named positions with angle(java.lang.String, double). An Arm motor and a Hood know their angles (Tunables.java) and need none.
    • slide

      public static Shape slide()
      A part that moves in a straight line along its axis (default up): sizeMm is one stage, atMm the bottom of the fixed stage. Parts on it ride its moving stage. Here it is for a passive slide (springs or gravity), with travelMm(double).
    • turret

      public static Shape turret()
      A part that turns about the up line (a turret): atMm is the middle of its bottom, on the line it turns about; sizeMm its box. A Turret turns it; parts can ride on it with on(turret).
    • claw

      public static Shape claw()
      Two fingers that a servo opens and closes (a Claw's). atMm is the middle of its palm; sizeMm its box. The simulator lets it hold a game piece while it is closed.
    • box

      public static Shape box(String name)
      A part that does not move (a ramp, a tower, a hood). atMm is the middle of its bottom.
      Parameters:
      name - its name in the robot file, e.g. "ramp"
    • name

      public Shape name(String name)
      Its name in the robot file (default: the part's configuration name, then name_2, name_3...).
    • atMm

      public Shape atMm(double forward, double left, double up)
      Where it is, in mm from its parent: forward, left, up (the parent: the chassis, or on(com.crossbotics.ftchelper.robot.Module<?>)).
    • atIn

      public Shape atIn(double forward, double left, double up)
    • sizeMm

      public Shape sizeMm(double forward, double left, double up)
      Its box in mm: forward x left-right x up (an arm: length x width x thickness at 0 degrees).
    • sizeIn

      public Shape sizeIn(double forward, double left, double up)
    • lengthMm

      public Shape lengthMm(double mm)
      A roller's length along its axle, mm (needed when the catalog does not give the part's width).
    • diameterMm

      public Shape diameterMm(double mm)
      A roller's or flywheel's diameter, mm, for a part not in the catalog.
    • axis

      public Shape axis(String axis)
      The line it turns about: "up", "down", "forward", "back", "left" or "right". A roller's axle (default left-right; "up" for a wheel lying flat), an arm's hinge (default "left").
    • on

      public Shape on(Module<?> part)
      Rides on another part's (first) shape: it moves with it, and atMm is from that shape's hinge or middle.
    • on

      public Shape on(String shapeName)
      Rides on a shape by its name in the robot file (a box(java.lang.String), or a part's second shape).
    • angle

      public Shape angle(String position, double degrees)
      An arm on a servo: its angle at a named position (from Tunables.java). Give two; the simulator draws every position between them. 0 = level forward, +90 = straight up.
      Parameters:
      position - e.g. "stowed"
      degrees - e.g. 95
    • passive

      public Shape passive()
      Moved by gravity or springs, not by the code (a floating intake, a sprung flywheel mount). The simulator draws it at startAt and checks the size rules over its whole range: give range(double, double) (arm) or travelMm(double) (slide), the hard stops a real robot needs too.
    • range

      public Shape range(double minDegrees, double maxDegrees)
      A passive arm's hard stops, in degrees (0 = level forward, +90 = straight up).
    • startAt

      public Shape startAt(double degrees)
      Where a passive arm is at the start of a match, degrees. Default: the bottom of its range.
    • travelMm

      public Shape travelMm(double mm)
      How far a slide can move, mm: a passive slide's travel from where it rests, or a Lift's stage from its min to its max (Tunables), so the simulator knows the counts per inch.
    • dropsWhen

      public Shape dropsWhen(ServoPositions<?> servoPart, String position, double toDegrees)
      A passive arm that a servo pushes over (an intake folded up at the start): when that servo reaches the named position (three quarters of the way there), it falls to toDegrees (its hard stop) and stays, as gravity holds it there on the robot.
      Parameters:
      servoPart - the part whose servo pushes it, e.g. intakeDeploy
      position - its position that pushes it over, e.g. "deployed"
      toDegrees - where it falls to, e.g. -10
    • tiltDeg

      public Shape tiltDeg(double degrees)
      Mounted turned about its parent's left-right line, in degrees (front up +). For a part fixed at an angle on what it rides on: a spinner kept level on an intake arm that is down at -40 degrees has a tilt of 40.
      Parameters:
      degrees - e.g. 40
    • soft

      public Shape soft()
      A soft roller (surgical tubing, flaps): it bends against the field, so in the simulator only game pieces touch it; the field does not stop it. It still counts for the size rules.
    • reversed

      public Shape reversed()
      A roller that turns the other way from its motor, through gears (for example the left one of two spinners geared to one intake shaft, so both pull pieces in).
    • note

      public Shape note(String note)
      Where a number came from, written after the line ("est. from the CAD", "measured 2026-10-20").
    • color

      public Shape color(String color)
      Its color in the 3D view, e.g. "#2fa84f".