NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
timestamped_nodes.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 #ifndef NODES_TIMESTAMPED_NODES_H_
19 #define NODES_TIMESTAMPED_NODES_H_
20 
22 
23 namespace nodes {
24 template <typename NodeType>
25 // Container for timestamped nodes with a single value per node.
26 // Stores the templated NodeType at various timestamps for use with a graph optimizer.
27 // Child class of TimestampedCombinedNodes which handles multiple values per node/timestamp.
28 class TimestampedNodes : public TimestampedCombinedNodes<NodeType> {
30 
31  public:
32  explicit TimestampedNodes(std::shared_ptr<Values> values);
33 
34  // For serialization only
35  TimestampedNodes() = default;
36 
37  private:
38  gtsam::KeyVector AddNode(const NodeType& node) final;
39 
40  boost::optional<NodeType> GetNode(const gtsam::KeyVector& keys,
41  const localization_common::Time timestamp) const final;
42 
43  // Serialization function
45  template <class Archive>
46  void serialize(Archive& ar, const unsigned int file_version) {
47  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
48  }
49 };
50 
51 // Implementation
52 template <typename NodeType>
53 TimestampedNodes<NodeType>::TimestampedNodes(std::shared_ptr<Values> values)
54  : TimestampedCombinedNodes<NodeType>(values) {}
55 
56 template <typename NodeType>
57 gtsam::KeyVector TimestampedNodes<NodeType>::AddNode(const NodeType& node) {
58  const auto key = this->values_->Add(node);
59  return {key};
60 }
61 
62 template <typename NodeType>
63 boost::optional<NodeType> TimestampedNodes<NodeType>::GetNode(const gtsam::KeyVector& keys,
64  const localization_common::Time timestamp) const {
65  // Assumes keys only has a single key since using non-combined type
66  return Base::template Value<NodeType>(keys[0]);
67 }
68 } // namespace nodes
69 
70 #endif // NODES_TIMESTAMPED_NODES_H_
Value
std::pair< std::string, Keywords > Value
Definition: eps_driver_tool.cc:72
nodes::TimestampedNodes::TimestampedNodes
TimestampedNodes()=default
nodes
Definition: combined_nav_state_nodes.h:24
nodes::TimestampedNodes::access
friend class boost::serialization::access
Definition: timestamped_nodes.h:44
nodes::TimestampedCombinedNodes
Definition: timestamped_combined_nodes.h:44
timestamped_combined_nodes.h
nodes::TimestampedCombinedNodes::Add
gtsam::KeyVector Add(const localization_common::Time timestamp, const NodeType &node)
Definition: timestamped_combined_nodes.h:174
nodes::TimestampedNodes
Definition: timestamped_nodes.h:28
localization_common::Time
double Time
Definition: time.h:23