本文整理汇总了C++中SensorFusion::GetAcceleration方法的典型用法代码示例。如果您正苦于以下问题:C++ SensorFusion::GetAcceleration方法的具体用法?C++ SensorFusion::GetAcceleration怎么用?C++ SensorFusion::GetAcceleration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SensorFusion
的用法示例。
在下文中一共展示了SensorFusion::GetAcceleration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnIdle
void InputTestApp::OnIdle()
{
double curtime = pPlatform->GetAppTime();
time_t t = time(0); // get time now
struct tm * now = localtime(&t);
// float dt = float(LastUpdate - curtime);
LastUpdate = curtime;
if (pBox)
{
Vector3f acceldata = SFusion.GetAcceleration();
Vector3f gyrodata = SFusion.GetAngularVelocity();
Vector3f magdata = SFusion.GetMagnetometer();
Quatf q = SFusion.GetOrientation();
pBox->SetOrientation(q);
//fstream outFile;
//outFile.open("C://Users//Barrett//Documents//oculus_sensor_data.txt");
// Output the sensor data to the text file
ofstream outFile("C://Users//Barrett//Documents//oculus_sensor_data.csv", ios::app);
outFile << \
now->tm_sec << "," << \
curtime << "," << \
acceldata.x << "," << acceldata.y << "," << acceldata.z << "," << \
gyrodata.x << "," << gyrodata.y << "," << gyrodata.z << "," << \
magdata.x << "," << magdata.y << "," << magdata.z << "," << \
q.x << "," << q.y << "," << q.z << q.w << "\n";
// Test Euler conversion, alternative to the above:
// Vector3f euler;
// SFusion.GetOrientation().GetEulerABC<Axis_Y, Axis_X, Axis_Z, Rotate_CCW, Handed_R>(&euler.y, &euler.x, &euler.z);
// Matrix4f mat = Matrix4f::RotationY(euler.y) * Matrix4f::RotationX(euler.x) * Matrix4f::RotationZ(euler.z);
// pBox->SetMatrix(mat);
// Update titlebar every 20th of a second.
if ((curtime - LastTitleUpdate) > 0.05f)
{
char titleBuffer[512];
SensorDevice::CoordinateFrame coord = SensorDevice::Coord_Sensor;
if (pSensor)
coord = pSensor->GetCoordinateFrame();
OVR_sprintf(titleBuffer, 512, "OVR SensorBox %s %s Ang: %0.3f",
(SFusion.IsGravityEnabled() ? "" : "[Grav Off]"),
(coord == SensorDevice::Coord_HMD) ? "[HMD Coord]" : "",
CalcDownAngleDegrees(q));
pPlatform->SetWindowTitle(titleBuffer);
LastTitleUpdate = curtime;
}
}
if (pBox2)
{
pBox2->SetOrientation(SFusion2.GetOrientation());
}
// Render
int w, h;
pPlatform->GetWindowSize(&w, &h);
pRender->SetViewport(0, 0, w, h);
pRender->Clear();
pRender->BeginScene();
pRender->SetProjection(Proj);
pRender->SetDepthMode(1,1);
Sc.Render(pRender, View);
pRender->Present();
}
示例2: Output
void Output()
{
cout << "----- Oculus Console -----" << endl;
if (pHMD)
{
cout << " [x] HMD Found" << endl;
}
else
{
cout << " [ ] HMD Not Found" << endl;
}
if (pSensor)
{
cout << " [x] Sensor Found" << endl;
}
else
{
cout << " [ ] Sensor Not Found" << endl;
}
cout << "--------------------------" << endl;
if (InfoLoaded)
{
cout << " DisplayDeviceName: " << Info.DisplayDeviceName << endl;
cout << " ProductName: " << Info.ProductName << endl;
cout << " Manufacturer: " << Info.Manufacturer << endl;
cout << " Version: " << Info.Version << endl;
cout << " HResolution: " << Info.HResolution<< endl;
cout << " VResolution: " << Info.VResolution<< endl;
cout << " HScreenSize: " << Info.HScreenSize<< endl;
cout << " VScreenSize: " << Info.VScreenSize<< endl;
cout << " VScreenCenter: " << Info.VScreenCenter<< endl;
cout << " EyeToScreenDistance: " << Info.EyeToScreenDistance << endl;
cout << " LensSeparationDistance: " << Info.LensSeparationDistance << endl;
cout << " InterpupillaryDistance: " << Info.InterpupillaryDistance << endl;
cout << " DistortionK[0]: " << Info.DistortionK[0] << endl;
cout << " DistortionK[1]: " << Info.DistortionK[1] << endl;
cout << " DistortionK[2]: " << Info.DistortionK[2] << endl;
cout << "--------------------------" << endl;
}
cout << endl << " Press ENTER to continue" << endl;
cin.get();
while(pSensor)
{
Vector3f acc = FusionResult.GetAcceleration();
Quatf quaternion = FusionResult.GetOrientation();
float yaw, pitch, roll;
quaternion.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch, &roll);
cout << "Yaw=" << RadToDegree(yaw) <<
" Pitch=" << RadToDegree(pitch) <<
" Roll=" << RadToDegree(roll) <<
" X=" << acc.x / STD_GRAV <<
" Y=" << acc.y / STD_GRAV <<
" Z=" << acc.z / STD_GRAV << endl;
Sleep(50);
if (_kbhit()) exit(0);
}
}