RainerKuemmerle / g2o

g2o: A General Framework for Graph Optimization
3.08k stars 1.11k forks source link

[Question] Relative inequality constraints without custom types #408

Open manolotis opened 4 years ago

manolotis commented 4 years ago

Hello,

I am looking for a way to constraint two vertices of my optimizable graph through a relative inequality rather than a exact measurement constraint, so as to add a constraint expressing "at least" or "at most" measurements. My goal is to penalize the situation in which two vertices are too close (closer than a predefined threshold distance). As a simple example: suppose I have two vertices v1 and v2 in 2D (no heading angle, just x,y coordinates). I would like to introduce an edge to capture that v1 and v2 are at least 5 meters apart, but say nothing about the upper bound of this distance.

Are there any pre-defined edges that allow me to set such a constraint without having to define my own? My apologies if this is documented somewhere in the code, I am finding it quite challenging to understand some of the classes that have little to no explanation provided.

sjulier commented 4 years ago

I don't think so.

Where I've implemented inequality constraints (and I've only used "closer than" ones) I've used a barrier method. To try to preserve a probabilistic perspective, I used a Generalized Normal, https://en.wikipedia.org/wiki/Generalized_normal_distribution, and implemented it using Rosen's method for non-Gaussian likelihoods, http://www.cs.cmu.edu/~kaess/pub/Rosen13icra.pdf.

Maybe an inverse barrier method (which I think just takes the reciprocal of the distance and uses the GN) might work?