optima 0.0.4

An easy to set up and easy optimization and planning toolbox, particularly for robotics.
Documentation
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
use std::vec;
#[cfg(not(target_arch = "wasm32"))]
use pyo3::*;

#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;

use nalgebra::{Isometry3, Matrix3, Matrix4, Quaternion, Rotation3, Unit, UnitQuaternion, Vector3};
use serde::{Serialize, Deserialize};
use crate::utils::utils_errors::OptimaError;
use crate::utils::utils_se3::homogeneous_matrix::HomogeneousMatrix;
use crate::utils::utils_se3::implicit_dual_quaternion::ImplicitDualQuaternion;
use crate::utils::utils_se3::optima_rotation::{OptimaRotation, OptimaRotationType};
use crate::utils::utils_se3::rotation_and_translation::RotationAndTranslation;
#[cfg(target_arch = "wasm32")]
use crate::utils::utils_wasm::JsMatrix;
#[cfg(target_arch = "wasm32")]
use crate::utils::utils_console::{optima_print, PrintColor, PrintMode};

/// An enum used to represent a rotation or orientation.  The enum affords easy conversion between
/// rotation types and functions over singular or pairs of rotations.
/// This is the main object that should be used for representing an SE(3) pose due to its
/// flexibility and interoperability.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum OptimaSE3Pose {
    ImplicitDualQuaternion { data: ImplicitDualQuaternion, pose_type: OptimaSE3PoseType },
    HomogeneousMatrix { data: HomogeneousMatrix, pose_type: OptimaSE3PoseType },
    RotationAndTranslation { data: RotationAndTranslation, pose_type: OptimaSE3PoseType },
    EulerAnglesAndTranslation { euler_angles: Vector3<f64>, translation: Vector3<f64>, phantom_data: ImplicitDualQuaternion, pose_type: OptimaSE3PoseType }
}
impl OptimaSE3Pose {
    pub fn new_from_euler_angles(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64, t: &OptimaSE3PoseType) -> Self {
        match t {
            OptimaSE3PoseType::ImplicitDualQuaternion => {
                Self::new_implicit_dual_quaternion_from_euler_angles(rx, ry, rz, x, y, z)
            }
            OptimaSE3PoseType::HomogeneousMatrix => {
                Self::new_homogeneous_matrix_from_euler_angles(rx, ry, rz, x, y, z)
            }
            OptimaSE3PoseType::UnitQuaternionAndTranslation => {
                Self::new_unit_quaternion_and_translation_from_euler_angles(rx, ry, rz, x, y, z)
            }
            OptimaSE3PoseType::RotationMatrixAndTranslation => {
                Self::new_rotation_matrix_and_translation_from_euler_angles(rx, ry, rz, x, y, z)
            }
            OptimaSE3PoseType::EulerAnglesAndTranslation => {
                let phantom_data = ImplicitDualQuaternion::new_from_euler_angles(rx, ry, rz, x, y, z);
                let euler_angles_and_translation = phantom_data.to_euler_angles_and_translation();
                Self::EulerAnglesAndTranslation {
                    euler_angles: euler_angles_and_translation.0,
                    translation: euler_angles_and_translation.1,
                    phantom_data,
                    pose_type: OptimaSE3PoseType::EulerAnglesAndTranslation
                }
            }
        }
    }
    pub fn new_from_axis_angle(axis: &Unit<Vector3<f64>>, angle: f64, x: f64, y: f64, z: f64, t: &OptimaSE3PoseType) -> Self {
        match t {
            OptimaSE3PoseType::ImplicitDualQuaternion => {
                Self::new_implicit_dual_quaternion_from_axis_angle(axis, angle, x, y, z)
            }
            OptimaSE3PoseType::HomogeneousMatrix => {
                Self::new_homogeneous_matrix_from_axis_angle(axis, angle, x, y, z)
            }
            OptimaSE3PoseType::UnitQuaternionAndTranslation => {
                Self::new_unit_quaternion_and_translation_from_axis_angle(axis, angle, x, y, z)
            }
            OptimaSE3PoseType::RotationMatrixAndTranslation => {
                Self::new_rotation_matrix_and_translation_from_axis_angle(axis, angle, x, y, z)
            }
            OptimaSE3PoseType::EulerAnglesAndTranslation => {
                let phantom_data = ImplicitDualQuaternion::new_from_axis_angle(axis, angle, x, y, z);
                let euler_angles_and_translation = phantom_data.to_euler_angles_and_translation();
                Self::EulerAnglesAndTranslation {
                    euler_angles: euler_angles_and_translation.0,
                    translation: euler_angles_and_translation.1,
                    phantom_data,
                    pose_type: OptimaSE3PoseType::EulerAnglesAndTranslation
                }
            }
        }
    }
    pub fn new_identity() -> Self {
        Self::new_from_euler_angles(0.,0.,0.,0.,0.,0., &OptimaSE3PoseType::ImplicitDualQuaternion)
    }

