Class ImuSetup
java.lang.Object
com.crossbotics.ftchelper.hardware.ImuSetup
Starts the IMU (the hub's built-in turn sensor) in one line, and reads the heading.
The "heading" is which way the robot is pointing, in degrees.
IMU imu = ImuSetup.get(hardwareMap, "imu",
RevHubOrientationOnRobot.LogoFacingDirection.UP,
RevHubOrientationOnRobot.UsbFacingDirection.FORWARD);
double heading = ImuSetup.headingDeg(imu); // counterclockwise is positive
You MUST give the directions the hub's logo and USB port face on YOUR robot. If they are wrong, the heading is wrong. See docs/modules/hardware.md for a picture. Why heading is counterclockwise-positive while turning is clockwise-positive: docs/conventions.md.
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.qualcomm.robotcore.hardware.IMUget(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logo, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usb) Gets the IMU, tells it how the hub is mounted, and sets the heading to 0.static doubleheadingDeg(com.qualcomm.robotcore.hardware.IMU imu) The robot's heading in degrees, from -180 to 180.
-
Method Details
-
get
public static com.qualcomm.robotcore.hardware.IMU get(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logo, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usb) Gets the IMU, tells it how the hub is mounted, and sets the heading to 0. Call it once in INIT: starting the IMU takes a short moment.- Parameters:
hardwareMap- the OpMode'shardwareMapname- the IMU's configuration name (usually "imu")logo- which way the REV logo on the hub facesusb- which way the hub's USB port faces- Returns:
- the IMU, ready to read
- Throws:
IllegalStateException- if the IMU does not start
-
headingDeg
public static double headingDeg(com.qualcomm.robotcore.hardware.IMU imu) The robot's heading in degrees, from -180 to 180. Turning left (counterclockwise) makes it bigger. It is 0 where the robot pointed at the lastresetYaw()."Yaw" is the sensor word for turning flat on the floor, like a spinning top.
- Parameters:
imu- the IMU fromget(com.qualcomm.robotcore.hardware.HardwareMap, java.lang.String, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection)- Returns:
- the heading in degrees, -180 to 180, counterclockwise = positive
-