arci/clients/
dummy_localization.rs

1use nalgebra::{Isometry2, Vector2};
2
3use crate::{error::Error, traits::Localization};
4
5/// Dummy Localization for debug or tests.
6#[derive(Debug)]
7pub struct DummyLocalization {
8    pub current_pose: Isometry2<f64>,
9}
10
11impl DummyLocalization {
12    /// Creates a new `DummyLocalization`.
13    pub fn new() -> Self {
14        Self {
15            current_pose: Isometry2::new(Vector2::new(0.0, 0.0), 0.0),
16        }
17    }
18}
19
20impl Default for DummyLocalization {
21    fn default() -> Self {
22        Self::new()
23    }
24}
25
26impl Localization for DummyLocalization {
27    fn current_pose(&self, _frame_id: &str) -> Result<Isometry2<f64>, Error> {
28        Ok(self.current_pose)
29    }
30}
31
32#[cfg(test)]
33mod tests {
34    use super::*;
35    #[test]
36    fn test_get() {
37        let loc = DummyLocalization::new();
38        let current_pose = loc.current_pose("").unwrap();
39        assert_eq!(current_pose, current_pose.inverse()); // only identity mapping satisfies this
40    }
41}