Skip to content

Commit 05812c3

Browse files
authored
Derive the fixed landmarks from the standard landmarks (#259)
1 parent 8a6f010 commit 05812c3

File tree

8 files changed

+53
-164
lines changed

8 files changed

+53
-164
lines changed

fuse_variables/include/fuse_variables/point_2d_fixed_landmark.h

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,27 @@
3636

3737
#include <fuse_core/fuse_macros.h>
3838
#include <fuse_core/serialization.h>
39-
#include <fuse_variables/fixed_size_variable.h>
39+
#include <fuse_variables/point_2d_landmark.h>
4040

4141
#include <boost/serialization/access.hpp>
4242
#include <boost/serialization/base_object.hpp>
4343
#include <boost/serialization/export.hpp>
4444

45-
#include <ostream>
46-
4745
namespace fuse_variables
4846
{
4947
/**
5048
* @brief Variable representing a 2D point landmark that exists across time.
5149
*
52-
* This is commonly used to represent locations of visual features. The UUID of this class is constant after
53-
* construction and dependent on a user input database id. As such, the database id cannot be altered after
54-
* construction.
50+
* This is commonly used to represent locations of visual features. This class differs from the Point2DLandmark in that
51+
* the value of the landmark is held constant during optimization. This is appropriate if the landmark positions are
52+
* known or were previously estimated to sufficient accuracy. The UUID of this class is constant after construction and
53+
* dependent on a user input database id. As such, the database id cannot be altered after construction.
5554
*/
56-
class Point2DFixedLandmark : public FixedSizeVariable<2>
55+
class Point2DFixedLandmark : public Point2DLandmark
5756
{
5857
public:
5958
FUSE_VARIABLE_DEFINITIONS(Point2DFixedLandmark);
6059

61-
/**
62-
* @brief Can be used to directly index variables in the data array
63-
*/
64-
enum : size_t
65-
{
66-
X = 0,
67-
Y = 1
68-
};
69-
7060
/**
7161
* @brief Default constructor
7262
*/
@@ -79,48 +69,14 @@ class Point2DFixedLandmark : public FixedSizeVariable<2>
7969
*/
8070
explicit Point2DFixedLandmark(const uint64_t& landmark_id);
8171

82-
/**
83-
* @brief Read-write access to the X-axis position.
84-
*/
85-
double& x() { return data_[X]; }
86-
87-
/**
88-
* @brief Read-only access to the X-axis position.
89-
*/
90-
const double& x() const { return data_[X]; }
91-
92-
/**
93-
* @brief Read-write access to the Y-axis position.
94-
*/
95-
double& y() { return data_[Y]; }
96-
97-
/**
98-
* @brief Read-only access to the Y-axis position.
99-
*/
100-
const double& y() const { return data_[Y]; }
101-
102-
/**
103-
* @brief Read-only access to the id
104-
*/
105-
const uint64_t& id() const { return id_; }
106-
107-
/**
108-
* @brief Print a human-readable description of the variable to the provided
109-
* stream.
110-
*
111-
* @param[out] stream The stream to write to. Defaults to stdout.
112-
*/
113-
void print(std::ostream& stream = std::cout) const override;
114-
11572
/**
11673
* @brief Specifies if the value of the variable should not be changed during optimization
11774
*/
118-
bool holdConstant() const override;
75+
bool holdConstant() const override { return true; }
11976

12077
private:
12178
// Allow Boost Serialization access to private methods
12279
friend class boost::serialization::access;
123-
uint64_t id_ { 0 };
12480

12581
/**
12682
* @brief The Boost Serialize method that serializes all of the data members
@@ -134,8 +90,7 @@ class Point2DFixedLandmark : public FixedSizeVariable<2>
13490
template <class Archive>
13591
void serialize(Archive& archive, const unsigned int /* version */)
13692
{
137-
archive& boost::serialization::base_object<FixedSizeVariable<SIZE>>(*this);
138-
archive& id_;
93+
archive& boost::serialization::base_object<Point2DLandmark>(*this);
13994
}
14095
};
14196

fuse_variables/include/fuse_variables/point_2d_landmark.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include <fuse_core/fuse_macros.h>
3838
#include <fuse_core/serialization.h>
39+
#include <fuse_core/uuid.h>
3940
#include <fuse_variables/fixed_size_variable.h>
4041

4142
#include <boost/serialization/access.hpp>
@@ -112,6 +113,15 @@ class Point2DLandmark : public FixedSizeVariable<2>
112113
*/
113114
void print(std::ostream& stream = std::cout) const override;
114115

116+
protected:
117+
/**
118+
* @brief Construct a point 2D variable given a UUID and a landmarks id
119+
*
120+
* @param[in] uuid The UUID for this variable
121+
* @param[in] landmark_id The id associated to a landmark
122+
*/
123+
Point2DLandmark(const fuse_core::UUID& uuid, const uint64_t& landmark_id);
124+
115125
private:
116126
// Allow Boost Serialization access to private methods
117127
friend class boost::serialization::access;

fuse_variables/include/fuse_variables/point_3d_fixed_landmark.h

Lines changed: 8 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -36,38 +36,27 @@
3636

3737
#include <fuse_core/fuse_macros.h>
3838
#include <fuse_core/serialization.h>
39-
#include <fuse_variables/fixed_size_variable.h>
39+
#include <fuse_variables/point_3d_landmark.h>
4040

4141
#include <boost/serialization/access.hpp>
4242
#include <boost/serialization/base_object.hpp>
4343
#include <boost/serialization/export.hpp>
4444

45-
#include <ostream>
46-
4745
namespace fuse_variables
4846
{
4947
/**
5048
* @brief Variable representing a 3D point landmark that exists across time.
5149
*
52-
* This is commonly used to represent locations of visual features. The UUID of this class is constant after
53-
* construction and dependent on a user input database id. As such, the database id cannot be altered after
54-
* construction.
50+
* This is commonly used to represent locations of visual features. This class differs from the Point3DLandmark in that
51+
* the value of the landmark is held constant during optimization. This is appropriate if the landmark positions are
52+
* known or were previously estimated to sufficient accuracy. The UUID of this class is constant after construction and
53+
* dependent on a user input database id. As such, the database id cannot be altered after construction.
5554
*/
56-
class Point3DFixedLandmark : public FixedSizeVariable<3>
55+
class Point3DFixedLandmark : public Point3DLandmark
5756
{
5857
public:
5958
FUSE_VARIABLE_DEFINITIONS(Point3DFixedLandmark);
6059

61-
/**
62-
* @brief Can be used to directly index variables in the data array
63-
*/
64-
enum : size_t
65-
{
66-
X = 0,
67-
Y = 1,
68-
Z = 2
69-
};
70-
7160
/**
7261
* @brief Default constructor
7362
*/
@@ -80,58 +69,14 @@ class Point3DFixedLandmark : public FixedSizeVariable<3>
8069
*/
8170
explicit Point3DFixedLandmark(const uint64_t& landmark_id);
8271

83-
/**
84-
* @brief Read-write access to the X-axis position.
85-
*/
86-
double& x() { return data_[X]; }
87-
88-
/**
89-
* @brief Read-only access to the X-axis position.
90-
*/
91-
const double& x() const { return data_[X]; }
92-
93-
/**
94-
* @brief Read-write access to the Y-axis position.
95-
*/
96-
double& y() { return data_[Y]; }
97-
98-
/**
99-
* @brief Read-only access to the Y-axis position.
100-
*/
101-
const double& y() const { return data_[Y]; }
102-
103-
/**
104-
* @brief Read-write access to the Z-axis position.
105-
*/
106-
double& z() { return data_[Z]; }
107-
108-
/**
109-
* @brief Read-only access to the Z-axis position.
110-
*/
111-
const double& z() const { return data_[Z]; }
112-
113-
/**
114-
* @brief Read-only access to the id
115-
*/
116-
const uint64_t& id() const { return id_; }
117-
118-
/**
119-
* @brief Print a human-readable description of the variable to the provided
120-
* stream.
121-
*
122-
* @param[out] stream The stream to write to. Defaults to stdout.
123-
*/
124-
void print(std::ostream& stream = std::cout) const override;
125-
12672
/**
12773
* @brief Specifies if the value of the variable should not be changed during optimization
12874
*/
129-
bool holdConstant() const override;
75+
bool holdConstant() const override { return true; }
13076

13177
private:
13278
// Allow Boost Serialization access to private methods
13379
friend class boost::serialization::access;
134-
uint64_t id_ { 0 };
13580

13681
/**
13782
* @brief The Boost Serialize method that serializes all of the data members
@@ -145,8 +90,7 @@ class Point3DFixedLandmark : public FixedSizeVariable<3>
14590
template <class Archive>
14691
void serialize(Archive& archive, const unsigned int /* version */)
14792
{
148-
archive& boost::serialization::base_object<FixedSizeVariable<SIZE>>(*this);
149-
archive& id_;
93+
archive& boost::serialization::base_object<Point3DLandmark>(*this);
15094
}
15195
};
15296

fuse_variables/include/fuse_variables/point_3d_landmark.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#include <fuse_core/fuse_macros.h>
4141
#include <fuse_core/serialization.h>
42+
#include <fuse_core/uuid.h>
4243
#include <fuse_variables/fixed_size_variable.h>
4344

4445
#include <boost/serialization/access.hpp>
@@ -126,6 +127,14 @@ class Point3DLandmark : public FixedSizeVariable<3>
126127
*/
127128
void print(std::ostream& stream = std::cout) const override;
128129

130+
protected:
131+
/**
132+
* @brief Construct a point 3D variable given a landmarks id
133+
*
134+
* @param[in] landmark_id The id associated to a landmark
135+
*/
136+
Point3DLandmark(const fuse_core::UUID& uuid, const uint64_t& landmark_id);
137+
129138
private:
130139
// Allow Boost Serialization access to private methods
131140
friend class boost::serialization::access;

fuse_variables/src/point_2d_fixed_landmark.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,16 @@
3535

3636
#include <fuse_core/uuid.h>
3737
#include <fuse_core/variable.h>
38-
#include <fuse_variables/fixed_size_variable.h>
38+
#include <fuse_variables/point_2d_landmark.h>
3939
#include <pluginlib/class_list_macros.hpp>
4040

4141
#include <boost/serialization/export.hpp>
4242

43-
#include <ostream>
44-
4543
namespace fuse_variables
4644
{
4745
Point2DFixedLandmark::Point2DFixedLandmark(const uint64_t& landmark_id) :
48-
FixedSizeVariable(fuse_core::uuid::generate(detail::type(), landmark_id)),
49-
id_(landmark_id)
50-
{
51-
}
52-
53-
void Point2DFixedLandmark::print(std::ostream& stream) const
54-
{
55-
stream << type() << ":\n"
56-
<< " uuid: " << uuid() << "\n"
57-
<< " size: " << size() << "\n"
58-
<< " landmark id: " << id() << "\n"
59-
<< " data:\n"
60-
<< " - x: " << x() << "\n"
61-
<< " - y: " << y() << "\n";
62-
}
63-
64-
bool Point2DFixedLandmark::holdConstant() const
46+
Point2DLandmark(fuse_core::uuid::generate(detail::type(), landmark_id), landmark_id)
6547
{
66-
return true;
6748
}
6849

6950
} // namespace fuse_variables

fuse_variables/src/point_2d_landmark.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,17 @@
4444

4545
namespace fuse_variables
4646
{
47-
Point2DLandmark::Point2DLandmark(const uint64_t& landmark_id) :
48-
FixedSizeVariable(fuse_core::uuid::generate(detail::type(), landmark_id)),
47+
Point2DLandmark::Point2DLandmark(const fuse_core::UUID& uuid, const uint64_t& landmark_id) :
48+
FixedSizeVariable(uuid),
4949
id_(landmark_id)
5050
{
5151
}
5252

53+
Point2DLandmark::Point2DLandmark(const uint64_t& landmark_id) :
54+
Point2DLandmark(fuse_core::uuid::generate(detail::type(), landmark_id), landmark_id)
55+
{
56+
}
57+
5358
void Point2DLandmark::print(std::ostream& stream) const
5459
{
5560
stream << type() << ":\n"

fuse_variables/src/point_3d_fixed_landmark.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,16 @@
3535

3636
#include <fuse_core/uuid.h>
3737
#include <fuse_core/variable.h>
38-
#include <fuse_variables/fixed_size_variable.h>
38+
#include <fuse_variables/point_3d_landmark.h>
3939
#include <pluginlib/class_list_macros.hpp>
4040

4141
#include <boost/serialization/export.hpp>
4242

43-
#include <ostream>
44-
4543
namespace fuse_variables
4644
{
4745
Point3DFixedLandmark::Point3DFixedLandmark(const uint64_t& landmark_id) :
48-
FixedSizeVariable(fuse_core::uuid::generate(detail::type(), landmark_id)),
49-
id_(landmark_id)
50-
{
51-
}
52-
53-
void Point3DFixedLandmark::print(std::ostream& stream) const
54-
{
55-
stream << type() << ":\n"
56-
<< " uuid: " << uuid() << "\n"
57-
<< " size: " << size() << "\n"
58-
<< " landmark id: " << id() << "\n"
59-
<< " data:\n"
60-
<< " - x: " << x() << "\n"
61-
<< " - y: " << y() << "\n"
62-
<< " - z: " << z() << "\n";
63-
}
64-
65-
bool Point3DFixedLandmark::holdConstant() const
46+
Point3DLandmark(fuse_core::uuid::generate(detail::type(), landmark_id), landmark_id)
6647
{
67-
return true;
6848
}
6949

7050
} // namespace fuse_variables

fuse_variables/src/point_3d_landmark.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,17 @@
4444

4545
namespace fuse_variables
4646
{
47-
Point3DLandmark::Point3DLandmark(const uint64_t& landmark_id) :
48-
FixedSizeVariable(fuse_core::uuid::generate(detail::type(), landmark_id)),
47+
Point3DLandmark::Point3DLandmark(const fuse_core::UUID& uuid, const uint64_t& landmark_id) :
48+
FixedSizeVariable(uuid),
4949
id_(landmark_id)
5050
{
5151
}
5252

53+
Point3DLandmark::Point3DLandmark(const uint64_t& landmark_id) :
54+
Point3DLandmark(fuse_core::uuid::generate(detail::type(), landmark_id), landmark_id)
55+
{
56+
}
57+
5358
void Point3DLandmark::print(std::ostream& stream) const
5459
{
5560
stream << type() << ":\n"

0 commit comments

Comments
 (0)