1#![warn(
2 rust_2018_idioms,
3 elided_lifetimes_in_paths,
4 clippy::all,
5 clippy::nursery
6)]
7
8mod camera;
9mod common;
10mod ground_truth;
11mod imu;
12mod position;
13
14use std::path::{Path, PathBuf};
15
16use anyhow::{ensure, Result};
17
18pub use self::{camera::*, common::*, ground_truth::*, imu::*, position::*};
19
20#[derive(Debug)]
21pub struct EuRoC {
22 root: PathBuf,
23}
24
25impl EuRoC {
26 pub fn new<P: AsRef<Path>>(root: P) -> Result<Self> {
27 ensure!(root.as_ref().is_dir());
28
29 Ok(Self {
30 root: root.as_ref().to_owned(),
31 })
32 }
33
34 pub fn left_camera(&self) -> Result<CameraRecords> {
35 CameraRecords::new(self.root.join("cam0"))
36 }
37
38 pub fn right_camera(&self) -> Result<CameraRecords> {
39 CameraRecords::new(self.root.join("cam1"))
40 }
41
42 pub fn imu(&self) -> Result<ImuData> {
43 ImuData::new(self.root.join("imu0"))
44 }
45
46 pub fn position(&self) -> Result<PositionData> {
47 PositionData::new(self.root.join("leica0"))
48 }
49
50 pub fn ground_truth(&self) -> Result<GroundTruthData> {
51 GroundTruthData::new(self.root.join("state_groundtruth_estimate0"))
52 }
53}
54
55#[cfg(test)]
56mod test {
57 use super::*;
58
59 #[test]
60 fn right_camera() -> Result<()> {
61 let _ = EuRoC::new("test_data")?.right_camera()?;
62
63 Ok(())
64 }
65}