ceres_solver.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Simbe Robotics, Inc.
3  * Author: Steve Macenski (stevenmacenski@gmail.com)
4  */
5 
6 #ifndef KARTO_CERESSOLVER_H
7 #define KARTO_CERESSOLVER_H
8 
9 #include <ros/ros.h>
10 #include <std_srvs/Empty.h>
11 
12 #include <vector>
13 #include <unordered_map>
14 #include <utility>
15 
16 #include <karto_sdk/Mapper.h>
17 #include <ceres/ceres.h>
18 #include <ceres/local_parameterization.h>
19 #include <cmath>
20 #include <math.h>
21 
22 #include "../include/slam_toolbox/toolbox_types.hpp"
23 #include "ceres_utils.h"
24 
25 namespace solver_plugins
26 {
27 
28 using namespace ::toolbox_types;
29 
31 {
32 public:
33  CeresSolver();
34  virtual ~CeresSolver();
35 
36 public:
37  virtual const karto::ScanSolver::IdPoseVector& GetCorrections() const; //Get corrected poses after optimization
38  virtual void Compute(); //Solve
39  virtual void Clear(); //Resets the corrections
40  virtual void Reset(); //Resets the solver plugin clean
41 
42  virtual void AddNode(karto::Vertex<karto::LocalizedRangeScan>* pVertex); //Adds a node to the solver
43  virtual void AddConstraint(karto::Edge<karto::LocalizedRangeScan>* pEdge); //Adds a constraint to the solver
44  virtual std::unordered_map<int, Eigen::Vector3d>* getGraph(); //Get graph stored
45  virtual void RemoveNode(kt_int32s id); //Removes a node from the solver correction table
46  virtual void RemoveConstraint(kt_int32s sourceId, kt_int32s targetId); // Removes constraints from the optimization problem
47 
48  virtual void ModifyNode(const int& unique_id, Eigen::Vector3d pose); // change a node's pose
49  virtual void GetNodeOrientation(const int& unique_id, double& pose); // get a node's current pose yaw
50 
51 private:
52  // karto
54 
55  // ceres
56  ceres::Solver::Options options_;
57  ceres::Problem::Options options_problem_;
58  ceres::LossFunction* loss_function_;
59  ceres::Problem* problem_;
60  ceres::LocalParameterization* angle_local_parameterization_;
62 
63  // graph
64  std::unordered_map<int, Eigen::Vector3d>* nodes_;
65  std::unordered_map<size_t, ceres::ResidualBlockId>* blocks_;
66  std::unordered_map<int, Eigen::Vector3d>::iterator first_node_;
67  boost::mutex nodes_mutex_;
68 };
69 
70 }
71 
72 #endif
solver_plugins::CeresSolver::RemoveNode
virtual void RemoveNode(kt_int32s id)
Definition: ceres_solver.cpp:355
karto::ScanSolver
Definition: Mapper.h:947
solver_plugins::CeresSolver::blocks_
std::unordered_map< size_t, ceres::ResidualBlockId > * blocks_
Definition: ceres_solver.hpp:65
toolbox_types
Definition: toolbox_types.hpp:36
solver_plugins::CeresSolver::GetCorrections
virtual const karto::ScanSolver::IdPoseVector & GetCorrections() const
Definition: ceres_solver.cpp:229
solver_plugins::CeresSolver::nodes_mutex_
boost::mutex nodes_mutex_
Definition: ceres_solver.hpp:67
solver_plugins::CeresSolver::Compute
virtual void Compute()
Definition: ceres_solver.cpp:170
ros.h
solver_plugins::CeresSolver::debug_logging_
bool debug_logging_
Definition: ceres_solver.hpp:61
solver_plugins::CeresSolver::first_node_
std::unordered_map< int, Eigen::Vector3d >::iterator first_node_
Definition: ceres_solver.hpp:66
solver_plugins::CeresSolver::getGraph
virtual std::unordered_map< int, Eigen::Vector3d > * getGraph()
Definition: ceres_solver.cpp:436
ceres_utils.h
solver_plugins::CeresSolver::AddConstraint
virtual void AddConstraint(karto::Edge< karto::LocalizedRangeScan > *pEdge)
Definition: ceres_solver.cpp:299
solver_plugins::CeresSolver::ModifyNode
virtual void ModifyNode(const int &unique_id, Eigen::Vector3d pose)
Definition: ceres_solver.cpp:410
solver_plugins::CeresSolver::corrections_
karto::ScanSolver::IdPoseVector corrections_
Definition: ceres_solver.hpp:53
solver_plugins::CeresSolver::~CeresSolver
virtual ~CeresSolver()
Definition: ceres_solver.cpp:152
kt_int32s
int32_t kt_int32s
Definition: Types.h:51
solver_plugins::CeresSolver::nodes_
std::unordered_map< int, Eigen::Vector3d > * nodes_
Definition: ceres_solver.hpp:64
karto::ScanSolver::IdPoseVector
std::vector< std::pair< kt_int32s, Pose2 > > IdPoseVector
Definition: Mapper.h:953
solver_plugins::CeresSolver::Clear
virtual void Clear()
Definition: ceres_solver.cpp:236
solver_plugins::CeresSolver::RemoveConstraint
virtual void RemoveConstraint(kt_int32s sourceId, kt_int32s targetId)
Definition: ceres_solver.cpp:384
solver_plugins::CeresSolver::CeresSolver
CeresSolver()
Definition: ceres_solver.cpp:18
solver_plugins::CeresSolver::angle_local_parameterization_
ceres::LocalParameterization * angle_local_parameterization_
Definition: ceres_solver.hpp:60
solver_plugins::CeresSolver::GetNodeOrientation
virtual void GetNodeOrientation(const int &unique_id, double &pose)
Definition: ceres_solver.cpp:424
solver_plugins::CeresSolver::options_
ceres::Solver::Options options_
Definition: ceres_solver.hpp:56
solver_plugins::CeresSolver::AddNode
virtual void AddNode(karto::Vertex< karto::LocalizedRangeScan > *pVertex)
Definition: ceres_solver.cpp:275
solver_plugins::CeresSolver::loss_function_
ceres::LossFunction * loss_function_
Definition: ceres_solver.hpp:58
solver_plugins::CeresSolver::Reset
virtual void Reset()
Definition: ceres_solver.cpp:243
karto::Vertex< karto::LocalizedRangeScan >
solver_plugins::CeresSolver::problem_
ceres::Problem * problem_
Definition: ceres_solver.hpp:59
Mapper.h
solver_plugins::CeresSolver
Definition: ceres_solver.hpp:30
solver_plugins
Definition: ceres_solver.cpp:14
solver_plugins::CeresSolver::options_problem_
ceres::Problem::Options options_problem_
Definition: ceres_solver.hpp:57
solver_plugins::CeresSolver::was_constant_set_
bool was_constant_set_
Definition: ceres_solver.hpp:61
karto::Edge
Definition: Mapper.h:247


slam_toolbox
Author(s): Steve Macenski
autogenerated on Thu Jan 11 2024 03:37:55