Пример #1
0
Файл: dir.c Проект: bmiro/EmoFS
/** Canvi el la data de modificació de l'inode.
 * @path: camí del fitxer
 * @date: data epoch a posar
 * @return: 0 si èxit
 */
int emofs_update_time(const char *path, time_t date) {
	int inode = 0;
	int inode_dir = 0;
	int entry = 0;
	emofs_find_entry(path, &inode_dir, &inode, &entry);
	timestamp_file(inode, date);
	return 0;
}
Пример #2
0
/** Extracts imu out of a log file. */
void ExtractImu() {
  std::ofstream accel_file(FLAGS_out + "/accel.txt", std::ios_base::trunc);
  std::ofstream gyro_file(FLAGS_out + "/gyro.txt", std::ios_base::trunc);
  std::ofstream mag_file(FLAGS_out + "/mag.txt", std::ios_base::trunc);
  std::ofstream timestamp_file(FLAGS_out + "/timestamp.txt",
                               std::ios_base::trunc);

  static const int kNoRange = -1;

  int frame_min = kNoRange, frame_max = kNoRange;
  std::vector<int> frames;
  Split(TrimQuotes(FLAGS_extract_frame_range), ',', &frames);
  if (!frames.empty()) {
    CHECK_EQ(2, frames.size()) << "extract_frame_range must be frame PAIR";
    frame_min = frames[0];
    frame_max = frames[1];
    CHECK_LE(frame_min, frame_max)
        << "Minimum frame index must be <= than max frame index.";
  }

  hal::Reader reader(FLAGS_in);
  reader.Enable(hal::Msg_Type_IMU);

  int idx = 0;
  std::unique_ptr<hal::Msg> msg;
  while (frame_min != kNoRange && idx < frame_min) {
    if ((msg = reader.ReadMessage()) && msg->has_camera()) {
      ++idx;
    }
  }

  while ((frame_max == kNoRange ||
          idx <= frame_max) &&
         (msg = reader.ReadMessage())) {
    if (msg->has_imu()) {
      const hal::ImuMsg& imu_msg = msg->imu();
      if (imu_msg.has_accel()) {
        // Write the accel to the accel csv
        accel_file  << imu_msg.accel().data(0) << ", " <<
                       imu_msg.accel().data(1) << ", " <<
                       imu_msg.accel().data(2) << std::endl;
      } else {
        accel_file << "0, 0, 0" << std::endl;
      }

      if (imu_msg.has_gyro()) {
        // Write the accel to the accel csv
        gyro_file  << imu_msg.gyro().data(0) << ", " <<
                      imu_msg.gyro().data(1) << ", " <<
                      imu_msg.gyro().data(2) << std::endl;
      } else {
        gyro_file << "0, 0, 0" << std::endl;
      }

      if (imu_msg.has_mag()) {
        // Write the accel to the accel csv
        mag_file  << imu_msg.mag().data(0) << ", " <<
                     imu_msg.mag().data(1) << ", " <<
                     imu_msg.mag().data(2) << std::endl;
      } else {
        mag_file << "0, 0, 0" << std::endl;
      }

      timestamp_file << std::fixed << std::setprecision(9) << imu_msg.system_time() << ", "
                     << std::setprecision(9) << imu_msg.device_time()
                     << std::endl;
      // WRITE THE IMU
      ++idx;
    }
  }
}