Skip to content
New issue

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

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

Already on GitHub? # to your account

Error with python_wrapper: plot_covariance_ellipse_3d not work as expected #1098

Closed
szx0112 opened this issue Feb 14, 2022 · 2 comments
Closed
Labels
python Related to python wrapper
Milestone

Comments

@szx0112
Copy link

szx0112 commented Feb 14, 2022

Description

Hi gtsam support team, I tried to plot the marginal covariance matrix using plot_covariance_ellipse_3d. The inputs are axes, 3x1 point position , and 6x6 covariance matrix obtained from gtsam_marginals.marginalCovariance(keys[ii]). I have checked and ensured these input variables are good.

After running the code, I got the error shape mismatch: objects cannot be broadcast to a single shape.
The problem is related to this line:

rx, ry, rz = radii

The radii is actually a 6x1 vector instead of 3x1 vector as expected. An example of the radii I got is:
[12.57294157 12.42959364 11.95267523 0.18826816 0.18105469 0.17589153].

I have tried to just take the first/last three element but this result in the incorrect estimation of the x,y,z:

x = data[0:n, :] + origin[0]

The expected x/y/z is a 2d array (because they are the input of the axes.plot_surface) but here I got their shapes as (9, 9) (9, 9) (36, 9) respectively.

Any comment is appreciated.

Steps to reproduce

  1. I modify the code [Pose3SLAMExample_g2o.py] (https://github.com/borglab/gtsam/blob/develop/python/gtsam/examples/Pose3SLAMExample_g2o.py) to read g2o format.
  2. test data is downloaded from the benchmark dataset
  3. I use marginals = gtsam.Marginals(graph, initial) to extract marginals and iteratively obtain the covariance matrix (6x6 matrix) at each pose based on initial.keys()[ii].
  4. I have plotted the pose positions (both before and after optimization) on these dataset without any issue, and got the error (as above) when I try to show the covariance matrix at each pose.

Expected behavior

The eclipses should be shown at each point

Environment

Python 3.8 in conda environment. Build from source

@varunagrawal varunagrawal added the python Related to python wrapper label Apr 2, 2022
@ProfFan ProfFan added this to the GTSAM 4.2 milestone Apr 19, 2022
@varunagrawal
Copy link
Collaborator

Hi @szx0112 does #1193 solve your issue?

@varunagrawal
Copy link
Collaborator

Closing due to lack of a response. Please reopen if this is still an issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
python Related to python wrapper
Projects
None yet
Development

No branches or pull requests

3 participants