<blockquote id="76sxc"></blockquote>
<cite id="76sxc"><track id="76sxc"></track></cite>
<legend id="76sxc"></legend>

  • <blockquote id="76sxc"><p id="76sxc"></p></blockquote>
    <sub id="76sxc"><p id="76sxc"></p></sub>

          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 


          <blockquote id="76sxc"></blockquote>
          <cite id="76sxc"><track id="76sxc"></track></cite>
          <legend id="76sxc"></legend>

        1. <blockquote id="76sxc"><p id="76sxc"></p></blockquote>
          <sub id="76sxc"><p id="76sxc"></p></sub>

                A级免费电影 | 久久99精品一区二区三区 | 黄色动漫在线免费观看 | 九九黄色网 | 亚洲狼人综合干视频 | 色在线播放 | 免费在线一区二区 | 美国大鸡巴与亚洲女黄色毛片 | 国产色情在线观看 | 久久久久久999 |