21 #include <boost/assign/list_of.hpp> 22 #include <boost/assign/std/list.hpp> 23 #include <boost/assign/std/set.hpp> 33 using namespace gtsam;
37 const SharedDiagonal chainNoise = noiseModel::Isotropic::Sigma(1, 0.5);
49 return boost::make_shared<GaussianBayesTreeClique>(
50 boost::make_shared<GaussianConditional>(conditional));
53 template<
typename CHILDREN>
58 boost::make_shared<GaussianBayesTreeClique>(
59 boost::make_shared<GaussianConditional>(conditional));
60 clique->children.assign(children.begin(), children.end());
61 for(
typename CHILDREN::const_iterator child = children.begin(); child != children.end(); ++child)
62 (*child)->parent_ = clique;
99 pair_list_of<Key, Matrix>(
x3, (Matrix21() << 2., 0.).finished())(
100 x4, (Matrix21() << 2., 2.).finished()), 2,
Vector2(2., 2.)),
104 pair_list_of<Key, Matrix>(
x2,
105 (Matrix21() << -2. *
sqrt(2.), 0.).finished())(x1,
106 (Matrix21() << -
sqrt(2.), -
sqrt(2.)).finished())(
x3,
107 (Matrix21() << -
sqrt(2.),
sqrt(2.)).finished()), 2,
108 (
Vector(2) << -2. *
sqrt(2.), 0.).finished())))));
133 (12, (
Matrix(3,2) << 0.3171, 0.4387, 0.9502, 0.3816, 0, 0.7655).finished()),
134 2,
Vector3(0.2638, 0.1455, 0.1361)), list_of
136 (10, (
Matrix(3,2) << 0.4456, 0.7547, 0.6463, 0.2760, 0, 0.6797).finished())
137 (11, (
Matrix(3,1) << 0.6551, 0.1626, 0.1190).finished())
138 (12, (
Matrix(3,2) << 0.4984, 0.5853, 0.9597, 0.2238, 0.3404, 0.7513).finished()),
139 2,
Vector3(0.4314, 0.9106, 0.1818))))
141 (8, (
Matrix(3,2) << 0.8909, 0.1386, 0.9593, 0.1493, 0, 0.2575).finished())
142 (11, (
Matrix(3,1) << 0.8407, 0.2543, 0.8143).finished()),
143 2,
Vector3(0.3998, 0.2599, 0.8001)), list_of
145 (6, (
Matrix(3,2) << 0.4733, 0.1966, 0.3517, 0.2511, 0.8308, 0.0).finished())
151 (7, (
Matrix(3,1) << 0.5853, 0.5497, 0.9172).finished())
152 (8, (
Matrix(3,2) << 0.2858, 0.3804, 0.7572, 0.5678, 0.7537, 0.0759).finished()),
153 2,
Vector3(0.8173, 0.8687, 0.0844)), list_of
155 (4, (
Matrix(3,2) << 0.9340, 0.4694, 0.1299, 0.0119, 0, 0.3371).finished())
156 (6, (
Matrix(3,2) << 0.1622, 0.5285, 0.7943, 0.1656, 0.3112, 0.6020).finished()),
157 2,
Vector3(0.9619, 0.0046, 0.7749))))
159 (2, (
Matrix(3,2) << 0.7482, 0.2290, 0.4505, 0.9133, 0, 0.1524).finished())
160 (5, (
Matrix(3,1) << 0.8258, 0.5383, 0.9961).finished()),
161 2,
Vector3(0.0782, 0.4427, 0.1067))))))))));
164 Matrix expectedCov = (
Matrix(1,1) << 236.5166).finished();
172 Matrix actualCov = (actualA.transpose() * actualA).
inverse();
179 expectedCov = (
Matrix(2,2) <<
181 2886.2, 8471.2).finished();
188 actualA = actualJacobianQR.
getA(actualJacobianQR.
begin());
189 actualCov = (actualA.transpose() * actualA).
inverse();
197 return 0.5 * (Rd.first * values - Rd.second).squaredNorm();
207 pair_list_of<Key, Matrix>
228 0.0,54.0).finished()),
229 3, (
Vector(6) << 29.0,30.0,39.0,40.0,49.0,50.0).finished()), list_of
231 pair_list_of<Key, Matrix>
241 0.0,20.0).finished())
246 23.0,24.0).finished())
256 27.0,28.0).finished()),
257 2, (
Vector(4) << 1.0,2.0,15.0,16.0).finished())))));
260 Matrix hessian = numericalHessian<Vector10>(
261 boost::bind(&computeError, bt, _1), Vector10::Zero());
264 Vector gradient = numericalGradient<Vector10>(
265 boost::bind(&computeError, bt, _1), Vector10::Zero());
270 Vector denseMatrixGradient = -augmentedHessian.col(10).segment(0,10);
274 double step = -gradient.squaredNorm() / (gradient.transpose() * hessian * gradient)(0);
279 (0,
Vector2(0.000129034, 0.000688183))
280 (1,
Vector2(0.0109679, 0.0253767))
281 (2,
Vector2(0.0680441, 0.114496))
282 (3,
Vector2(0.16125, 0.241294))
283 (4,
Vector2(0.300134, 0.423233));
296 EXPECT(newError < origError);
306 fg +=
JacobianFactor(x1, 10 * I_2x2, -1.0 * Vector::Ones(2), unit2);
318 double expectedDeterminant =
sqrt(H.determinant());
319 double actualDeterminant = bt->determinant();
def step(data, isam, result, truth, currPoseIndex)
VectorValues optimizeGradientSearch() const
static int runAllTests(TestResult &result)
boost::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType=boost::none, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex=boost::none) const
TEST(GaussianBayesTree, eliminate)
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Some functions to compute numerical derivatives.
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
void insertRoot(const sharedClique &subtree)
sharedConditional marginalFactor(Key j, const Eliminate &function=EliminationTraitsType::DefaultEliminate) const
double error(const VectorValues &x) const
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
const_iterator begin() const
#define EXPECT(condition)
Matrix augmentedHessian(const Ordering &ordering) const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Conditional Gaussian Base class.
constABlock getA(const_iterator variable) const
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
std::pair< Matrix, Vector > jacobian(const Ordering &ordering) const
#define LONGS_EQUAL(expected, actual)
std::pair< Matrix, Vector > hessian(const Ordering &ordering) const
static SharedNoiseModel unit2(noiseModel::Unit::Create(2))
noiseModel::Diagonal::shared_ptr SharedDiagonal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
#define EXPECT_LONGS_EQUAL(expected, actual)
const KeyVector & keys() const
Access the factor's involved variable keys.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
std::pair< GaussianConditional::shared_ptr, JacobianFactor::shared_ptr > EliminateQR(const GaussianFactorGraph &factors, const Ordering &keys)
Gaussian Bayes Tree, the result of eliminating a GaussianJunctionTree.
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
std::uint64_t Key
Integer nonlinear key type.
boost::shared_ptr< This > shared_ptr