forked from Little-Potato-1990/localization_in_auto_driving
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7243d79
commit 187273f
Showing
23 changed files
with
847 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# Find the header files | ||
FIND_PATH(G2O_INCLUDE_DIR g2o/core/base_vertex.h | ||
${G2O_ROOT}/include | ||
$ENV{G2O_ROOT}/include | ||
$ENV{G2O_ROOT} | ||
/usr/local/include | ||
/usr/include | ||
/opt/local/include | ||
/sw/local/include | ||
/sw/include | ||
# /opt/ros/$ENV{ROS_DISTRO}/include | ||
NO_DEFAULT_PATH | ||
) | ||
|
||
# Macro to unify finding both the debug and release versions of the | ||
# libraries; this is adapted from the OpenSceneGraph FIND_LIBRARY | ||
# macro. | ||
|
||
MACRO(FIND_G2O_LIBRARY MYLIBRARY MYLIBRARYNAME) | ||
|
||
FIND_LIBRARY("${MYLIBRARY}_DEBUG" | ||
NAMES "g2o_${MYLIBRARYNAME}_d" | ||
PATHS | ||
${G2O_ROOT}/lib/Debug | ||
${G2O_ROOT}/lib | ||
$ENV{G2O_ROOT}/lib/Debug | ||
$ENV{G2O_ROOT}/lib | ||
# /opt/ros/$ENV{ROS_DISTRO}/lib | ||
NO_DEFAULT_PATH | ||
) | ||
|
||
FIND_LIBRARY("${MYLIBRARY}_DEBUG" | ||
NAMES "g2o_${MYLIBRARYNAME}_d" | ||
PATHS | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local/lib | ||
/usr/local/lib64 | ||
/usr/lib | ||
/usr/lib64 | ||
/opt/local/lib | ||
/sw/local/lib | ||
/sw/lib | ||
NO_DEFAULT_PATH | ||
) | ||
|
||
FIND_LIBRARY(${MYLIBRARY} | ||
NAMES "libg2o_${MYLIBRARYNAME}.so" | ||
PATHS | ||
${G2O_ROOT}/lib/Release | ||
${G2O_ROOT}/lib | ||
$ENV{G2O_ROOT}/lib/Release | ||
$ENV{G2O_ROOT}/lib | ||
# /opt/ros/$ENV{ROS_DISTRO}/lib | ||
NO_DEFAULT_PATH | ||
) | ||
|
||
FIND_LIBRARY(${MYLIBRARY} | ||
NAMES "libg2o_${MYLIBRARYNAME}.so" | ||
PATHS | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local/lib | ||
/usr/local/lib64 | ||
/usr/lib | ||
/usr/lib64 | ||
/opt/local/lib | ||
/sw/local/lib | ||
/sw/lib | ||
NO_DEFAULT_PATH | ||
) | ||
IF(NOT ${MYLIBRARY}_DEBUG) | ||
IF(MYLIBRARY) | ||
SET(${MYLIBRARY}_DEBUG ${MYLIBRARY}) | ||
ENDIF(MYLIBRARY) | ||
ENDIF( NOT ${MYLIBRARY}_DEBUG) | ||
|
||
ENDMACRO() | ||
|
||
# Find the core elements | ||
FIND_G2O_LIBRARY(G2O_STUFF_LIBRARY stuff) | ||
FIND_G2O_LIBRARY(G2O_CORE_LIBRARY core) | ||
|
||
# Find the CLI library | ||
FIND_G2O_LIBRARY(G2O_CLI_LIBRARY cli) | ||
|
||
# Find the pluggable solvers | ||
FIND_G2O_LIBRARY(G2O_SOLVER_CHOLMOD solver_cholmod) | ||
FIND_G2O_LIBRARY(G2O_SOLVER_CSPARSE solver_csparse) | ||
FIND_G2O_LIBRARY(G2O_SOLVER_CSPARSE_EXTENSION csparse_extension) | ||
FIND_G2O_LIBRARY(G2O_SOLVER_DENSE solver_dense) | ||
FIND_G2O_LIBRARY(G2O_SOLVER_PCG solver_pcg) | ||
FIND_G2O_LIBRARY(G2O_SOLVER_SLAM2D_LINEAR solver_slam2d_linear) | ||
FIND_G2O_LIBRARY(G2O_SOLVER_STRUCTURE_ONLY solver_structure_only) | ||
FIND_G2O_LIBRARY(G2O_SOLVER_EIGEN solver_eigen) | ||
|
||
# Find the predefined types | ||
FIND_G2O_LIBRARY(G2O_TYPES_DATA types_data) | ||
FIND_G2O_LIBRARY(G2O_TYPES_ICP types_icp) | ||
FIND_G2O_LIBRARY(G2O_TYPES_SBA types_sba) | ||
FIND_G2O_LIBRARY(G2O_TYPES_SCLAM2D types_sclam2d) | ||
FIND_G2O_LIBRARY(G2O_TYPES_SIM3 types_sim3) | ||
FIND_G2O_LIBRARY(G2O_TYPES_SLAM2D types_slam2d) | ||
FIND_G2O_LIBRARY(G2O_TYPES_SLAM3D types_slam3d) | ||
FIND_G2O_LIBRARY(G2O_TYPES_SLAM3D_ADDONS types_slam3d_addons) | ||
|
||
# G2O solvers declared found if we found at least one solver | ||
SET(G2O_SOLVERS_FOUND "NO") | ||
IF(G2O_SOLVER_CHOLMOD OR G2O_SOLVER_CSPARSE OR G2O_SOLVER_DENSE OR G2O_SOLVER_PCG OR G2O_SOLVER_SLAM2D_LINEAR OR G2O_SOLVER_STRUCTURE_ONLY OR G2O_SOLVER_EIGEN) | ||
SET(G2O_SOLVERS_FOUND "YES") | ||
ENDIF(G2O_SOLVER_CHOLMOD OR G2O_SOLVER_CSPARSE OR G2O_SOLVER_DENSE OR G2O_SOLVER_PCG OR G2O_SOLVER_SLAM2D_LINEAR OR G2O_SOLVER_STRUCTURE_ONLY OR G2O_SOLVER_EIGEN) | ||
|
||
# G2O itself declared found if we found the core libraries and at least one solver | ||
SET(G2O_FOUND "NO") | ||
IF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_SOLVERS_FOUND) | ||
SET(G2O_FOUND "YES") | ||
ENDIF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_SOLVERS_FOUND) | ||
|
||
# 加入引用文件和库文件中去 | ||
include_directories(SYSTEM ${G2O_INCLUDE_DIR}) | ||
list(APPEND ALL_TARGET_LIBRARIES | ||
${G2O_TYPES_DATA} | ||
${G2O_CORE_LIBRARY} | ||
${G2O_STUFF_LIBRARY} | ||
${G2O_SOLVER_PCG} | ||
${G2O_SOLVER_CSPARSE} | ||
${G2O_SOLVER_CHOLMOD} | ||
${G2O_TYPES_SLAM3D} | ||
${G2O_TYPES_SLAM3D_ADDONS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ class BackEndFlow { | |
|
||
bool Run(); | ||
|
||
bool ForceOptimize(); | ||
|
||
private: | ||
bool ReadData(); | ||
bool HasData(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...ization/include/lidar_localization/models/graph_optimizer/g2o/edge/edge_se3_priorquat.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* @Description: 姿态的先验边 | ||
* @Author: Ren Qian | ||
* @Date: 2020-03-01 18:05:35 | ||
*/ | ||
#ifndef LIDAR_LOCALIZATION_MODELS_GRAPH_OPTIMIZER_G2O_EDGE_EDGE_SE3_PRIORQUAT_HPP_ | ||
#define LIDAR_LOCALIZATION_MODELS_GRAPH_OPTIMIZER_G2O_EDGE_EDGE_SE3_PRIORQUAT_HPP_ | ||
|
||
#include <g2o/types/slam3d/types_slam3d.h> | ||
#include <g2o/types/slam3d_addons/types_slam3d_addons.h> | ||
|
||
namespace g2o { | ||
class EdgeSE3PriorQuat : public g2o::BaseUnaryEdge<3, Eigen::Quaterniond, g2o::VertexSE3> { | ||
public: | ||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
EdgeSE3PriorQuat() | ||
:g2o::BaseUnaryEdge<3, Eigen::Quaterniond, g2o::VertexSE3>() { | ||
} | ||
|
||
void computeError() override { | ||
const g2o::VertexSE3* v1 = static_cast<const g2o::VertexSE3*>(_vertices[0]); | ||
|
||
Eigen::Quaterniond estimate = Eigen::Quaterniond(v1->estimate().linear()); | ||
if(estimate.w() < 0) { | ||
estimate.coeffs() = -estimate.coeffs(); | ||
} | ||
_error = estimate.vec() - _measurement.vec(); | ||
} | ||
|
||
void setMeasurement(const Eigen::Quaterniond& m) override { | ||
_measurement = m; | ||
if(m.w() < 0.0) { | ||
_measurement.coeffs() = -m.coeffs(); | ||
} | ||
} | ||
|
||
virtual bool read(std::istream& is) override { | ||
Eigen::Quaterniond q; | ||
is >> q.w() >> q.x() >> q.y() >> q.z(); | ||
setMeasurement(q); | ||
for (int i = 0; i < information().rows(); ++i) | ||
for (int j = i; j < information().cols(); ++j) { | ||
is >> information()(i, j); | ||
if (i != j) | ||
information()(j, i) = information()(i, j); | ||
} | ||
return true; | ||
} | ||
|
||
virtual bool write(std::ostream& os) const override { | ||
Eigen::Quaterniond q = _measurement; | ||
os << q.w() << " " << q.x() << " " << q.y() << " " << q.z(); | ||
for (int i = 0; i < information().rows(); ++i) | ||
for (int j = i; j < information().cols(); ++j) | ||
os << " " << information()(i, j); | ||
return os.good(); | ||
} | ||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.