Field2d

class wpilib.Field2d(self: wpilib.Field2d) → None

Bases: wpilib.Sendable

2D representation of game field for dashboards.

An object’s pose is the location shown on the dashboard view. Note that for the robot, this may or may not match the internal odometry. For example, if the robot is shown at a particular starting location, the pose in this class would represent the actual location on the field, but the robot’s internal state might have a 0,0,0 pose (unless it’s initialized to something different).

As the user is able to edit the pose, code performing updates should get the robot pose, transform it as appropriate (e.g. based on wheel odometry), and set the new pose.

This class provides methods to set the robot pose, but other objects can also be shown by using the GetObject() function. Other objects can also have multiple poses (which will show the object at multiple locations).

getObject(self: wpilib.Field2d, name: str)wpilib.FieldObject2d

Get or create a field object.

Returns

Field object

getRobotObject(self: wpilib.Field2d)wpilib.FieldObject2d

Get the robot object.

Returns

Field object for robot

getRobotPose(self: wpilib.Field2d)wpimath.geometry.Pose2d

Get the robot pose.

Returns

2D pose

initSendable(self: wpilib.Field2d, builder: wpilib.SendableBuilder) → None
setRobotPose(*args, **kwargs)

Overloaded function.

  1. setRobotPose(self: wpilib._wpilib.Field2d, pose: wpimath.geometry._geometry.Pose2d) -> None

Set the robot pose from a Pose object.

Parameters

pose – 2D pose

  1. setRobotPose(self: wpilib._wpilib.Field2d, x: meters, y: meters, rotation: wpimath.geometry._geometry.Rotation2d) -> None

Set the robot pose from x, y, and rotation.

Parameters
  • x – X location

  • y – Y location

  • rotation – rotation