From bb8ea17acfd4fa5de9469ea0711d8196bcf4f853 Mon Sep 17 00:00:00 2001 From: Joe Ross Date: Sat, 6 Sep 2014 14:58:36 -0700 Subject: [PATCH] Open scope for gyro methods. Fixes FirstForge artf1699. Allows user to cause gyro calibration on demand. It also exposes the AnalogInput object as protected to allow the user to extend the gyro class and implement their own calibration. Change-Id: Ib4206a9b16ce6d5e8e5ca9c28a14471974705a7f --- wpilibc/wpilibC++Devices/include/Gyro.h | 7 ++++--- .../src/main/java/edu/wpi/first/wpilibj/Gyro.java | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wpilibc/wpilibC++Devices/include/Gyro.h b/wpilibc/wpilibC++Devices/include/Gyro.h index 3dd92a6f3c..e16225d0d8 100644 --- a/wpilibc/wpilibC++Devices/include/Gyro.h +++ b/wpilibc/wpilibC++Devices/include/Gyro.h @@ -40,6 +40,7 @@ public: void SetDeadband(float volts); void SetPIDSourceParameter(PIDSourceParameter pidSource); virtual void Reset(); + void InitGyro(); // PIDSource interface double PIDGet(); @@ -51,10 +52,10 @@ public: void InitTable(ITable *subTable); ITable * GetTable(); -private: - void InitGyro(); - +protected: AnalogInput *m_analog; + +private: float m_voltsPerDegreePerSecond; float m_offset; bool m_channelAllocated; diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Gyro.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Gyro.java index b8ccd81509..fc73d803b5 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Gyro.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Gyro.java @@ -29,7 +29,7 @@ public class Gyro extends SensorBase implements PIDSource, LiveWindowSendable { static final double kSamplesPerSecond = 50.0; static final double kCalibrationSampleTime = 5.0; static final double kDefaultVoltsPerDegreePerSecond = 0.007; - private AnalogInput m_analog; + protected AnalogInput m_analog; double m_voltsPerDegreePerSecond; double m_offset; int m_center; @@ -45,7 +45,7 @@ public class Gyro extends SensorBase implements PIDSource, LiveWindowSendable { * calculations are in progress, this is typically done when the robot is * first turned on while it's sitting at rest before the competition starts. */ - private void initGyro() { + public void initGyro() { result = new AccumulatorResult(); if (m_analog == null) { System.out.println("Null m_analog");