    pub fn new_homogeneous_matrix(data: HomogeneousMatrix) -> Self {
        Self::HomogeneousMatrix { data, pose_type: OptimaSE3PoseType::HomogeneousMatrix }
    }
    pub fn new_homogeneous_matrix_from_euler_angles(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self::new_homogeneous_matrix(HomogeneousMatrix::new_from_euler_angles(rx, ry, rz, x, y, z))
    }
    pub fn new_homogeneous_matrix_from_axis_angle(axis: &Unit<Vector3<f64>>, angle: f64, x: f64, y: f64, z: f64) -> Self {
        Self::new_homogeneous_matrix(HomogeneousMatrix::new_from_axis_angle(axis, angle, x, y, z))
    }

    pub fn new_rotation_and_translation(data: RotationAndTranslation) -> Self {
        match data.rotation() {
            OptimaRotation::RotationMatrix { .. } => {
                Self::RotationAndTranslation { data, pose_type: OptimaSE3PoseType::RotationMatrixAndTranslation }
            }
            OptimaRotation::UnitQuaternion { .. } => {
                Self::RotationAndTranslation { data, pose_type: OptimaSE3PoseType::UnitQuaternionAndTranslation }
            }
        }
    }
    pub fn new_rotation_and_translation_from_euler_angles(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64, rotation_type: &OptimaRotationType) -> Self {
        Self::new_rotation_and_translation(RotationAndTranslation::new_from_euler_angles(rx, ry, rz, x, y, z, rotation_type))
    }
    pub fn new_rotation_and_translation_from_axis_angle(axis: &Unit<Vector3<f64>>, angle: f64, x: f64, y: f64, z: f64, rotation_type: &OptimaRotationType) -> Self {
        Self::new_rotation_and_translation(RotationAndTranslation::new_from_axis_angle(axis, angle, x, y, z, rotation_type))
    }

    pub fn new_unit_quaternion_and_translation(q: UnitQuaternion<f64>, t: Vector3<f64>) -> Self {
        Self::new_rotation_and_translation(RotationAndTranslation::new(OptimaRotation::new_unit_quaternion(q), t))
    }
    pub fn new_unit_quaternion_and_translation_from_euler_angles(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self::new_rotation_and_translation_from_euler_angles(rx, ry, rz, x, y, z, &OptimaRotationType::UnitQuaternion)
    }
    pub fn new_unit_quaternion_and_translation_from_axis_angle(axis: &Unit<Vector3<f64>>, angle: f64, x: f64, y: f64, z: f64) -> Self {
        Self::new_rotation_and_translation_from_axis_angle(axis, angle, x, y, z, &OptimaRotationType::UnitQuaternion)
    }

    pub fn new_rotation_matrix_and_translation(m: Rotation3<f64>, t: Vector3<f64>) -> Self {
        Self::new_rotation_and_translation(RotationAndTranslation::new(OptimaRotation::new_rotation_matrix(m), t))
    }
    pub fn new_rotation_matrix_and_translation_from_euler_angles(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self::new_rotation_and_translation_from_euler_angles(rx, ry, rz, x, y, z, &OptimaRotationType::RotationMatrix)
    }
    pub fn new_rotation_matrix_and_translation_from_axis_angle(axis: &Unit<Vector3<f64>>, angle: f64, x: f64, y: f64, z: f64) -> Self {
        Self::new_rotation_and_translation_from_axis_angle(axis, angle, x, y, z, &OptimaRotationType::RotationMatrix)
    }

    pub fn new_implicit_dual_quaternion(data: ImplicitDualQuaternion) -> Self {
        Self::ImplicitDualQuaternion { data, pose_type: OptimaSE3PoseType::ImplicitDualQuaternion }
    }
    pub fn new_implicit_dual_quaternion_from_euler_angles(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self::new_implicit_dual_quaternion(ImplicitDualQuaternion::new_from_euler_angles(rx, ry, rz, x, y, z))
    }
    pub fn new_implicit_dual_quaternion_from_axis_angle(axis: &Unit<Vector3<f64>>, angle: f64, x: f64, y: f64, z: f64) -> Self {
        Self::new_implicit_dual_quaternion(ImplicitDualQuaternion::new_from_axis_angle(axis, angle, x, y, z))
    }

