1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use nalgebra::{Isometry2, Vector2};

use crate::{error::Error, traits::Localization};

/// Dummy Localization for debug or tests.
#[derive(Debug)]
pub struct DummyLocalization {
    pub current_pose: Isometry2<f64>,
}

impl DummyLocalization {
    /// Creates a new `DummyLocalization`.
    pub fn new() -> Self {
        Self {
            current_pose: Isometry2::new(Vector2::new(0.0, 0.0), 0.0),
        }
    }
}

impl Default for DummyLocalization {
    fn default() -> Self {
        Self::new()
    }
}

impl Localization for DummyLocalization {
    fn current_pose(&self, _frame_id: &str) -> Result<Isometry2<f64>, Error> {
        Ok(self.current_pose)
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_get() {
        let loc = DummyLocalization::new();
        let current_pose = loc.current_pose("").unwrap();
        assert_eq!(current_pose, current_pose.inverse()); // only identity mapping satisfies this
    }
}