G2o pointer error
1. Problem description I
error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<-1, -1> >::BlockSolver(SlamLinearSolver*&)
And prompt
std::unique_ptr
The reason for the pointer may be a repeated reference.
G2oSolver::G2oSolver()
{
// Step 1: Create a linear solver LinearSolver
SlamLinearSolver *linearSolver = new SlamLinearSolver();
linearSolver->setBlockOrdering(false);
// Step 2: Create the BlockSolver and initialize it with the linear solver defined above
SlamBlockSolver *blockSolver = new SlamBlockSolver(linearSolver);
// Step 3: Create the total solver solver and select one from GN, LM, DogLeg and initialize it with the block solver BlockSolver defined above
g2o::OptimizationAlgorithmLevenberg *solver = new g2o::OptimizationAlgorithmLevenberg(blockSolver);
// Step 4: Create the sparse optimizer (SparseOptimizer)
mOptimizer.setAlgorithm(solver);
}
Modified code:
G2oSolver::G2oSolver()
{
// Step 1: Create a linear solver LinearSolver
SlamLinearSolver *linearSolver = new SlamLinearSolver();
linearSolver->setBlockOrdering(false);
// Step 2: Create the BlockSolver and initialize it with the linear solver defined above
SlamBlockSolver *blockSolver=new SlamBlockSolver(std::unique_ptr<SlamLinearSolver>(linearSolver));
// Step 3: Create the total solver solver and select one from GN, LM, DogLeg and initialize it with the above block solver BlockSolver
g2o::OptimizationAlgorithmLevenberg *solver = new g2o::OptimizationAlgorithmLevenberg(std::unique_ptr<SlamBlockSolver>( blockSolver));
// Step 4: Create the Sparse Optimizer (SparseOptimizer)
mOptimizer.setAlgorithm(solver);
}
2. Problem description II
fatal error: cs.h: No such file or directory
the error is in /usr/local/include/g2o/solvers/csparse/csparse_extension.h:
#include <cs.h>
Install
CSparse
sudo apt-get install libsuitesparse-dev
Find the header file
/usr/include/suitesparse/cs.h
add the header files in CMakeLists.txt:
include_directories("/usr/include/suitesparse")
target_link_libraries(${PROJECT_NAME}_karto_slam_node
${catkin_LIBRARIES}
${Boost_LIBRARIES}
sba
${CERES_LIBRARIES}
gtsam
${G2O_LIBRARIES}
${SUITESPARSE_LIBRARIES}
)
Read More:
- TensorFlow error: AttributeError: module ‘tensorflow_core._api.v2.train’ has no attribute ‘Optimizer‘
- [Solved] Excel solver: Error Log 3_Decimal result after non negative constraint
- [Solved] VINS-MONO: integer_sequence_algorithm.h:64:21: error: ‘integer_sequence’ is not a member of ‘std’
- [Solved] Doris StreamLoad Error: load by MERGE or DELETE need to upgrade table to support batch delete
- How to Solve Excel Error Log 2: Sloving method
- How to Solve Excel Error Log 0: Install Error
- How to Solve QT and PCIe interactive loading setupapi.H error
- Error: Error building SqlSession [How to Solve]
- [How to Fix]Unable to find the requested Boost libraries
- [Solved] 1.fatal error: NvInfer.h: No such file or directory
- [Solved] go cobra Error: required flag(s) “pkg-name” not set
- error: field ‘XXX’ declared as a function [How to Solve]
- C++ Use of deleted function error
- [Solved] iperf Analyze Error: unable to create a new stream: Invalid argument
- [Solved] fatal error: Eigen/Geometry: No such file or directory
- Clion new method shows undefined reference to solution
- [Solved] target_link_libraries error: a missing vtable usually means the first non-inline virtual member function has no definition.
- [Solved] MIT cheetah make error: ‘ioctl’ was not declared in this scope
- C++:error C2872: ‘byte‘: ambiguous symbol [How to Solve]
- [Solved] error: external/googletest/googletest: MODULE.TARGET.STATIC_LIBRARIES.libgtest already defined