NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
spaced_feature_track.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef VISION_COMMON_SPACED_FEATURE_TRACK_H_
20 #define VISION_COMMON_SPACED_FEATURE_TRACK_H_
21 
23 
24 #include <set>
25 #include <vector>
26 
27 namespace vision_common {
28 // Feature track with additional methods to return downsampled or
29 // set duration feature tracks.
30 // Allows for maximally spaced tracks, downsampled tracks given a set spacing,
31 // and downsampled tracks using only allowabled timestamps.
33  public:
34  explicit SpacedFeatureTrack(const FeatureId id);
35  // Default constructor for serialization only.
36  SpacedFeatureTrack() = default;
37 
38  virtual ~SpacedFeatureTrack() = default;
39 
40  // Returns the latest set of points spaced by the provided spacing.
41  // Starts sampling with the latest point.
42  // Return vector is ordered from oldest to latest points.
43  std::vector<FeaturePoint> LatestSpacedPoints(const int spacing = 0) const;
44 
45  // Returns the max spacing usable for a feature track
46  // such that the total number of points in the feature
47  // track does not exceed max_num_points.
48  int MaxSpacing(const int max_num_points) const;
49 
50  // Returns the second latest point's timestamp in the feature track.
51  boost::optional<localization_common::Time> SecondLatestTimestamp() const;
52 
53  private:
54  bool SpacingFits(const int spacing, const int max_num_points) const;
55  int ClosestSpacing(const int ideal_spacing, const int ideal_max_num_points) const;
56 
57  // Serialization function
59  template <class ARCHIVE>
60  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
61  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(FeatureTrack);
62  }
63 };
64 } // namespace vision_common
65 
66 #endif // VISION_COMMON_SPACED_FEATURE_TRACK_H_
feature_track.h
vision_common
Definition: brisk_feature_detector_and_matcher.h:25
vision_common::SpacedFeatureTrack::SecondLatestTimestamp
boost::optional< localization_common::Time > SecondLatestTimestamp() const
Definition: spaced_feature_track.cc:69
vision_common::SpacedFeatureTrack::LatestSpacedPoints
std::vector< FeaturePoint > LatestSpacedPoints(const int spacing=0) const
Definition: spaced_feature_track.cc:26
vision_common::FeatureTrack
Definition: feature_track.h:28
vision_common::SpacedFeatureTrack::MaxSpacing
int MaxSpacing(const int max_num_points) const
Definition: spaced_feature_track.cc:48
vision_common::SpacedFeatureTrack
Definition: spaced_feature_track.h:32
vision_common::SpacedFeatureTrack::SpacedFeatureTrack
SpacedFeatureTrack()=default
vision_common::SpacedFeatureTrack::~SpacedFeatureTrack
virtual ~SpacedFeatureTrack()=default
vision_common::FeatureId
int FeatureId
Definition: feature_point.h:29
vision_common::SpacedFeatureTrack::access
friend class boost::serialization::access
Definition: spaced_feature_track.h:58