• <rt id="2awkm"><noscript id="2awkm"></noscript></rt>
      <rt id="2awkm"><noscript id="2awkm"></noscript></rt>
    • <dfn id="2awkm"></dfn>
      <menu id="2awkm"><acronym id="2awkm"></acronym></menu>
      
      
      <rt id="2awkm"></rt><dfn id="2awkm"><code id="2awkm"></code></dfn>
    • <dd id="2awkm"><s id="2awkm"></s></dd>
      <tbody id="2awkm"></tbody>
    • <dfn id="2awkm"></dfn>
      <menu id="2awkm"><noscript id="2awkm"></noscript></menu>

      C++ IMU讀取示例代碼-IMU Reader

      # imu讀取示例-ImuReader

      功能描述:演示獲取imu數(shù)據(jù)

       

      >本示例基于C++ low Level API進(jìn)行演示,輸出imu數(shù)據(jù),并通過ESC_KEY鍵退出程序

       

      獲取設(shè)備

      // Create a Context.
      ob::Context ctx;

      // Query the list of connected devices
      auto devList = ctx.queryDeviceList();

      if(devList->deviceCount() == 0) {
          std::cerr << "Device not found!" << std::endl;
          return -1;
      }

      // Create a device, 0 represents the index of the first device
      auto dev = devList->getDevice(0);

       

      獲取陀螺儀數(shù)據(jù)

      // Get Gyroscope Sensor
      gyroSensor = dev->getSensorList()->getSensor(OB_SENSOR_GYRO);
      if(gyroSensor) {
          // Get configuration list
          auto profiles = gyroSensor->getStreamProfileList();
          // Select the first profile to open stream
          auto profile = profiles->getProfile(OB_PROFILE_DEFAULT);
          gyroSensor->start(profile, [](std::shared_ptr<ob::Frame> frame) {
              std::unique_lock<std::mutex> lk(printerMutex);
              auto                         timeStamp = frame->timeStamp();
              auto                         index     = frame->index();
              auto                         gyroFrame = frame->as<ob::GyroFrame>();
              if(gyroFrame != nullptr && (index % 50) == 2) {  //( timeStamp % 500 ) < 2: Reduce printing frequency
                  auto value = gyroFrame->value();
                  std::cout << "Gyro Frame: \n\r{\n\r"
                              << "  tsp = " << timeStamp << "\n\r"
                              << "  temperature = " << gyroFrame->temperature() << "\n\r"
                              << "  gyro.x = " << value.x << " rad/s"
                              << "\n\r"
                              << "  gyro.y = " << value.y << " rad/s"
                              << "\n\r"
                              << "  gyro.z = " << value.z << " rad/s"
                              << "\n\r"
                              << "}\n\r" << std::endl;
              }
          });
      }

       

      獲取加速度計(jì)

      accelSensor = dev->getSensorList()->getSensor(OB_SENSOR_ACCEL);
      if(accelSensor) {
          // Get configuration list
          auto profiles = accelSensor->getStreamProfileList();
          // Select the first profile to open stream
          auto profile = profiles->getProfile(OB_PROFILE_DEFAULT);
          accelSensor->start(profile, [](std::shared_ptr<ob::Frame> frame) {
              std::unique_lock<std::mutex> lk(printerMutex);
              auto                         timeStamp  = frame->timeStamp();
              auto                         index      = frame->index();
              auto                         accelFrame = frame->as<ob::AccelFrame>();
              if(accelFrame != nullptr && (index % 50) == 0) {
                  auto value = accelFrame->value();
                  std::cout << "Accel Frame: \n\r{\n\r"
                              << "  tsp = " << timeStamp << "\n\r"
                              << "  temperature = " << accelFrame->temperature() << "\n\r"
                              << "  accel.x = " << value.x << " m/s^2"
                              << "\n\r"
                              << "  accel.y = " << value.y << " m/s^2"
                              << "\n\r"
                              << "  accel.z = " << value.z << " m/s^2"
                              << "\n\r"
                              << "}\n\r" << std::endl;
              }
          });
      }

       

      // turn off the flow
      if(gyroSensor) {
          gyroSensor->stop();
      }
      if(accelSensor) {
          accelSensor->stop();

       

      預(yù)期輸出:

      image.png 


      • <rt id="2awkm"><noscript id="2awkm"></noscript></rt>
        <rt id="2awkm"><noscript id="2awkm"></noscript></rt>
      • <dfn id="2awkm"></dfn>
        <menu id="2awkm"><acronym id="2awkm"></acronym></menu>
        
        
        <rt id="2awkm"></rt><dfn id="2awkm"><code id="2awkm"></code></dfn>
      • <dd id="2awkm"><s id="2awkm"></s></dd>
        <tbody id="2awkm"></tbody>
      • <dfn id="2awkm"></dfn>
        <menu id="2awkm"><noscript id="2awkm"></noscript></menu>
        蜜臀AV国产精品又黃又粗又大 | 男女在线免费视频 | 亚洲黄色视频在线免费观看 | 久久偷偷做嫩草影院免费看 | 色tv国产 |