Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
肥鼠路易
基于MyG2O的例子实现
提交
260f237c
基
基于MyG2O的例子实现
项目概览
肥鼠路易
/
基于MyG2O的例子实现
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
29
列表
看板
标记
里程碑
合并请求
29
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
基
基于MyG2O的例子实现
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
29
Issue
29
列表
看板
标记
里程碑
合并请求
29
合并请求
29
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
260f237c
编写于
6月 08, 2021
作者:
肥鼠路易
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
上传新文件
上级
c30c3b00
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
214 addition
and
0 deletion
+214
-0
include/types_six_dof_expmap_ours.h
include/types_six_dof_expmap_ours.h
+214
-0
未找到文件。
include/types_six_dof_expmap_ours.h
0 → 100644
浏览文件 @
260f237c
// g2o - General Graph Optimization
// Copyright (C) 2011 H. Strasdat
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Modified by Raúl Mur Artal (2014)
// Added EdgeSE3ProjectXYZ (project using focal_length in x,y directions)
// Modified by Raúl Mur Artal (2016)
// Added EdgeStereoSE3ProjectXYZ (project using focal_length in x,y directions)
// Added EdgeSE3ProjectXYZOnlyPose (unary edge to optimize only the camera pose)
// Added EdgeStereoSE3ProjectXYZOnlyPose (unary edge to optimize only the camera pose)
#ifndef G2O_SIX_DOF_TYPES_EXPMAP_our
#define G2O_SIX_DOF_TYPES_EXPMAP_our
#include "../Thirdparty/g2o/g2o/core/base_vertex.h"
#include "../Thirdparty/g2o/g2o/core/base_binary_edge.h"
#include "../Thirdparty/g2o/g2o/core/base_unary_edge.h"
//#include "se3_ops.h"
//#include "se3quat.h"
#include "../Thirdparty/g2o/g2o/types/types_sba.h"
#include "so3.h"
#include <Eigen/Geometry>
#include <Eigen/StdVector>
#include "Thirdparty/g2o/g2o/core/factory.h"
#include "Thirdparty/g2o/g2o/stuff/macros.h"
#include "Thirdparty/g2o/g2o/types/types_sba.h"
#include "Thirdparty/g2o/g2o/types/types_six_dof_expmap.h"
#include "Thirdparty/g2o/g2o/core/base_edge.h"
#include "Thirdparty/g2o/g2o/core/block_solver.h"
namespace
g2o
{
namespace
types_six_dof_expmap
{
void
init
();
}
using
namespace
Eigen
;
typedef
Matrix
<
double
,
6
,
6
>
Matrix6d
;
/**
* \brief SE3 Vertex parameterized internally with a transformation matrix
and externally with its exponential map
*/
class
VertexMyExpmap
:
public
BaseVertex
<
6
,
SE3Quat
>
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
VertexMyExpmap
();
bool
read
(
std
::
istream
&
is
);
bool
write
(
std
::
ostream
&
os
)
const
;
virtual
void
setToOriginImpl
()
{
_estimate
=
SE3Quat
();
}
virtual
void
oplusImpl
(
const
double
*
update_
)
{
Eigen
::
Map
<
const
Vector6d
>
update
(
update_
);
std
::
cout
<<
"VertexSE3Expmap"
<<
update
.
transpose
()
<<
std
::
endl
;
setEstimate
(
SE3Quat
::
exp
(
update
)
*
estimate
());
}
};
/**
* \brief SO3 Vertex parameterized internally with a rotation matrix and externally with its exponential map
*/
class
VertexSO3Expmap
:
public
BaseVertex
<
3
,
SO3
>
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
;
public:
VertexSO3Expmap
();
bool
read
(
std
::
istream
&
is
);
bool
write
(
std
::
ostream
&
os
)
const
;
virtual
void
setToOriginImpl
(){
_estimate
=
SO3
();
}
virtual
void
oplusImpl
(
const
double
*
update_
){
Eigen
::
Map
<
const
Vector3d
>
update
(
update_
);
SO3
tmp
(
SO3
::
exp
(
update
));
setEstimate
(
tmp
*
estimate
());
// exp(w + delta_w ) = exp(delta_w ) * exp(w); left multipline
}
};
class
EdgeSE3ProjectPlaneSO3
:
public
BaseBinaryEdge
<
3
,
Vector3d
,
VertexSO3Expmap
,
VertexMyExpmap
>
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
;
public:
EdgeSE3ProjectPlaneSO3
();
bool
read
(
std
::
istream
&
is
);
bool
write
(
std
::
ostream
&
os
)
const
;
void
computeError
(){
VertexMyExpmap
*
vj
=
static_cast
<
VertexMyExpmap
*>
(
_vertices
[
1
]);
SE3Quat
T
(
vj
->
estimate
());
VertexSO3Expmap
*
vi
=
static_cast
<
VertexSO3Expmap
*>
(
_vertices
[
0
]);
SO3
plane
(
vi
->
estimate
());
Quaterniond
pi_x
=
plane_c
.
unit_quaternion
();
// the observation
Vector4d
pi_x_4d
;
pi_x_4d
<<
pi_x
.
x
()
,
pi_x
.
y
()
,
pi_x
.
z
()
,
pi_x
.
w
();
Vector4d
y
=
T
.
to_homogeneous_matrix
().
transpose
()
*
pi_x_4d
;
Vector4d
q_y
=
y
/
y
.
norm
();
Quaterniond
n_q_y
(
q_y
[
3
]
,
q_y
[
0
]
,
q_y
[
1
]
,
q_y
[
2
]);
SO3
q_T
(
n_q_y
);
SO3
q_u
=
q_T
*
plane
.
inverse
();
Vector3d
u
=
q_u
.
log
();
Vector3d
obs
;
obs
=
u
;
_error
=
obs
;
}
virtual
void
linearizeOplus
();
void
setParams
(
const
SO3
&
plane_
);
SO3
plane_c
;
// the plane coordinates in the current camera frame C
};
class
EdgeSE3ProjectPlaneSO3OnlyPose
:
public
BaseUnaryEdge
<
3
,
Vector3d
,
VertexSE3Expmap
>
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
;
public:
EdgeSE3ProjectPlaneSO3OnlyPose
();
bool
read
(
std
::
istream
&
is
);
bool
write
(
std
::
ostream
&
os
)
const
;
void
computeError
(){
VertexSE3Expmap
*
vj
=
static_cast
<
VertexSE3Expmap
*>
(
_vertices
[
0
]);
SE3Quat
T
(
vj
->
estimate
());
//VertexSO3Expmap *vi = static_cast<VertexSO3Expmap *>(_vertices[0]);
SO3
plane
=
plane_g
;
//(vi->estimate());
Quaterniond
pi_x
=
plane_c
.
unit_quaternion
();
// the observation
Vector4d
pi_x_4d
;
pi_x_4d
<<
pi_x
.
x
()
,
pi_x
.
y
()
,
pi_x
.
z
()
,
pi_x
.
w
();
Vector4d
y
=
T
.
to_homogeneous_matrix
().
transpose
()
*
pi_x_4d
;
Vector4d
q_y
=
y
/
y
.
norm
();
Quaterniond
n_q_y
(
q_y
[
3
]
,
q_y
[
0
]
,
q_y
[
1
]
,
q_y
[
2
]);
SO3
q_T
(
n_q_y
);
SO3
q_u
=
q_T
*
plane
.
inverse
();
Vector3d
u
=
q_u
.
log
();
Vector3d
obs
;
obs
=
u
;
_error
=
obs
;
}
virtual
void
linearizeOplus
();
void
setParams
(
const
SO3
&
plane_
,
const
SO3
&
_plane_g
);
SO3
plane_c
;
// the plane coordinates in the current camera frame C
SO3
plane_g
;
};
}
// end namespace
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录