29 using namespace gtsam;
39 return K.uncalibrate(p, Dcal, Dp);
70 const Point3 somePoint(1, 2, 3);
72 std::vector<Point3_> pointExpressions = createUnknowns<Point3>(10,
'p', 1);
94 using namespace unary;
101 using namespace unary;
108 using namespace unary;
118 enum {dimension = 3};
121 inline static Class
Identity() {
return Class(0,0,0); }
128 void print(
const string&
s)
const { cout << s << *
this << endl;}
147 values.
insert(key, Class(3, 4, 5));
150 std::map<Key, int> map;
155 std::vector<Matrix>
H(1);
156 double actual = norm_.
value(values,
H);
159 const double norm =
sqrt(3*3 + 4*4 + 5*5);
162 expected << 3.0 / norm, 4.0 / norm, 5.0 / norm;
196 map<Key, int> actual,
expected{{1, 6}, {2, 3}};
204 typedef internal::BinaryExpression<Point3, Pose3, Point3> Binary;
205 size_t expectedTraceSize =
sizeof(Binary::Record);
233 map<Key, int> actual,
expected{{1, 6}, {2, 3}, {3, 5}};
241 typedef internal::BinaryExpression<Point3, Pose3, Point3> Binary1;
244 typedef internal::UnaryExpression<Point2, Point3> Unary;
250 typedef internal::BinaryExpression<Point2, Cal3_S2, Point2> Binary2;
316 return R1 * (R2 *
R3);
335 const set<Key> expected_keys{key};
338 map<Key, int> actual_dims, expected_dims {{
key, 3}};
339 expr.
dims(actual_dims);
340 EXPECT(actual_dims == expected_dims)
343 std::map<Key, int> map;
355 std::vector<Matrix>
H(1);
366 const set<Key> expected_keys{key};
369 map<Key, int> actual_dims, expected_dims {{
key, 3}};
370 sum_.
dims(actual_dims);
371 EXPECT(actual_dims == expected_dims)
374 std::map<Key, int> map;
386 std::vector<Matrix>
H(1);
408 std::vector<Matrix>
H(1);
432 std::vector<Matrix>
H(1);
441 const Double_ sum_ = norm_ + norm_;
450 std::vector<Matrix>
H(1);
461 map<Key, int> actual_dims, expected_dims = {{
key1, 3}, {
key2, 3}};
462 norm_.
dims(actual_dims);
463 EXPECT(actual_dims == expected_dims)
473 std::vector<Matrix>
H(2);
484 map<Key, int> actual_dims, expected_dims {{
key1, 3}, {
key2, 3}};
485 weighted_sum_.
dims(actual_dims);
486 EXPECT(actual_dims == expected_dims)
498 std::vector<Matrix>
H(2);
506 const Vector3 p = Vector3::Random(),
q = Vector3::Random();
511 set<Key> expected_keys = {0, 1};
515 std::vector<Matrix>
H(2);
516 EXPECT(assert_equal<Vector3>(p -
q, expression.
value(values,
H)))
524 const std::function<Vector3(Point3)>
f = [](
const Point3&
p) {
return (
Vector3)
p; };
536 std::vector<Matrix>
H(1);
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
const gtsam::Symbol key('X', 0)
Expression< Point3 > Point3_
bool equals(const Class &q, double tol) const
Concept check for values that can be used in unit tests.
static int runAllTests(TestResult &result)
Expression< T > linearExpression(const std::function< T(A)> &f, const Expression< A > &expression, const Eigen::Matrix< double, traits< T >::dimension, traits< A >::dimension > &dTdA)
TEST(Expression, Constant)
VectorSpace provides both Testable and VectorSpaceTraits.
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Expression< Pose3 > Pose3_
Rot2 R(Rot2::fromAngle(0.1))
const set< Key > expected
double f2(const Vector2 &x)
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
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
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
T upAligned(T value, unsigned requiredAlignment=TraceAlignment)
void print(const string &s) const
Base class for all pinhole cameras.
Rot3 composeThree(const Rot3 &R1, const Rot3 &R2, const Rot3 &R3, OptionalJacobian< 3, 3 > H1, OptionalJacobian< 3, 3 > H2, OptionalJacobian< 3, 3 > H3)
const Symbol key1('v', 1)
static const NavState kIdentity
#define EXPECT(condition)
T & upAlign(T &value, unsigned requiredAlignment=TraceAlignment)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DEVICE_FUNC const Scalar & q
static const Point3 point2(-0.08, 0.08, 0.0)
Point3_ p_cam(x, &Pose3::transformTo, p)
static sharedNode Leaf(Key key, const SymbolicFactorGraph &factors)
Expression< Point2 > uv_hat(uncalibrate< Cal3_S2 >, K, projection)
Expression< Cal3_S2 > K(3)
Matrix< Scalar, Dynamic, Dynamic > C
#define LONGS_EQUAL(expected, actual)
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
std::set< Key > keys() const
Return keys that play in this expression.
const Vector3 & vector() const
#define EXPECT_LONGS_EQUAL(expected, actual)
Expression< Point2 > projection(f, p_cam)
double norm(OptionalJacobian< 1, 3 > H={}) const
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
T value(const Values &values, std::vector< Matrix > *H=nullptr) const
Return value and optional derivatives, reverse AD version Notes: this is not terribly efficient...
Point2(* Project)(const Point3 &, OptionalJacobian< 2, 3 >)
double f3(double x1, double x2)
void insert(Key j, const Value &val)
Line3 transformTo(const Pose3 &wTc, const Line3 &wL, OptionalJacobian< 4, 6 > Dpose, OptionalJacobian< 4, 4 > Dline)
double norm3(const Point3 &p, OptionalJacobian< 1, 3 > H)
Distance of the point from the origin, with Jacobian.
Jet< T, N > sqrt(const Jet< T, N > &f)
Point3_ pointExpression(1)
const Point3 point1(3.0, 4.0, 2.0)
void dims(std::map< Key, int > &map) const
Return dimensions for each argument, as a map.
std::uint64_t Key
Integer nonlinear key type.
double doubleF(const Pose3 &pose, const Point3 &point, OptionalJacobian< 1, 6 > H1, OptionalJacobian< 1, 3 > H2)
The most common 5DOF 3D->2D calibration.
Point2 uncalibrate(const CAL &K, const Point2 &p, OptionalJacobian< 2, 5 > Dcal, OptionalJacobian< 2, 2 > Dp)
size_t traceSize() const
Return size needed for memory buffer in traceExecution.
const Symbol key2('v', 2)
Expression< Vector3 > Vector3_