2015-11-06 12:05:40 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-08-23 22:06:13 -07:00
|
|
|
/* Copyright (c) 2008-2017 FIRST. All Rights Reserved. */
|
2015-11-06 12:05:40 -08: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. */
|
2015-11-06 12:05:40 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "GyroBase.h"
|
2016-09-25 16:50:13 -07:00
|
|
|
|
2015-11-06 12:05:40 -08:00
|
|
|
#include "LiveWindow/LiveWindow.h"
|
2016-05-20 17:30:37 -07:00
|
|
|
#include "WPIErrors.h"
|
2015-11-06 12:05:40 -08:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2015-11-06 12:05:40 -08:00
|
|
|
/**
|
|
|
|
|
* Get the PIDOutput for the PIDSource base object. Can be set to return
|
|
|
|
|
* angle or rate using SetPIDSourceType(). Defaults to angle.
|
|
|
|
|
*
|
|
|
|
|
* @return The PIDOutput (angle or rate, defaults to angle)
|
|
|
|
|
*/
|
|
|
|
|
double GyroBase::PIDGet() {
|
|
|
|
|
switch (GetPIDSourceType()) {
|
|
|
|
|
case PIDSourceType::kRate:
|
|
|
|
|
return GetRate();
|
|
|
|
|
case PIDSourceType::kDisplacement:
|
|
|
|
|
return GetAngle();
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GyroBase::UpdateTable() {
|
2017-09-02 00:17:43 -07:00
|
|
|
if (m_valueEntry) m_valueEntry.SetDouble(GetAngle());
|
2015-11-06 12:05:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GyroBase::StartLiveWindowMode() {}
|
|
|
|
|
|
|
|
|
|
void GyroBase::StopLiveWindowMode() {}
|
|
|
|
|
|
|
|
|
|
std::string GyroBase::GetSmartDashboardType() const { return "Gyro"; }
|
|
|
|
|
|
2017-09-02 00:17:43 -07:00
|
|
|
void GyroBase::InitTable(std::shared_ptr<nt::NetworkTable> subTable) {
|
2017-09-02 00:35:30 -07:00
|
|
|
if (subTable) {
|
|
|
|
|
m_valueEntry = subTable->GetEntry("Value");
|
2017-09-02 00:17:43 -07:00
|
|
|
UpdateTable();
|
|
|
|
|
} else {
|
|
|
|
|
m_valueEntry = nt::NetworkTableEntry();
|
|
|
|
|
}
|
2015-11-06 12:05:40 -08:00
|
|
|
}
|