本文整理汇总了C++中Sensor::CheckSensors方法的典型用法代码示例。如果您正苦于以下问题:C++ Sensor::CheckSensors方法的具体用法?C++ Sensor::CheckSensors怎么用?C++ Sensor::CheckSensors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sensor
的用法示例。
在下文中一共展示了Sensor::CheckSensors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartTrackChecker
bool Tracker::StartTrackChecker(int nSampleFrequence /*= 100*/)
{
bool bRet = false;
MOJING_FUNC_TRACE(g_Sensorlogger);
if (AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, 1) >= 1)
{
MOJING_TRACE(g_Sensorlogger, "Start Tracker do not match! Start already. ");
}
else
{
Manager* pManager = Manager::GetMojingManager();
Sensor* pSensor = pManager->GetCheckSensor();
int nCheck = pSensor->CheckSensors();
if (nCheck & (SENSOR_GryoTooSlow | SENSOR_NoGryo))
{
MOJING_ERROR(g_Sensorlogger, "GryoTooSlow | SENSOR_NoGryo");
}
bRet = pSensor->StartSensor(nSampleFrequence);
}
return bRet;
}
示例2: CheckSensors
int Tracker::CheckSensors()const
{
Manager* pManager = Manager::GetMojingManager();
if (pManager)
{
Sensor* pSensor = pManager->GetSensor();
if (pSensor)
{
return pSensor->CheckSensors();
}
}
return -1;
}
示例3: StartTrack
bool Tracker::StartTrack(int nSampleFrequence/*, const char *pRecordPath*/, const char * lpszModel /* = NULL*/, const char* szGlassName)
{
MOJING_FUNC_TRACE(g_Sensorlogger);
MojingSDKStatus *pStatus = MojingSDKStatus::GetSDKStatus();
if (AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, 1) >= 1)
{
MOJING_TRACE(g_Sensorlogger, "Start Tracker do not match! Start already. ");
pStatus->SetTrackerStatus(TRACKER_START);
}
else
{
pStatus->SetTrackerStatus(TRACKER_START_NOW);
MOJING_TRACE(g_Sensorlogger, "Set sensor frequence as " << nSampleFrequence << " / " << GetMaxSensorsSampleRate() << "(Max)");
Manager* pManager = Manager::GetMojingManager();
pManager->SetSensor(szGlassName);
Sensor* pSensor = pManager->GetSensor();
int nCheck = pSensor->CheckSensors();
if (nCheck & (SENSOR_GryoTooSlow | SENSOR_NoGryo))
{
pStatus->SetTrackerStatus(TRACKER_STOP);
MOJING_ERROR(g_APIlogger, "GryoTooSlow or SENSOR_NoGryo , CheckSensors = " << nCheck);
AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, -1);
return false;
}
Parameters* pParameters = pManager->GetParameters();
m_pSensorfusion->Initialize(pSensor, pParameters, lpszModel);
if (GetDataFromExternal() && szGlassName == NULL)
{
#ifdef MJ_OS_ANDROID
pStatus->SetSensorOrigin(SENSOR_FROM_JAVA);
#endif
MOJING_TRACE(g_Sensorlogger, "Use sensor data from SDK_Java.");
m_bSensorfusionInit = true;
m_nSkipSamples = 10;
memset(&m_sensorFrame, 0, sizeof(MessageBodyFrame));
m_sensorFrame.LastSampleTime = m_sensorFrame.lastTempTime = NanoSecondToSecond(Timer::GetTicksNanos());
m_sensorFrame.Temperature = getTemperature();
if (m_sensorFrame.Temperature < 0) m_sensorFrame.Temperature = 2500; // 如果不能拿到温度值,则设置成25度
}
else
{
#ifdef MJ_OS_ANDROID
if (szGlassName)
{
pStatus->SetSensorOrigin(SENSOR_FROM_SERVICE);
MOJING_TRACE(g_Sensorlogger, "Use sensor data from Service. Name: " << szGlassName );
}
else
{
pStatus->SetSensorOrigin(SENSOR_FROM_NATIVE);
MOJING_TRACE(g_Sensorlogger, "Use sensor data from SDK_Native.");
}
#endif
if (!pSensor->StartSensor(nSampleFrequence/*, pRecordPath*/))
{
pStatus->SetTrackerStatus(TRACKER_STOP);
MOJING_ERROR(g_APIlogger, "pSensor->StartSensor failed");
AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, -1);
return false;
}
int iCount = 0;
MojingSDKStatus *pStatus = MojingSDKStatus::GetSDKStatus();
if (pStatus->GetEngineStatus() != ENGINE_UNREAL)
{ // 特殊处理:在进行等待第一个Sample的等待的时候,Unreal 4.11以及4.12
// 会陷入闪退。疑似等待时间过长导致。暂时屏蔽掉这里的代码,详细原因待查。
while (!m_pSensorfusion->m_bHasData && iCount++ < 1000)
{// 5ms
usleep(5000);
}
}
if (iCount > 1000)
{// 由于陀螺仪故障导致完全无法获取数据,这种情况下要通知调用方初始化失败
pSensor->StopSensor();
pStatus->SetTrackerStatus(TRACKER_STOP);
MOJING_ERROR(g_APIlogger, "Can not get any data in 5 Secs");
// Sensor data failed maybe temporary so recover RefCount
AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, -1);
return false;
}
else
{
pStatus->SetTrackerStatus(TRACKER_START);
}
SetYaw();
}
}
return true;
}