RainerKuemmerle / g2o

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

edges unchanged #442

Open wxt-github opened 4 years ago

wxt-github commented 4 years ago

Hello, if there are some vertices connected by edges, but some of the edges I want to remain unchanged before and after optimization, what should I do? @RainerKuemmerle

RainerKuemmerle commented 4 years ago

I guess you mean vertices should not change. Set them to fixed by calling setFixed. If edges should not be taken into account have a look at the different methods to initialize the optimization.

Cheers Rainer

Am 10.10.2020 um 11:18 schrieb wxt-github notifications@github.com:

 Hello, if there are some vertices connected by edges, but some of the edges I want to remain unchanged before and after optimization, what should I do? @RainerKuemmerle

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

wxt-github commented 4 years ago

Not exactly the same,setFixed means absolutely unchanged before and after optimization, but what I want is that certain vertices change before and after optimization, but the relative position between vertices and vertices remains unchanged.Is there any way to achieve this?

sjulier commented 4 years ago

There isn't an edge type which ensures equality constraints. You could create an edge type which specifies the relative translation and says the covariance is small (information matrix is very big). However, this tends to introduce large gradients which I think slows the optimiser down.

What's the feasibility of not having a "real" vertex but create a "virtual" one?

Suppose you had two vertices v0 and v1, where v1=v0+dv, where dv is fixed and known. Can you just keep a single vertex v0 in the graph, and wherever you'd reference v1, replace it by v0+dv where dv is, say, a fixed parameter value?

RainerKuemmerle commented 4 years ago

I would try to address it by using an offset between the two vertices. There are several examples that provide this concept. For example: https://github.com/RainerKuemmerle/g2o/blob/master/g2o/types/slam3d/edge_se3_pointxyz.cpp which implements observations to 3D points from a pose whereas an offset would represent the equality between "two" poses. You will only have the vertex once in the optimization but express equality by the offset.