OKVIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParameterBlock.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2  * OKVIS - Open Keyframe-based Visual-Inertial SLAM
3  * Copyright (c) 2015, Autonomous Systems Lab / ETH Zurich
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of Autonomous Systems Lab / ETH Zurich nor the names of
14  * its contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Created on: Aug 30, 2013
30  * Author: Stefan Leutenegger (s.leutenegger@imperial.ac.uk)
31  *********************************************************************************/
32 
39 #ifndef INCLUDE_OKVIS_CERES_PARAMETERBLOCK_HPP_
40 #define INCLUDE_OKVIS_CERES_PARAMETERBLOCK_HPP_
41 
42 #include <stdio.h>
43 #include <iostream>
44 #include <stdint.h>
45 #include "ceres/ceres.h"
46 
48 namespace okvis {
50 namespace ceres {
51 
54  public:
55 
58  : id_(0),
59  fixed_(false),
61  }
62 
64  virtual ~ParameterBlock() {
65  }
66 
69 
72  void setId(uint64_t id) {
73  id_ = id;
74  }
75 
78  virtual void setParameters(const double* parameters) = 0;
79 
82  void setFixed(bool fixed) {
83  fixed_ = fixed;
84  }
85 
87 
90 
92  virtual double* parameters() = 0;
93 
95  virtual const double* parameters() const = 0;
96 
98  uint64_t id() const {
99  return id_;
100  }
102  virtual size_t dimension() const = 0;
103 
105  virtual size_t minimalDimension() const = 0;
106 
108  bool fixed() const {
109  return fixed_;
110  }
111 
113  // minimal internal parameterization
120  virtual void plus(const double* x0, const double* Delta_Chi,
121  double* x0_plus_Delta) const = 0;
122 
126  virtual void plusJacobian(const double* x0, double* jacobian) const = 0;
127 
133  virtual void minus(const double* x0, const double* x0_plus_Delta,
134  double* Delta_Chi) const = 0;
135 
140  virtual void liftJacobian(const double* x0, double* jacobian) const = 0;
141 
144 
149  const ::ceres::LocalParameterization* localParameterizationPtr) {
151  }
155  virtual const ::ceres::LocalParameterization* localParameterizationPtr() const {
157  }
160  virtual std::string typeInfo() const = 0;
161 
162  protected:
164  uint64_t id_;
166  bool fixed_;
168  const ::ceres::LocalParameterization* localParameterizationPtr_;
169 };
170 
171 } // namespace ceres
172 } // namespace okvis
173 
174 #endif /* INCLUDE_OKVIS_CERES_PARAMETERBLOCK_HPP_ */
virtual void minus(const double *x0, const double *x0_plus_Delta, double *Delta_Chi) const =0
Computes the minimal difference between a variable x and a perturbed variable x_plus_delta.
virtual void plus(const double *x0, const double *Delta_Chi, double *x0_plus_Delta) const =0
Generalization of the addition operation, x_plus_delta = Plus(x, delta) with the condition that Plus(...
virtual size_t dimension() const =0
Get the dimension of the parameter block.
virtual ~ParameterBlock()
Trivial destructor.
Definition: ParameterBlock.hpp:64
virtual void plusJacobian(const double *x0, double *jacobian) const =0
The jacobian of Plus(x, delta) w.r.t delta at delta = 0.
const ::ceres::LocalParameterization * localParameterizationPtr_
The local parameterisation object to use.
Definition: ParameterBlock.hpp:168
virtual std::string typeInfo() const =0
Return parameter block type as string.
virtual void setLocalParameterizationPtr(const ::ceres::LocalParameterization *localParameterizationPtr)
Set which local parameterisation object to use.
Definition: ParameterBlock.hpp:148
ParameterBlock()
Default constructor, assumes not fixed and no local parameterisation.
Definition: ParameterBlock.hpp:57
uint64_t id() const
Get parameter block ID.
Definition: ParameterBlock.hpp:98
virtual double * parameters()=0
Get parameter values.
uint64_t id_
ID of the parameter block.
Definition: ParameterBlock.hpp:164
virtual size_t minimalDimension() const =0
The dimension of the internal parameterisation (minimal representation).
bool fixed() const
Whether or not this is optimised at all.
Definition: ParameterBlock.hpp:108
virtual void setParameters(const double *parameters)=0
Directly set values of this parameter block.
virtual void liftJacobian(const double *x0, double *jacobian) const =0
Computes the Jacobian from minimal space to naively overparameterised space as used by ceres...
void setId(uint64_t id)
Set parameter block ID.
Definition: ParameterBlock.hpp:72
void setFixed(bool fixed)
Whether or not this should be optimised at all.
Definition: ParameterBlock.hpp:82
virtual const ::ceres::LocalParameterization * localParameterizationPtr() const
The local parameterisation object to use.
Definition: ParameterBlock.hpp:155
bool fixed_
Whether or not this should be optimised at all (ceres::problem::setFixed)
Definition: ParameterBlock.hpp:166
Base class providing the interface for parameter blocks.
Definition: ParameterBlock.hpp:53