    pub fn new_euler_angles_and_translation(data: ImplicitDualQuaternion) -> Self {
        let euler_angles_and_translation = data.to_euler_angles_and_translation();
        Self::EulerAnglesAndTranslation {
            euler_angles: euler_angles_and_translation.0,
            translation: euler_angles_and_translation.1,
            phantom_data: data,
            pose_type: OptimaSE3PoseType::EulerAnglesAndTranslation
        }
    }

    /// Converts the SE(3) pose to other supported pose types.
    pub fn convert(&self, target_type: &OptimaSE3PoseType) -> OptimaSE3Pose {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { data.convert(target_type) }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => { data.convert(target_type) }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => { data.convert(target_type) }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles: _, translation: _, phantom_data, pose_type: _ } => {
                Self::new_implicit_dual_quaternion(phantom_data.clone()).convert(target_type)
            }
        }
    }
    /// The inverse transform such that T * T^-1 = I.
    pub fn inverse(&self) -> OptimaSE3Pose {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { Self::new_implicit_dual_quaternion(data.inverse()) }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => { Self::new_homogeneous_matrix(data.inverse()) }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => { Self::new_rotation_and_translation(data.inverse()) }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                Self::new_implicit_dual_quaternion(phantom_data.inverse()).convert(&OptimaSE3PoseType::EulerAnglesAndTranslation)
            }
        }
    }
    /// Transform multiplication.
    pub fn multiply(&self, other: &OptimaSE3Pose, conversion_if_necessary: bool) -> Result<OptimaSE3Pose, OptimaError> {
        let c = Self::are_types_compatible(self, other);
        if !c {
            return if conversion_if_necessary {
                let new_operand = other.convert(self.map_to_pose_type());
                self.multiply(&new_operand, conversion_if_necessary)
            } else {
                Err(OptimaError::new_generic_error_str("incompatible pose types in multiply.", file!(), line!()))
            }
        }

        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                        Ok(OptimaSE3Pose::new_implicit_dual_quaternion(data0.multiply_shortcircuit(data)))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in multiply.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                        Ok(OptimaSE3Pose::new_homogeneous_matrix(data0.multiply(data)))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in multiply.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                        Ok(OptimaSE3Pose::new_rotation_and_translation(data0.multiply(data, conversion_if_necessary)?))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in multiply.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                let data0 = phantom_data;
                match other {
                    OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                        Ok(OptimaSE3Pose::new_implicit_dual_quaternion(data0.multiply_shortcircuit(phantom_data)).convert(&OptimaSE3PoseType::EulerAnglesAndTranslation))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in distance function.", file!(), line!())) }
                }
            }
        }
    }

    pub fn multiply_separate_rotation_and_translation(&self, other: &OptimaSE3Pose, conversion_if_necessary: bool) -> Result<OptimaSE3Pose, OptimaError> {
        let self_translation = self.translation();
        let self_rotation = self.rotation();
        let other_translation = other.translation();
        let other_rotation = other.rotation();

        let multiplied_translation = self_translation + other_translation;
        let multiplied_rotation = self_rotation.multiply(&other_rotation, conversion_if_necessary).expect("error");

        let combined = Self::new_rotation_and_translation(RotationAndTranslation::new(multiplied_rotation, multiplied_translation));
        let res = combined.convert(&self.map_to_pose_type());
        return Ok(res);
    }
    /// Multiplication by a point.
    pub fn multiply_by_point(&self, point: &Vector3<f64>) -> Vector3<f64> {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { data.multiply_by_point(point) }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => { data.multiply_by_point(point) }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => { data.multiply_by_point(point) }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => { phantom_data.inverse_multiply_by_point_shortcircuit(point) }
        }
    }
    /// Inverse multiplies by the given point.  inverse multiplication is useful for placing the
    /// given point in the transform's local coordinate system.
    pub fn inverse_multiply_by_point(&self, point: &Vector3<f64>) -> Vector3<f64> {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { data.inverse_multiply_by_point_shortcircuit(point) }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => { data.inverse_multiply_by_point(point) }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => { data.inverse_multiply_by_point(point) }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => { phantom_data.inverse_multiply_by_point_shortcircuit(point) }
        }
    }
    /// The displacement transform such that T_self * T_disp = T_other.
    pub fn displacement(&self, other: &OptimaSE3Pose, conversion_if_necessary: bool) -> Result<OptimaSE3Pose, OptimaError> {
        let c = Self::are_types_compatible(self, other);
        if !c {
            return if conversion_if_necessary {
                let new_operand = other.convert(self.map_to_pose_type());
                self.displacement(&new_operand, conversion_if_necessary)
            } else {
                Err(OptimaError::new_generic_error_str("incompatible pose types in displacement.", file!(), line!()))
            }
        }

        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                        Ok(OptimaSE3Pose::new_implicit_dual_quaternion(data0.displacement(data)))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in displacement.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                        Ok(OptimaSE3Pose::new_homogeneous_matrix(data0.displacement(data)))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in displacement.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                        Ok(OptimaSE3Pose::new_rotation_and_translation(data0.displacement(data, conversion_if_necessary)?))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in displacement.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                let data0 = phantom_data;
                match other {
                    OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                        Ok(OptimaSE3Pose::new_implicit_dual_quaternion(data0.displacement(phantom_data)).convert(&OptimaSE3PoseType::EulerAnglesAndTranslation))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in displacement.", file!(), line!())) }
                }
            }
        }
    }

    pub fn displacement_separate_rotation_and_translation(&self, other: &OptimaSE3Pose, conversion_if_necessary: bool) -> Result<(OptimaRotation, Vector3<f64>), OptimaError> {
        let c = Self::are_types_compatible(self, other);
        if !c {
            return if conversion_if_necessary {
                let new_operand = other.convert(self.map_to_pose_type());
                self.displacement_separate_rotation_and_translation(&new_operand, conversion_if_necessary)
            } else {
                Err(OptimaError::new_generic_error_str("incompatible pose types in displacement_separate_rotation_and_translation.", file!(), line!()))
            }
        }

        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                        Ok(data0.displacement_separate_rotation_and_translation(data))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in displacement_separate_rotation_and_translation.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                        Ok(data0.displacement_separate_rotation_and_translation(data))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in displacement_separate_rotation_and_translation.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                        Ok(data0.displacement_separate_rotation_and_translation(data))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in displacement_separate_rotation_and_translation.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                let data0 = phantom_data;
                match other {
                    OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                        Ok(data0.displacement_separate_rotation_and_translation(phantom_data))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in displacement_separate_rotation_and_translation.", file!(), line!())) }
                }
            }
        }
    }

    pub fn slerp(&self, other: &OptimaSE3Pose, t: f64, conversion_if_necessary: bool) -> Result<OptimaSE3Pose, OptimaError> {
        let c = Self::are_types_compatible(self, other);
        if !c {
            return if conversion_if_necessary {
                let new_operand = other.convert(self.map_to_pose_type());
                self.slerp(&new_operand, t, conversion_if_necessary)
            } else {
                Err(OptimaError::new_generic_error_str("incompatible pose types in slerp.", file!(), line!()))
            }
        }

        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                        Ok(Self::new_implicit_dual_quaternion(data0.slerp(data, t)))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in slerp.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                        Ok(Self::new_homogeneous_matrix(data0.slerp(data, t)))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in slerp.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                        Ok(Self::new_rotation_and_translation(data0.slerp(data, t, conversion_if_necessary)?))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in slerp.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                let data0 = phantom_data;
                match other {
                    OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                        Ok(Self::new_euler_angles_and_translation( data0.slerp(phantom_data, t) ))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in slerp.", file!(), line!())) }
                }
            }
        }
    }
    /// Distance function between transforms.  This may be approximate.
    /// In the case of the implicit dual quaternion, this is smooth, differentiable, and exact (one
    /// of the benefits of that representation).
    pub fn distance_function(&self, other: &OptimaSE3Pose, conversion_if_necessary: bool) -> Result<f64, OptimaError> {
        let c = Self::are_types_compatible(self, other);
        if !c {
            return if conversion_if_necessary {
                let new_operand = other.convert(self.map_to_pose_type());
                self.distance_function(&new_operand, conversion_if_necessary)
            } else {
                Err(OptimaError::new_generic_error_str("incompatible pose types in distance function.", file!(), line!()))
            }
        }

        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                        Ok(data0.displacement(data).ln_l2_magnitude())
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in distance function.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                        Ok(data0.approximate_distance(&data))
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in distance function.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                let data0 = data;
                match other {
                    OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                        data0.approximate_distance(&data, conversion_if_necessary)
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in distance function.", file!(), line!())) }
                }
            }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                let data0 = phantom_data;
                match other {
                    OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles:_, translation:_, phantom_data, pose_type:_ } => {
                        Ok(data0.displacement(phantom_data).ln_l2_magnitude())
                    }
                    _ => { Err(OptimaError::new_generic_error_str("incompatible pose types in distance function.", file!(), line!())) }
                }
            }
        }
    }
    /// Unwraps homogeneous matrix.  Returns error if the underlying representation is not homogeneous matrix.
    pub fn unwrap_homogeneous_matrix(&self) -> Result<&HomogeneousMatrix, OptimaError> {
        return match self {
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                Ok(data)
            }
            _ => {
                Err(OptimaError::new_generic_error_str("tried to unwrap homogenous matrix on incompatible type.", file!(), line!()))
            }
        }
    }
    /// Unwraps implicit dual quaternion.  Returns error if the underlying representation is not IDQ.
    pub fn unwrap_implicit_dual_quaternion(&self) -> Result<&ImplicitDualQuaternion, OptimaError> {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                Ok(data)
            }
            _ => {
                Err(OptimaError::new_generic_error_str("tried to unwrap implicit dual quaternion on incompatible type.", file!(), line!()))
            }
        }
    }
    /// Unwraps rotation and translation.  Returns error if the underlying representation is not R&T.
    pub fn unwrap_rotation_and_translation(&self) -> Result<&RotationAndTranslation, OptimaError> {
        return match self {
            OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                Ok(data)
            }
            _ => {
                Err(OptimaError::new_generic_error_str("tried to unwrap rotation and translation on incompatible type.", file!(), line!()))
            }
        }
    }
    /// Returns an euler angle and vector representation of the SE(3) pose.
    pub fn to_euler_angles_and_translation(&self) -> (Vector3<f64>, Vector3<f64>) {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => {
                data.to_euler_angles_and_translation()
            }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => {
                data.to_euler_angles_and_translation()
            }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => {
                data.to_euler_angles_and_translation()
            }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles, translation, .. } => {
                return (euler_angles.clone(), translation.clone())
            }
        }
    }
    /// Returns an axis angle and translation representation of the SE(3) pose.
    pub fn to_axis_angle_and_translation(&self) -> (Vector3<f64>, f64, Vector3<f64>) {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { data.to_axis_angle_and_translation() }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => { data.to_axis_angle_and_translation() }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => { data.to_axis_angle_and_translation() }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles: _, translation: _, phantom_data, pose_type: _ } => { phantom_data.to_axis_angle_and_translation() }
        }
    }
    /// Outputs an Isometry3 object in the Nalgebra library that corresponds to the SE(3) pose.
    pub fn to_nalgebra_isometry(&self) -> Isometry3<f64> {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { data.to_nalgebra_isometry() }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => { data.to_nalgebra_isometry() }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => { data.to_nalgebra_isometry() }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles: _, translation: _, phantom_data, pose_type: _ } => { phantom_data.to_nalgebra_isometry() }
        }
    }
    /// Converts to vector representation.
    pub fn to_vec_representation(&self) -> Vec<Vec<f64>> {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { data.to_vec_representation() }
            OptimaSE3Pose::HomogeneousMatrix { data, .. } => { data.to_vec_representation() }
            OptimaSE3Pose::RotationAndTranslation { data, .. } => { data.to_vec_representation() }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles, translation, .. } => {
                let e = euler_angles;
                let t = translation;
                return vec![ vec![e[0], e[1], e[2]], vec![t[0], t[1], t[2]] ];
            }
        }
    }
    pub fn map_to_pose_type(&self) -> &OptimaSE3PoseType {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data: _, pose_type } => { pose_type }
            OptimaSE3Pose::HomogeneousMatrix { data: _, pose_type } => { pose_type }
            OptimaSE3Pose::RotationAndTranslation { data: _, pose_type } => { pose_type }
            OptimaSE3Pose::EulerAnglesAndTranslation { euler_angles: _, translation: _, phantom_data: _, pose_type } => { pose_type }
        }
    }
    pub fn translation(&self) -> Vector3<f64> {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { data.translation().clone() }
            OptimaSE3Pose::HomogeneousMatrix { data, ..} => { data.translation().clone() }
            OptimaSE3Pose::RotationAndTranslation { data, ..} => { data.translation().clone() }
            OptimaSE3Pose::EulerAnglesAndTranslation { translation, .. } => { translation.clone() }
        }
    }
    pub fn rotation(&self) -> OptimaRotation {
        return match self {
            OptimaSE3Pose::ImplicitDualQuaternion { data, .. } => { OptimaRotation::new_unit_quaternion(data.rotation().clone()) }
            OptimaSE3Pose::HomogeneousMatrix { data, ..} => { OptimaRotation::new_rotation_matrix(data.rotation()) }
            OptimaSE3Pose::RotationAndTranslation { data, ..} => { data.rotation().clone() }
            OptimaSE3Pose::EulerAnglesAndTranslation { phantom_data, .. } => { OptimaRotation::new_unit_quaternion(phantom_data.rotation().clone()) }
        }
    }
    fn are_types_compatible(a: &OptimaSE3Pose, b: &OptimaSE3Pose) -> bool {
        return if a.map_to_pose_type() == b.map_to_pose_type() { true } else { false }
    }
}
impl Default for OptimaSE3Pose {
    fn default() -> Self {
        Self::new_identity()
    }
}

