28 #include <boost/assign/list_of.hpp> 29 using boost::assign::list_of;
30 using boost::assign::map_list_of;
33 using namespace gtsam;
43 return K.uncalibrate(p, Dcal, Dp);
75 std::vector<Point3_> points = createUnknowns<Point3>(10,
'p', 1);
96 using namespace unary;
101 using namespace unary;
109 using namespace unary;
116 enum {dimension = 3};
119 inline static Class
identity() {
return Class(0,0,0); }
126 void print(
const string&
s)
const { cout << s << *
this << endl;}
141 values.
insert(67, Class(3, 4, 5));
144 std::map<Key, int> map;
149 std::vector<Matrix>
H(1);
150 double actual = norm_.
value(values, H);
155 expected << 3.0 /
sqrt(50.0), 4.0 /
sqrt(50.0), 5.0 /
sqrt(50.0);
189 map<Key, int> actual,
expected = map_list_of<Key, int>(1, 6)(2, 3);
191 EXPECT(actual == expected);
197 typedef internal::BinaryExpression<Point3, Pose3, Point3> Binary;
198 size_t expectedTraceSize =
sizeof(Binary::Record);
219 set<Key>
expected = list_of(1)(2)(3);
226 map<Key, int> actual,
expected = map_list_of<Key, int>(1, 6)(2, 3)(3, 5);
228 EXPECT(actual == expected);
234 typedef internal::BinaryExpression<Point3, Pose3, Point3> Binary1;
237 typedef internal::UnaryExpression<Point2, Point3> Unary;
243 typedef internal::BinaryExpression<Point2, Cal3_S2, Point2> Binary2;
295 return R1 * (R2 *
R3);
304 set<Key>
expected = list_of(1)(2)(3);
313 set<Key> expected_keys = list_of(key);
316 map<Key, int> actual_dims, expected_dims = map_list_of<Key, int>(
key, 3);
317 expr.
dims(actual_dims);
318 EXPECT(actual_dims == expected_dims);
321 std::map<Key, int> map;
333 std::vector<Matrix>
H(1);
343 set<Key> expected_keys = list_of(key);
346 map<Key, int> actual_dims, expected_dims = map_list_of<Key, int>(
key, 3);
347 sum_.
dims(actual_dims);
348 EXPECT(actual_dims == expected_dims);
351 std::map<Key, int> map;
363 std::vector<Matrix>
H(1);
384 std::vector<Matrix>
H(1);
407 std::vector<Matrix>
H(1);
416 const Double_ sum_ = norm_ + norm_;
425 std::vector<Matrix>
H(1);
436 map<Key, int> actual_dims, expected_dims = map_list_of<Key, int>(
key1, 3)(key2, 3);
437 norm_.
dims(actual_dims);
438 EXPECT(actual_dims == expected_dims);
448 std::vector<Matrix>
H(2);
459 map<Key, int> actual_dims, expected_dims = map_list_of<Key, int>(
key1, 3)(key2, 3);
460 weighted_sum_.
dims(actual_dims);
461 EXPECT(actual_dims == expected_dims);
472 std::vector<Matrix>
H(2);
480 const Vector3 p = Vector3::Random(),
q = Vector3::Random();
485 set<Key> expected_keys = {0, 1};
489 std::vector<Matrix>
H(2);
490 EXPECT(assert_equal<Vector3>(p -
q, expression.
value(values, H)));
498 const boost::function<Vector3(Point3)>
f = [](
const Point3&
p) {
return (
Vector3)
p; };
510 std::vector<Matrix>
H(1);
Expression< Point3 > Point3_
Concept check for values that can be used in unit tests.
static int runAllTests(TestResult &result)
TEST(Expression, Constant)
VectorSpace provides both Testable and VectorSpaceTraits.
void insert(Key j, const Value &val)
double norm(OptionalJacobian< 1, 3 > H=boost::none) const
Expression< Pose3 > Pose3_
Rot2 R(Rot2::fromAngle(0.1))
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
double f2(const Vector2 &x)
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
Matrix< SCALARB, Dynamic, Dynamic > B
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
T upAligned(T value, unsigned requiredAlignment=TraceAlignment)
const Symbol key1('v', 1)
bool equals(const Class &q, double tol) 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)
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
static const NavState kIdentity
#define EXPECT(condition)
T & upAlign(T &value, unsigned requiredAlignment=TraceAlignment)
Point3_ p_cam(x,&Pose3::transformTo, p)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DEVICE_FUNC const Scalar & q
void print(const string &s) const
Q R1(Eigen::AngleAxisd(1, Q_z_axis))
double norm3(const Point3 &p, OptionalJacobian< 1, 3 > H)
Distance of the point from the origin, with Jacobian.
void dims(std::map< Key, int > &map) const
Return dimensions for each argument, as a map.
std::set< Key > keys() const
Return keys that play in this expression.
Expression< Point2 > uv_hat(uncalibrate< Cal3_S2 >, K, projection)
Expression< Cal3_S2 > K(3)
Matrix< Scalar, Dynamic, Dynamic > C
#define LONGS_EQUAL(expected, actual)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
#define EXPECT_LONGS_EQUAL(expected, actual)
Expression< Point2 > projection(f, p_cam)
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
const Symbol key2('v', 2)
T value(const Values &values, boost::optional< std::vector< Matrix > & > H=boost::none) const
Return value and optional derivatives, reverse AD version Notes: this is not terribly efficient...
const Vector3 & vector() const
Point2(* Project)(const Point3 &, OptionalJacobian< 2, 3 >)
double f3(double x1, double x2)
size_t traceSize() const
Return size needed for memory buffer in traceExecution.
Line3 transformTo(const Pose3 &wTc, const Line3 &wL, OptionalJacobian< 4, 6 > Dpose, OptionalJacobian< 4, 4 > Dline)
Expression< T > linearExpression(const boost::function< T(A)> &f, const Expression< A > &expression, const Eigen::Matrix< double, traits< T >::dimension, traits< A >::dimension > &dTdA)
Q R2(Eigen::AngleAxisd(2, Vector3(0, 1, 0)))
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)
Expression< Vector3 > Vector3_