Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with deserialize GenericProjectionFactor with python and Cauchy #1164

Closed
shteren1 opened this issue Apr 10, 2022 · 1 comment · Fixed by #1169
Closed

Problem with deserialize GenericProjectionFactor with python and Cauchy #1164

shteren1 opened this issue Apr 10, 2022 · 1 comment · Fixed by #1169

Comments

@shteren1
Copy link

shteren1 commented Apr 10, 2022

Description

When a GenericProjectionFactor is filled with serialized data and Cauchy robust loss it returns wrong error, using python wrapper.
I tested with Huber loss and it works fine. also notice that unweightenedError returns correct result.

Steps to reproduce

  1. see the attached python code:
import gtsam
import numpy as np

point_noise = gtsam.noiseModel.Diagonal.Sigmas(np.ones(2))
point_noise = gtsam.noiseModel.Robust.Create(gtsam.noiseModel.mEstimator.Cauchy.Create(1), point_noise)
factor = gtsam.GenericProjectionFactorCal3_S2(np.ones(2), point_noise, 0, 1, gtsam.Cal3_S2())
values = gtsam.Values()
values.insert(0, gtsam.Pose3())
values.insert(1, np.array([2, 0, 15]))
#init new factor with something, since there is no empty constructor for GenerincProjectionFactor
factor1 = gtsam.GenericProjectionFactorCal3_S2(np.ones(2), point_noise, 0, 2, gtsam.Cal3_S2())
factor1.deserialize(factor.serialize())
print(f"original factor error: {factor.error(values)}, deserialized factor error: {factor1.error(values)}")

output:
original factor error: 0.24628311578204365, deserialized factor error: 0.003451520129521184

Expected behavior

The error returned will be similar

Environment

tested on ubuntu 18.04 with python 3.7 and gtsam pip package version 4.2a5

@ProfFan
Copy link
Collaborator

ProfFan commented Apr 14, 2022

Hi @shteren1 I pushed the fix in the linked PR. Thanks for reporting :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants