Replies: 2 comments 2 replies
-
Thanks for reaching out! Easy fix, Alternatively to make sure it doesn't happen again, you can also do Let me know if that fixes it, or if you hit any other snags! factrs is under pretty heavy development still, so if you see anything you'd like/need let us know |
Beta Was this translation helpful? Give feedback.
-
Success! Fixing the dimension did the trick. I should point out that I originally followed the implementation of Anyway, once I got it working, I added a manual implementation of the Jacobian, just for the heck of it. No problems here. Listing the final code below, should anybody find it useful/instructional: impl Residual1 for GpsResidual
{
type Differ = ForwardProp<<Self as Residual1>::DimIn>;
type V1 = SE2;
type DimIn = Const<3>;
type DimOut = Const<2>;
fn residual1<D: Numeric>(&self, v: SE2<D>) -> VectorX<D> {
let p_meas = Vector2::<D>::dual_convert(&self.meas);
let p: VectorVar2<D> = v.xy().into_owned().into();
let p_meas: VectorVar2<D> = p_meas.into();
p.ominus_right(&p_meas)
}
fn residual1_jacobian(&self, values: &Values,keys: &[Key]) -> DiffResult<VectorX, MatrixX> {
let p: &SE2 = values.get_unchecked(*keys.first().unwrap()).unwrap();
let s = p.theta().sin();
let c = p.theta().cos();
let diff = MatrixX::from_row_slice(2, 3, &[0.0, c, -s,
0.0, s, c]);
DiffResult { value: self.residual1(p.clone()), diff }
}
} Should you be interested, I could open a PR to add the complete example to [2] https://github.com/rpl-cmu/factrs/blob/master/src/residuals/imu_preint/residual.rs#L299 |
Beta Was this translation helpful? Give feedback.
-
I'm trying to port the Localization example [1] from GTSAM over to factrs and ran into problems with the custom factor which is a translation of the
UnaryFactor
in the original code:The code compiles but panics due to a "Matrix index out of bounds" error during optimization.
This sounds like in issue with my code, but I'm a bit lost at this point. Any clues about this?
[1] https://github.com/borglab/gtsam/blob/develop/examples/LocalizationExample.cpp
Beta Was this translation helpful? Give feedback.
All reactions