/// An Enum that encodes a pose type.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum OptimaSE3PoseType {
    ImplicitDualQuaternion,
    HomogeneousMatrix,
    UnitQuaternionAndTranslation,
    RotationMatrixAndTranslation,
    EulerAnglesAndTranslation
}

/// A container object that holds all OPtimaSE3 types.  This is useful for functions that may need
/// to handle many pose types, so this allows all to be initialized and saved at once to avoid
/// many transform conversions at run-time.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct OptimaSE3PoseAll {
    implicit_dual_quaternion: OptimaSE3Pose,
    homogeneous_matrix: OptimaSE3Pose,
    unit_quaternion_and_translation: OptimaSE3Pose,
    rotation_matrix_and_translation: OptimaSE3Pose,
    euler_angles_and_translation: OptimaSE3Pose
}
impl OptimaSE3PoseAll {
    pub fn new(p: &OptimaSE3Pose) -> Self {
        Self {
            implicit_dual_quaternion: p.convert(&OptimaSE3PoseType::ImplicitDualQuaternion),
            homogeneous_matrix: p.convert(&OptimaSE3PoseType::HomogeneousMatrix),
            unit_quaternion_and_translation: p.convert(&OptimaSE3PoseType::UnitQuaternionAndTranslation),
            rotation_matrix_and_translation: p.convert(&OptimaSE3PoseType::RotationMatrixAndTranslation),
            euler_angles_and_translation: p.convert(&OptimaSE3PoseType::EulerAnglesAndTranslation)
        }
    }

