幾元邊就有幾個jacobian
例如g2o定義的二元邊就有_jacobianoplusxi和_jacobianoplusxj
原始碼中baseedge定義如下:d決定了誤差的維度
template
<
int d,
typename e>
class
baseedge
:public optimizablegraph::edge
{public
:static
const
int dimension = d;
typedef e measurement;
typedef eigen::matrix1, eigen::colmajor> errorvector;
typedef eigen::matrix informationtype;
乙個具體例子:
class
vertexpose
:public g2o::basevertex<
6, sophus::se3d>
{class
edgeprojection
:public g2o::baseunaryedge<
2, eigen::vector2d, vertexpose>
{ _jacobianoplusxi
<<
-fx / z,
0, fx * x / z2, fx * x * y / z2,
-fx - fx * x * x / z2, fx * y / z,0,
-fy / z, fy * y /
(z * z)
, fy + fy * y * y / z2,
-fy * x * y / z2,
-fy * x / z;
typedef g2o::blocksolver3>> blocksolvertype;
// pose is 6, landmark is 3
class
curvefittin**ertex
:public g2o::basevertex<
3, eigen::vector3d>
{class
curvefittingedge
:public g2o::baseunaryedge<1,
double
, curvefittin**ertex>
{double y =
exp(abc[0]
* _x * _x + abc[1]
* _x + abc[2]
);_jacobianoplusxi[0]
=-_x * _x * y;
_jacobianoplusxi[1]
=-_x * y;
_jacobianoplusxi[2]
=-y;
typedef g2o::blocksolver1>> blocksolvertype;
// 每個誤差項優化變數維度為3,誤差值維度為1
class
basebinaryedge
:public baseedge
{public
:typedef vertexxi vertexxitype;
typedef vertexxj vertexxjtype;
static
const
int di = vertexxitype::dimension;
static
const
int dj = vertexxjtype::dimension;
static
const
int dimension = baseedge
::dimension;
typedef
typename baseedge
::measurement measurement;
typedef
typename eigen::matrix1?eigen::rowmajor:eigen::colmajor>
::alignedmaptype jacobianxioplustype;
typedef
typename eigen::matrix1?eigen::rowmajor:eigen::colmajor>
::alignedmaptype jacobianxjoplustype;
typedef
typename baseedge
::errorvector errorvector;
typedef
typename baseedge
::informationtype informationtype;
d決定了誤差的維度,從對映的角度講,三維情況下就是2維的,二維的情況下是1維的;然後e是measurement的型別,也就是測量值是什麼型別的,這裡e就是什麼型別的(一般都是eigen::vectorn表示的,n是自然數) g2o學習 g2o整體框架
進來對g2o優化庫進行了學習,雖然才模仿著寫了兩個例程,但是對於整個g2o的理解和使用方面還是多了不少的感觸,特此寫下部落格,對這些天的學習進行記錄。說到整體的結構,不得不用一張比較概括的圖來說明 這張圖最好跟著畫一下,這樣能更好的理解和掌握,例如我第一次看的時候根本沒有注意說箭頭的型別等等的細節。...
G2O使用要點總結
頂點的定義 繼承basevertex 定點byte數,頂點結構體 類 實現settoriginimpl 函式,裡面給 estimate成員函式賦初值 estimate的型別就是模板裡指定的頂點結構體 實現 oplusimpl const double update update 是指向跟新值得指標,...
使用g2o求解BA
用節點表示相機和路標,用邊表示他們之間的觀測,使用自定義的點和邊 include include include include include include include iostream include common.h include sophus se3.hpp using namesp...