89 for (
UByte i = 0; i < iterationCount; i++)
128 float ax = (float)sample.
AccelX;
129 float ay = (
float)sample.
AccelY;
130 float az = (float)sample.
AccelZ;
132 return Vector3f(ax, ay, az) * 0.0001f;
144 float gx = (float)sample.
GyroX;
145 float gy = (
float)sample.
GyroY;
146 float gz = (float)sample.
GyroZ;
148 return Vector3f(gx, gy, gz) * 0.0001f;
181 LastRunningSampleCount(0),
182 FullCameraFrameCount(0),
186 LastFrameTimestamp(0)
462 for (
int i = 0; i < positions; i++)
757 for (
int i = 0; i < bins; i++)
758 (*data)[i].Resize(samples);
760 for (
int i = 0; i < bins; i++)
761 for (
int j = 0; j < samples; j++)
809 const float sampleIntervalTimeUnit = (1.0f / 1000.f);
810 double scaledSampleIntervalTimeUnit = sampleIntervalTimeUnit;
813 double absoluteTimeSeconds = 0.0;
817 UInt32 runningSampleCountDelta;
835 if ((runningSampleCountDelta >
LastNumSamples) && (runningSampleCountDelta <= 254))
877 sensors.
TimeDelta = (float) scaledSampleIntervalTimeUnit;
880 for (
UByte i = 0; i < iterations; i++)
882 sensors.
AbsoluteTimeSeconds = absoluteTimeSeconds - ( iterations - 1 - i ) * scaledSampleIntervalTimeUnit;
892 sensors.
TimeDelta = (float) scaledSampleIntervalTimeUnit;
958 int updateIndices[4];
963 OVR_ASSERT(count <=
sizeof(updateIndices)/
sizeof(
int));
966 for (i = 0; i < count; i++)
970 if (rawValues[i] != lowMks)
975 if (rawValues[i] < lowMks)
977 LogText(
"Timestamp %d rollover, was: %u, now: %u\n", i, lowMks, rawValues[i]);
987 (timestamps[0]->
TimestampMks & 0xFFFFFFFF00000000) | rawValues[i];
989 if (timestamps[i]->TimestampMks > timestamps[0]->TimestampMks + 0x1000000)
991 else if (timestamps[i]->TimestampMks + 0x100000000 < timestamps[0]->TimestampMks + 0x1000000)
995 updateIndices[updateCount] = i;
1005 static const double mksToSec = 1.0 / 1000000.0;
1007 for (
int i = 0; i < updateCount; i++)
1019 bool processed =
false;
1066 static unsigned SLastSampleTime = 0;
1069 fprintf(SF_LOG_fp,
"*** Sample Timestamp Wrap! ***\n");
1074 static unsigned SLastCameraTime = 0;
1077 fprintf(SF_LOG_fp,
"*** Camera Timestamp Wrap! ***\n");
1082 static unsigned SLastFrameTime = 0;
1085 fprintf(SF_LOG_fp,
"*** Frame Timestamp Wrap! ***\n");
1110 double keepAliveDelta = 3.0;
bool setManufacturingReport(const ManufacturingReport &data)
Matrix4f GyroCalibrationMatrix
bool setMagCalibrationReport(const MagCalibrationReport &data)
SensorCalibration * pCalibration
Vector3f AccelCalibrationOffset
UInt16 RunningSampleCount
SensorTimestampMapping LastFrameTime
ManufacturingReport Settings
void Apply(MessageBodyFrame &msg)
void LogText(const char *fmt,...) OVR_LOG_VAARG_ATTRIBUTE(1
PositionTypeEnum PositionType
virtual bool SetUUIDReport(const UUIDReport &data)
UInt32 FullCameraFrameCount
Vector3f MagFromBodyFrameUpdate(const Tracker2Sensors &update)
KeepAliveMuxReport Settings
virtual bool SetManufacturingReport(const ManufacturingReport &data)
double ScaleTimeUnit(double deviceClockDelta)
bool getLensDistortionReport(LensDistortionReport *data)
bool getKeepAliveMuxReport(KeepAliveMuxReport *data)
virtual bool GetLensDistortionReport(LensDistortionReport *data)
CustomPatternReport Settings
SensorTimeFilter TimeFilter
virtual bool GetGyroOffsetReport(GyroOffsetReport *data)
bool setTrackingReport(const TrackingReport &data)
virtual bool SetMagCalibrationReport(const MagCalibrationReport &data)
UInt32 LastFrameTimestamp
UInt32 DecodeUInt32(const UByte *buffer)
virtual bool GetAllPositionCalibrationReports(Array< PositionCalibrationReport > *data)
Matrix4f AccelCalibrationMatrix
virtual bool SetTrackingReport(const TrackingReport &data)
bool getTemperatureReport(TemperatureReport *data)
UInt16 LastRunningSampleCount
UInt16 DecodeUInt16(const UByte *buffer)
virtual bool SetCustomPatternReport(const CustomPatternReport &data)
float CalibrationTemperature
Tracker2MessageType Decode(const UByte *buffer, int size)
Void setReportRate(unsigned rateHz)
virtual double OnTicks(double tickSeconds)
virtual bool SetLensDistortionReport(const LensDistortionReport &data)
Vector3f AccelFromBodyFrameUpdate(const Tracker2Sensors &update, UByte sampleNumber)
double SampleToSystemTime(double sampleDeviceTime, double systemTime, double prevResult, const char *debugTag="")
bool getGyroOffsetReport(GyroOffsetReport *data)
TemperatureReport Settings
bool getDisplayReport(DisplayReport *data)
bool getCustomPatternReport(CustomPatternReport *data)
void GetSensorRange(SensorRange *r)
bool setTemperatureReport(const TemperatureReport &data)
bool setCustomPatternReport(const CustomPatternReport &data)
MagCalibrationReport Settings
Vector3f GyroCalibrationOffset
Sensor2DeviceImpl(SensorDeviceCreateDesc *createDesc)
Vector3f LastRotationRate
LensDistortionReport Settings
bool getMagCalibrationReport(MagCalibrationReport *data)
virtual bool GetCustomPatternReport(CustomPatternReport *data)
PositionCalibrationReport Settings
bool setPositionCalibrationReport(const PositionCalibrationReport &data)
void Resize(UPInt newSize)
SensorTimestampMapping LastCameraTime
SensorTimestampMapping LastSensorTime
virtual bool SetPositionCalibrationReport(const PositionCalibrationReport &data)
void UpdateDK2Timestamps(SensorTimeFilter &tf, SensorTimestampMapping **timestamps, UInt32 *rawValues, int count)
virtual bool GetTrackingReport(TrackingReport *data)
virtual bool SetKeepAliveMuxReport(const KeepAliveMuxReport &data)
bool setKeepAliveMuxReport(const KeepAliveMuxReport &data)
virtual void OnInputReport(UByte *pData, UInt32 length)
MessageHandlerRef HandlerRef
bool getUUIDReport(UUIDReport *data)
bool getPositionCalibrationReport(PositionCalibrationReport *data)
bool GetFeatureReport(UByte *data, UInt32 length)
virtual bool GetUUIDReport(UUIDReport *data)
DeviceManagerImpl * GetManagerImpl() const
bool getAllPositionCalibrationReports(Array< PositionCalibrationReport > *data)
PositionCalibrationReport Settings
virtual bool GetDisplayReport(DisplayReport *data)
virtual bool GetKeepAliveMuxReport(KeepAliveMuxReport *data)
UByte GetDeviceInterfaceVersion()
Vector3f EulerFromBodyFrameUpdate(const Tracker2Sensors &update, UByte sampleNumber)
bool getAllTemperatureReports(Array< Array< TemperatureReport > > *)
bool setLensDistortionReport(const LensDistortionReport &data)
CoordinateFrame Coordinates
double NextKeepAliveTickSeconds
HIDDevice * GetInternalDevice() const
bool decodeTracker2Message(Tracker2Message *message, UByte *buffer, int size)
__BEGIN_NAMESPACE_STD void void __END_NAMESPACE_STD void __BEGIN_NAMESPACE_STD void * memset(void *__s, int __c, size_t __n) __THROW __nonnull((1))
void UnpackSensor(const UByte *buffer, SInt32 *x, SInt32 *y, SInt32 *z)
virtual bool SetTemperatureReport(const TemperatureReport &data)
bool setUUIDReport(const UUIDReport &data)
static double OVR_STDCALL GetSeconds()
Vector3f LastMagneticField
virtual bool GetMagCalibrationReport(MagCalibrationReport *data)
virtual void openDevice()
void onTrackerMessage(Tracker2Message *message)
Void setCoordinateFrame(CoordinateFrame coordframe)
virtual bool SetFeatureReport(UByte *data, UInt32 length)=0
Void setOnboardCalibrationEnabled(bool enabled)
virtual bool GetAllTemperatureReports(Array< Array< TemperatureReport > > *)
double AbsoluteTimeSeconds
void Call(const Message &msg)
SInt16 DecodeSInt16(const UByte *buffer)
GyroOffsetReport Settings
bool getTrackingReport(TrackingReport *data)
Vector3< float > Vector3f
virtual bool SetDisplayReport(const DisplayReport &data)
ThreadId GetCurrentThreadId()
bool getManufacturingReport(ManufacturingReport *data)
bool setDisplayReport(const DisplayReport &data)
Vector3f LastAcceleration
virtual bool GetManufacturingReport(ManufacturingReport *data)