LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
IMU.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6#pragma once
7
8#include "api.h"
11
12namespace okapi {
13enum class IMUAxes {
14 z,
15 y,
16 x
17};
18
20 public:
33 IMU(std::uint8_t iport, IMUAxes iaxis = IMUAxes::z);
34
40 double get() const override;
41
49 double getRemapped(double iupperBound = 1800, double ilowerBound = -1800) const;
50
56 double getAcceleration() const;
57
63 std::int32_t reset() override;
64
73 std::int32_t reset(double inewAngle);
74
81 std::int32_t calibrate();
82
89 double controllerGet() override;
90
94 bool isCalibrating() const;
95
96 protected:
97 std::uint8_t port;
99 double offset = 0;
100
107 double readAngle() const;
108};
109} // namespace okapi
PROS API header provides high-level user functionality.
std::uint8_t port
Definition IMU.hpp:97
std::int32_t reset() override
Reset the rotation value to zero.
std::int32_t reset(double inewAngle)
Resets rotation value to desired value For example, reset(0) will reset the sensor to zero.
double offset
Definition IMU.hpp:99
double controllerGet() override
Get the sensor value for use in a control loop.
IMU(std::uint8_t iport, IMUAxes iaxis=IMUAxes::z)
An inertial sensor on the given port.
bool isCalibrating() const
std::int32_t calibrate()
Calibrate the IMU.
double get() const override
Get the current rotation about the configured axis.
IMUAxes axis
Definition IMU.hpp:98
double getAcceleration() const
Get the current acceleration along the configured axis.
double readAngle() const
Get the current rotation about the configured axis.
double getRemapped(double iupperBound=1800, double ilowerBound=-1800) const
Get the current sensor value remapped into the target range ([-1800, 1800] by default).
IMUAxes
Definition IMU.hpp:13
@ y
Pitch Axis.
@ x
Roll Axis.
@ z
Yaw Axis.