2014-07-21 08:57:03 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-09-14 15:22:54 -05:00
|
|
|
/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
|
2014-07-21 08:57:03 -04:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2014-07-21 08:57:03 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2016-01-02 03:02:34 -08:00
|
|
|
|
2014-07-21 08:57:03 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/ErrorBase.h"
|
|
|
|
|
#include "frc/interfaces/Accelerometer.h"
|
2019-09-14 15:22:54 -05:00
|
|
|
#include "frc/smartdashboard/Sendable.h"
|
|
|
|
|
#include "frc/smartdashboard/SendableHelper.h"
|
2014-07-21 08:57:03 -04:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
class SendableBuilder;
|
|
|
|
|
|
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
|
|
|
*/
|
2018-05-23 20:22:30 -07:00
|
|
|
class BuiltInAccelerometer : public ErrorBase,
|
2019-09-14 15:22:54 -05:00
|
|
|
public Accelerometer,
|
|
|
|
|
public Sendable,
|
|
|
|
|
public 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.
|
|
|
|
|
*/
|
2016-07-10 17:47:44 -07:00
|
|
|
void SetRange(Range range) override;
|
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
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
void InitSendable(SendableBuilder& builder) override;
|
2014-07-21 08:57:03 -04:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|