NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
simple_localizer.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented
2  * by the Administrator of the National Aeronautics and Space
3  * Administration.
4  *
5  * All rights reserved.
6  *
7  * The Astrobee platform is licensed under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the
19  * License.
20  */
21 
22 #ifndef TUTORIAL_EXAMPLES_SIMPLE_LOCALIZER_H_
23 #define TUTORIAL_EXAMPLES_SIMPLE_LOCALIZER_H_
24 
31 
32 namespace tutorial_examples {
33 // Simple localizer that adds absolute pose factors using
34 // absolute pose measurements (for example, from matches to a
35 // preexisting map) and adds pose nodes and relative factors
36 // using relative pose measurements (for example, from an
37 // odometry provider). Uses a sliding window graph optimizer
38 // and Levenberg-Marquardt nonlinear optimization.
40  SlidingWindowGraphOptimizer {
41  public:
42  // Initialize and register the node and factor adders.
43  explicit SimpleLocalizer(const SimpleLocalizerParams& params)
44  : SlidingWindowGraphOptimizer(
46  std::make_unique<optimizers::NonlinearOptimizer>(
47  params.nonlinear_optimizer)) {
48  // Initialize node and factor adders
49  node_adder_ = std::make_shared<node_adders::PoseNodeAdder>(
51  values());
52  factor_adder_ =
53  std::make_shared<factor_adders::PoseFactorAdder<
55  node_adder_);
56  // Register node and factor adders
57  AddSlidingWindowNodeAdder(node_adder_);
58  AddFactorAdder(factor_adder_);
59  }
60 
61  // Adds an odometry pose measurement to the pose node
62  // adder. Assumes the pose is in the odometry frame.
65  PoseWithCovarianceMeasurement& measurement) {
66  node_adder_->AddMeasurement(measurement);
67  }
68 
69  // Adds an absolute pose measurement to the pose
70  // factor adder. Assumes the pose is in the world frame.
73  PoseWithCovarianceMeasurement& measurement) {
74  factor_adder_->AddMeasurement(measurement);
75  }
76 
77  // Const accessor for optimized pose nodes.
80  return node_adder_->nodes();
81  }
82 
83  private:
84  std::shared_ptr<
86  factor_adder_;
87  std::shared_ptr<node_adders::PoseNodeAdder> node_adder_;
88 };
89 } // namespace tutorial_examples
90 
91 #endif // TUTORIAL_EXAMPLES_SIMPLE_LOCALIZER_H_
node_adders::MeasurementBasedTimestampedNodeAdder
Definition: measurement_based_timestamped_node_adder.h:30
nonlinear_optimizer.h
tutorial_examples::SimpleLocalizerParams::pose_factor_adder
factor_adders::PoseFactorAdderParams pose_factor_adder
Definition: simple_localizer_params.h:66
tutorial_examples::SimpleLocalizerParams::pose_node_adder
node_adders::PoseNodeAdderParams pose_node_adder
Definition: simple_localizer_params.h:67
tutorial_examples::SimpleLocalizer
Definition: simple_localizer.h:39
sliding_window_graph_optimizer.h
tutorial_examples::SimpleLocalizerParams::pose_node_adder_model
node_adders::PoseNodeAdderModel::Params pose_node_adder_model
Definition: simple_localizer_params.h:68
optimizers
Definition: isam2_optimizer.h:33
tutorial_examples::SimpleLocalizer::timestamped_nodes
const nodes::TimestampedNodes< gtsam::Pose3 > & timestamped_nodes() const
Definition: simple_localizer.h:79
factor_adders::PoseFactorAdder
Definition: pose_factor_adder.h:35
tutorial_examples::SimpleLocalizer::AddOdometryMeasurement
void AddOdometryMeasurement(const localization_measurements::PoseWithCovarianceMeasurement &measurement)
Definition: simple_localizer.h:63
simple_localizer_params.h
tutorial_examples::SimpleLocalizerParams
Definition: simple_localizer_params.h:33
pose_measurement.h
sliding_window_graph_optimizer
Definition: sliding_window_graph_optimizer.h:32
localization_measurements
Definition: depth_correspondences.h:25
tutorial_examples
Definition: simple_localizer.h:32
nodes::TimestampedNodes
Definition: timestamped_nodes.h:28
tutorial_examples::SimpleLocalizer::SimpleLocalizer
SimpleLocalizer(const SimpleLocalizerParams &params)
Definition: simple_localizer.h:43
std
Definition: tensor.h:39
tutorial_examples::SimpleLocalizer::AddPoseMeasurement
void AddPoseMeasurement(const localization_measurements::PoseWithCovarianceMeasurement &measurement)
Definition: simple_localizer.h:71
pose_factor_adder.h
pose_node_adder.h