2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2016-01-02 03:02:34 -08:00
|
|
|
|
2014-07-21 08:57:03 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
2021-06-13 16:38:05 -07:00
|
|
|
#include <wpi/sendable/Sendable.h>
|
|
|
|
|
#include <wpi/sendable/SendableHelper.h>
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/interfaces/Accelerometer.h"
|
2014-07-21 08:57:03 -04:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2014-07-21 08:57:03 -04:00
|
|
|
/**
|
|
|
|
|
* Built-in accelerometer.
|
|
|
|
|
*
|
2016-05-29 09:19:43 -07:00
|
|
|
* This class allows access to the roboRIO's internal accelerometer.
|
2014-07-21 08:57:03 -04:00
|
|
|
*/
|
2021-04-18 20:35:29 -07:00
|
|
|
class BuiltInAccelerometer : public Accelerometer,
|
2021-06-13 16:38:05 -07:00
|
|
|
public wpi::Sendable,
|
|
|
|
|
public wpi::SendableHelper<BuiltInAccelerometer> {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Constructor.
|
|
|
|
|
*
|
|
|
|
|
* @param range The range the accelerometer will measure
|
|
|
|
|
*/
|
2016-07-10 17:47:44 -07:00
|
|
|
explicit BuiltInAccelerometer(Range range = kRange_8G);
|
2014-07-22 18:04:00 -04:00
|
|
|
|
2018-09-24 00:08:25 -07:00
|
|
|
BuiltInAccelerometer(BuiltInAccelerometer&&) = default;
|
|
|
|
|
BuiltInAccelerometer& operator=(BuiltInAccelerometer&&) = default;
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
// Accelerometer interface
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Set the measuring range of the accelerometer.
|
|
|
|
|
*
|
|
|
|
|
* @param range The maximum acceleration, positive or negative, that the
|
|
|
|
|
* accelerometer will measure. Not all accelerometers support all
|
|
|
|
|
* ranges.
|
|
|
|
|
*/
|
2021-01-01 10:27:49 -08:00
|
|
|
void SetRange(Range range) final;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The acceleration of the roboRIO along the X axis in g-forces
|
|
|
|
|
*/
|
2016-07-10 17:47:44 -07:00
|
|
|
double GetX() override;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The acceleration of the roboRIO along the Y axis in g-forces
|
|
|
|
|
*/
|
2016-07-10 17:47:44 -07:00
|
|
|
double GetY() override;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The acceleration of the roboRIO along the Z axis in g-forces
|
|
|
|
|
*/
|
2016-07-10 17:47:44 -07:00
|
|
|
double GetZ() override;
|
2014-07-21 10:07:46 -04:00
|
|
|
|
2021-06-13 16:38:05 -07:00
|
|
|
void InitSendable(wpi::SendableBuilder& builder) override;
|
2014-07-21 08:57:03 -04:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|