HybridValues.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 #include <gtsam/inference/Key.h>
22 #include <gtsam/nonlinear/Values.h>
23 
24 namespace gtsam {
25 
26 /* ************************************************************************* */
28  : continuous_(cv), discrete_(dv) {}
29 
30 /* ************************************************************************* */
32  const Values& v)
33  : continuous_(cv), discrete_(dv), nonlinear_(v) {}
34 
35 /* ************************************************************************* */
36 void HybridValues::print(const std::string& s,
37  const KeyFormatter& keyFormatter) const {
38  std::cout << s << ": \n";
39  // print continuous components
40  continuous_.print(" Continuous", keyFormatter);
41  // print discrete components
42  discrete_.print(" Discrete", keyFormatter);
43  // print nonlinear components
44  nonlinear_.print(" Nonlinear", keyFormatter);
45 }
46 
47 /* ************************************************************************* */
48 bool HybridValues::equals(const HybridValues& other, double tol) const {
49  return continuous_.equals(other.continuous_, tol) &&
50  discrete_.equals(other.discrete_, tol);
51 }
52 
53 /* ************************************************************************* */
55 
56 /* ************************************************************************* */
58 
59 /* ************************************************************************* */
60 const Values& HybridValues::nonlinear() const { return nonlinear_; }
61 
62 /* ************************************************************************* */
64 
65 /* ************************************************************************* */
67  return (discrete_.find(j) != discrete_.end());
68 }
69 
70 /* ************************************************************************* */
72 
73 /* ************************************************************************* */
76 }
77 
78 /* ************************************************************************* */
81  return updated;
82 }
83 
84 /* ************************************************************************* */
87 }
88 
89 /* ************************************************************************* */
91 
92 /* ************************************************************************* */
95 }
96 
97 /* ************************************************************************* */
99  discrete_[j] = value;
100 }
101 
102 /* ************************************************************************* */
105  return *this;
106 }
107 
108 /* ************************************************************************* */
111  return *this;
112 }
113 
114 /* ************************************************************************* */
117  return *this;
118 }
119 
120 /* ************************************************************************* */
122  continuous_.insert(values.continuous());
123  discrete_.insert(values.discrete());
124  nonlinear_.insert(values.nonlinear());
125  return *this;
126 }
127 
128 /* ************************************************************************* */
130 
131 /* ************************************************************************* */
132 size_t& HybridValues::atDiscrete(Key j) { return discrete_.at(j); }
133 
134 /* ************************************************************************* */
137  return *this;
138 }
139 
140 /* ************************************************************************* */
143  return *this;
144 }
145 
146 /* ************************************************************************* */
148  continuous_.update(values.continuous());
149  discrete_.update(values.discrete());
150  return *this;
151 }
152 
153 /* ************************************************************************* */
156  for (const auto& key : keys) {
157  measurements.insert(key, continuous_.at(key));
158  }
159  return measurements;
160 }
161 
162 /* ************************************************************************* */
163 std::string HybridValues::html(const KeyFormatter& keyFormatter) const {
164  std::stringstream ss;
165  ss << this->continuous_.html(keyFormatter);
166  ss << this->discrete_.html(keyFormatter);
167  return ss.str();
168 }
169 
170 } // namespace gtsam
gtsam::VectorValues::print
void print(const std::string &str="VectorValues", const KeyFormatter &formatter=DefaultKeyFormatter) const
Definition: VectorValues.cpp:153
gtsam::HybridValues::exists
bool exists(Key j)
Check whether a variable with key j exists.
Definition: HybridValues.cpp:74
gtsam::DiscreteValues::print
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print required by Testable.
Definition: DiscreteValues.cpp:30
gtsam::Values::exists
bool exists(Key j) const
Definition: Values.cpp:93
gtsam::HybridValues
Definition: HybridValues.h:37
s
RealScalar s
Definition: level1_cplx_impl.h:126
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
gtsam::HybridValues::retract
HybridValues retract(const VectorValues &delta) const
Definition: HybridValues.cpp:79
gtsam::VectorValues::insert
iterator insert(const std::pair< Key, Vector > &key_value)
Definition: VectorValues.cpp:90
gtsam::VectorValues::html
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Output as a html table.
Definition: VectorValues.cpp:390
gtsam::VectorValues::at
Vector & at(Key j)
Definition: VectorValues.h:142
relicense.updated
updated
Definition: relicense.py:62
gtsam::HybridValues::update
HybridValues & update(const VectorValues &values)
Definition: HybridValues.cpp:135
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
gtsam::HybridValues::equals
bool equals(const HybridValues &other, double tol=1e-9) const
equals required by Testable for unit testing
Definition: HybridValues.cpp:48
gtsam::HybridValues::existsVector
bool existsVector(Key j)
Check whether a variable with key j exists in VectorValues.
Definition: HybridValues.cpp:63
gtsam::HybridValues::existsNonlinear
bool existsNonlinear(Key j)
Check whether a variable with key j exists in values.
Definition: HybridValues.cpp:71
gtsam::DiscreteValues::html
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const
Output as a html table.
Definition: DiscreteValues.cpp:105
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
gtsam::HybridValues::continuous
const VectorValues & continuous() const
Return the multi-dimensional vector values.
Definition: HybridValues.cpp:54
ss
static std::stringstream ss
Definition: testBTree.cpp:31
Key.h
gtsam::Values::retract
Values retract(const VectorValues &delta) const
Definition: Values.cpp:98
gtsam.examples.PlanarManipulatorExample.delta
def delta(g0, g1)
Definition: PlanarManipulatorExample.py:45
gtsam::VectorValues
Definition: VectorValues.h:74
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
gtsam::KeyFormatter
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
gtsam::VectorValues::update
VectorValues & update(const VectorValues &values)
Definition: VectorValues.cpp:100
gtsam::DiscreteValues::update
DiscreteValues & update(const DiscreteValues &values)
Definition: DiscreteValues.cpp:64
gtsam::HybridValues::nonlinear
const Values & nonlinear() const
Return the nonlinear values.
Definition: HybridValues.cpp:60
gtsam::HybridValues::existsDiscrete
bool existsDiscrete(Key j)
Check whether a variable with key j exists in DiscreteValues.
Definition: HybridValues.cpp:66
gtsam::HybridValues::nonlinear_
Values nonlinear_
Definition: HybridValues.h:46
gtsam::HybridValues::insert
void insert(Key j, const Vector &value)
Definition: HybridValues.cpp:85
VectorValues.h
Factor Graph Values.
gtsam::HybridValues::HybridValues
HybridValues()=default
Default constructor creates an empty HybridValues.
key
const gtsam::Symbol key('X', 0)
gtsam::HybridValues::continuous_
VectorValues continuous_
Definition: HybridValues.h:40
gtsam::HybridValues::at
Vector & at(Key j)
Definition: HybridValues.cpp:129
gtsam::DiscreteValues::equals
bool equals(const DiscreteValues &x, double tol=1e-9) const
equals required by Testable for unit testing.
Definition: DiscreteValues.cpp:39
gtsam::Values::print
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Definition: Values.cpp:66
gtsam::VectorValues::equals
bool equals(const VectorValues &x, double tol=1e-9) const
Definition: VectorValues.cpp:161
gtsam
traits
Definition: SFMdata.h:40
gtsam::HybridValues::atDiscrete
size_t & atDiscrete(Key j)
Definition: HybridValues.cpp:132
DiscreteValues.h
estimation_fixture::measurements
std::vector< double > measurements
Definition: testHybridEstimation.cpp:51
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
gtsam::Values
Definition: Values.h:65
gtsam::VectorValues::insert_or_assign
void insert_or_assign(Key j, const Vector &value)
Definition: VectorValues.h:222
gtsam::HybridValues::discrete
const DiscreteValues & discrete() const
Return the discrete values.
Definition: HybridValues.cpp:57
gtsam::DiscreteValues::insert
std::pair< iterator, bool > insert(const value_type &value)
Definition: DiscreteValues.h:68
gtsam::Values::insert
void insert(Key j, const Value &val)
Definition: Values.cpp:155
gtsam::VectorValues::exists
bool exists(Key j) const
Definition: VectorValues.h:136
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::HybridValues::continuousSubset
VectorValues continuousSubset(const KeyVector &keys) const
Extract continuous values with given keys.
Definition: HybridValues.cpp:154
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::HybridValues::insert_or_assign
void insert_or_assign(Key j, const Vector &value)
insert_or_assign() , similar to Values.h
Definition: HybridValues.cpp:93
gtsam::HybridValues::print
void print(const std::string &s="HybridValues", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print required by Testable for unit testing
Definition: HybridValues.cpp:36
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
HybridValues.h
test_callbacks.value
value
Definition: test_callbacks.py:160
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::HybridValues::discrete_
DiscreteValues discrete_
Definition: HybridValues.h:43
gtsam::HybridValues::html
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Output as a html table.
Definition: HybridValues.cpp:163
Values.h
A non-templated config holding any types of Manifold-group elements.


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:26