    pub fn new_identity() -> Self {
        return Self::new(&OptimaSE3Pose::new_unit_quaternion_and_translation_from_euler_angles(0.,0.,0.,0.,0.,0.));
    }

    pub fn get_pose_by_type(&self, t: &OptimaSE3PoseType) -> &OptimaSE3Pose {
        return match t {
            OptimaSE3PoseType::ImplicitDualQuaternion => { &self.implicit_dual_quaternion }
            OptimaSE3PoseType::HomogeneousMatrix => { &self.homogeneous_matrix }
            OptimaSE3PoseType::UnitQuaternionAndTranslation => { &self.unit_quaternion_and_translation }
            OptimaSE3PoseType::RotationMatrixAndTranslation => { &self.rotation_matrix_and_translation }
            OptimaSE3PoseType::EulerAnglesAndTranslation => { &self.euler_angles_and_translation }
        }
    }
}

#[cfg_attr(not(target_arch = "wasm32"), pyclass, derive(Clone, Debug, Serialize, Deserialize))]
pub struct OptimaSE3PosePy {
    pose: OptimaSE3Pose
}
#[cfg(not(target_arch = "wasm32"))]
#[pymethods]
impl OptimaSE3PosePy {
    #[staticmethod]
    pub fn new_implicit_dual_quaternion_from_euler_angles_and_translation_py(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_implicit_dual_quaternion_from_euler_angles(rx, ry, rz, x, y, z)
        }
    }
    #[staticmethod]
    pub fn new_homogeneous_matrix_from_euler_angles_and_translation_py(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_homogeneous_matrix_from_euler_angles(rx, ry, rz, x, y, z)
        }
    }
    #[staticmethod]
    pub fn new_unit_quaternion_and_translation_from_euler_angles_and_translation_py(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_unit_quaternion_and_translation_from_euler_angles(rx, ry, rz, x, y, z)
        }
    }
    #[staticmethod]
    pub fn new_rotation_matrix_and_translation_from_euler_angles_and_translation_py(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_rotation_matrix_and_translation_from_euler_angles(rx, ry, rz, x, y, z)
        }
    }
    #[staticmethod]
    pub fn new_euler_angles_and_translation_py(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_euler_angles_and_translation(ImplicitDualQuaternion::new_from_euler_angles(rx, ry, rz, x, y, z))
        }
    }
    #[staticmethod]
    pub fn new_implicit_dual_quaternion_py(q: [f64; 4], t: [f64; 3]) -> Self {
        let rotation = UnitQuaternion::from_quaternion(Quaternion::new(q[3], q[0], q[1], q[2]));
        let translation = Vector3::new(t[0], t[1], t[2]);
        return Self {
            pose: OptimaSE3Pose::new_implicit_dual_quaternion(ImplicitDualQuaternion::new(rotation, translation))
        }
    }
    #[staticmethod]
    pub fn new_homogeneous_matrix_py(m: [[f64; 4]; 4]) -> Self {
        let mat = Matrix4::new(
            m[0][0], m[0][1], m[0][2], m[0][3],
            m[1][0], m[1][1], m[1][2], m[1][3],
            m[2][0], m[2][1], m[2][2], m[2][3],
            m[3][0], m[3][1], m[3][2], m[3][3]);

        let h = HomogeneousMatrix::new(mat);
        return Self {
            pose: OptimaSE3Pose::new_homogeneous_matrix(h)
        }
    }
    #[staticmethod]
    pub fn new_unit_quaternion_and_translation_py(q: [f64; 4], t: [f64; 3]) -> Self {
        let rotation = UnitQuaternion::from_quaternion(Quaternion::new(q[3], q[0], q[1], q[2]));
        let translation = Vector3::new(t[0], t[1], t[2]);
        return Self {
            pose: OptimaSE3Pose::new_unit_quaternion_and_translation(rotation, translation)
        }
    }
    #[staticmethod]
    pub fn new_rotation_matrix_and_translation_py(r: [[f64; 3]; 3], t: [f64; 3]) -> Self {
        let rotation = Rotation3::from_matrix(&Matrix3::new(
            r[0][0], r[0][1], r[0][2],
            r[1][0], r[1][1], r[1][2],
            r[2][0], r[2][1], r[2][2]));
        let translation = Vector3::new(t[0], t[1], t[2]);
        return Self {
            pose: OptimaSE3Pose::new_rotation_matrix_and_translation(rotation, translation)
        }
    }

    pub fn get_euler_angles_and_translation(&self) -> (Vec<f64>, Vec<f64>) {
        let euler_angles_and_translation = self.pose.to_euler_angles_and_translation();
        let e = euler_angles_and_translation.0;
        let t = euler_angles_and_translation.1;
        return (vec![e[0], e[1], e[2]], vec![t[0], t[1], t[2]])
    }

    /// \[i, j, k, w\]
    pub fn get_unit_quaternion_and_translation(&self) -> (Vec<f64>, Vec<f64>) {
        let unit_quat_and_translation_pose = self.pose.convert(&OptimaSE3PoseType::UnitQuaternionAndTranslation);
        let unit_quat_and_translation = unit_quat_and_translation_pose.unwrap_rotation_and_translation().expect("error");
        let q = unit_quat_and_translation.rotation().unwrap_unit_quaternion().expect("error");
        let t = unit_quat_and_translation.translation();
        return (vec![q.i, q.j, q.k, q.w], vec![t[0], t[1], t[2]])
    }

    pub fn get_rotation_matrix_and_translation(&self) -> (Vec<Vec<f64>>, Vec<f64>) {
        let rot_mat_and_translation_pose = self.pose.convert(&OptimaSE3PoseType::RotationMatrixAndTranslation);
        let rot_mat_and_translation = rot_mat_and_translation_pose.unwrap_rotation_and_translation().expect("error");
        let r = rot_mat_and_translation.rotation().unwrap_rotation_matrix().expect("error");
        let t = rot_mat_and_translation.translation();
        let mat = vec![
            vec![r[(0,0)], r[(0,1)], r[(0,2)]],
            vec![r[(1,0)], r[(1,1)], r[(1,2)]],
            vec![r[(2,0)], r[(2,1)], r[(2,2)]]
        ];
        return (mat, vec![t[0], t[1], t[2]])
    }

    pub fn get_homogeneous_matrix(&self) -> Vec<Vec<f64>> {
        let homogeneous_matrix = self.pose.convert(&OptimaSE3PoseType::HomogeneousMatrix);
        let mat = homogeneous_matrix.unwrap_homogeneous_matrix().expect("error");
        return mat.to_vec_representation();
    }

    pub fn print_summary_py(&self) {
        println!("{:?}", self);
    }
}
impl OptimaSE3PosePy {
    pub fn pose(&self) -> &OptimaSE3Pose { &self.pose }
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen, derive(Clone, Debug, Serialize, Deserialize))]
pub struct OptimaSE3PoseWASM {
    pose: OptimaSE3Pose
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
impl OptimaSE3PoseWASM {
    pub fn new_implicit_dual_quaternion_from_euler_angles_wasm(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_implicit_dual_quaternion_from_euler_angles(rx, ry, rz, x, y, z)
        }
    }
    pub fn new_homogeneous_matrix_from_euler_angles_wasm(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_homogeneous_matrix_from_euler_angles(rx, ry, rz, x, y, z)
        }
    }
    pub fn new_unit_quaternion_and_translation_from_euler_angles_wasm(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_unit_quaternion_and_translation_from_euler_angles(rx, ry, rz, x, y, z)
        }
    }
    pub fn new_rotation_matrix_and_translation_from_euler_angles_wasm(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_rotation_matrix_and_translation_from_euler_angles(rx, ry, rz, x, y, z)
        }
    }
    pub fn new_euler_angles_and_translation_wasm(rx: f64, ry: f64, rz: f64, x: f64, y: f64, z: f64) -> Self {
        Self {
            pose: OptimaSE3Pose::new_euler_angles_and_translation(ImplicitDualQuaternion::new_from_euler_angles(rx, ry, rz, x, y, z))
        }
    }
    pub fn new_implicit_dual_quaternion_wasm(q: Vec<f64>, t: Vec<f64>) -> Self {
        let rotation = UnitQuaternion::from_quaternion(Quaternion::new(q[3], q[0], q[1], q[2]));
        let translation = Vector3::new(t[0], t[1], t[2]);
        return Self {
            pose: OptimaSE3Pose::new_implicit_dual_quaternion(ImplicitDualQuaternion::new(rotation, translation))
        }
    }
    pub fn new_unit_quaternion_and_translation_wasm(q: Vec<f64>, t: Vec<f64>) -> Self {
        let rotation = UnitQuaternion::from_quaternion(Quaternion::new(q[3], q[0], q[1], q[2]));
        let translation = Vector3::new(t[0], t[1], t[2]);
        return Self {
            pose: OptimaSE3Pose::new_unit_quaternion_and_translation(rotation, translation)
        }
    }
    pub fn new_homogeneous_matrix_wasm(input_mat: JsValue) -> Self {
        let mat: JsMatrix = input_mat.into_serde().unwrap();
        let m = mat.matrix();
        let mat = Matrix4::new(
            m[0][0], m[0][1], m[0][2], m[0][3],
            m[1][0], m[1][1], m[1][2], m[1][3],
            m[2][0], m[2][1], m[2][2], m[2][3],
            m[3][0], m[3][1], m[3][2], m[3][3]);

        let h = HomogeneousMatrix::new(mat);
        return Self {
            pose: OptimaSE3Pose::new_homogeneous_matrix(h)
        }
    }
    pub fn new_rotation_matrix_and_translation_wasm(r: JsValue, t: Vec<f64>) -> Self {
        let mat: JsMatrix = r.into_serde().unwrap();
        let m = mat.matrix();
        let rotation = Rotation3::from_matrix(&Matrix3::new(
            m[0][0], m[0][1], m[0][2],
            m[1][0], m[1][1], m[1][2],
            m[2][0], m[2][1], m[2][2]));
        let translation = Vector3::new(t[0], t[1], t[2]);
        return Self {
            pose: OptimaSE3Pose::new_rotation_matrix_and_translation(rotation, translation)
        }
    }

    pub fn serialized_pose(&self) -> JsValue {
        JsValue::from_serde(&self).unwrap()
    }
    pub fn print_summary_wasm(&self) {
        optima_print(&format!("{:?}", self), PrintMode::Println, PrintColor::None, true);
    }
}
impl OptimaSE3PoseWASM {
    pub fn pose(&self) -> &OptimaSE3Pose { &self.pose }
}