NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
ros_pose_extrapolator_wrapper.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 ROS_POSE_EXTRAPOLATOR_ROS_POSE_EXTRAPOLATOR_WRAPPER_H_
19 #define ROS_POSE_EXTRAPOLATOR_ROS_POSE_EXTRAPOLATOR_WRAPPER_H_
20 
21 #include <ff_msgs/EkfState.h>
22 #include <ff_msgs/FlightMode.h>
23 #include <ff_msgs/GraphLocState.h>
24 #include <ff_msgs/GraphVIOState.h>
32 
33 #include <geometry_msgs/PoseWithCovarianceStamped.h>
34 #include <sensor_msgs/Imu.h>
35 
36 #include <memory>
37 #include <string>
38 #include <utility>
39 
40 namespace ros_pose_extrapolator {
41 // Extrapolates latest localization pose using VIO odometry and IMU measurements.
42 // No extrapolation is performed during standstill to avoid adding jittery IMU data.
44  public:
45  explicit RosPoseExtrapolatorWrapper(const std::string& graph_config_path_prefix = "");
46 
48 
49  // Updates latest loc pose with msg pose.
50  void LocalizationStateCallback(const ff_msgs::GraphLocState& graph_loc_state_msg);
51 
52  // Updates odometry pose interpolator with latest VIO msg pose.
53  // Also stores latest velocity and bias estimates for future creation of latest
54  // combined nav state.
55  void GraphVIOStateCallback(const ff_msgs::GraphVIOState& graph_vio_state_msg);
56 
57  // Updates IMU interpolator with latest IMU measurement.
58  void ImuCallback(const sensor_msgs::Imu& imu_msg);
59 
60  // Updates IMU interpolator with latest flight mode to adjust IMU measurement filter appropriately.
61  void FlightModeCallback(const ff_msgs::FlightMode& flight_mode);
62 
63  // Extrapolates latest loc pose using relative VIO odometry measurements and finally
64  // interpolated IMU data for timestamps past the last VIO measurement.
65  boost::optional<std::pair<localization_common::CombinedNavState, localization_common::CombinedNavStateCovariances>>
67 
68  // Constructs EkfState msg (historically named, contains pose/velocity/bias and covariances)
69  // using extrapolated loc pose and covariance.
70  boost::optional<ff_msgs::EkfState> LatestExtrapolatedLocalizationMsg();
71 
72  private:
73  // Initializes extrapolator based on provided params.
74  void Initialize(const RosPoseExtrapolatorParams& params);
75 
76  // Returns if currently in standstill. Uses latest VIO measurement to determine this.
77  bool standstill() const;
78 
79  std::unique_ptr<imu_integration::ImuIntegrator> imu_integrator_;
80  boost::optional<ff_msgs::GraphLocState> latest_loc_msg_;
81  boost::optional<ff_msgs::GraphVIOState> latest_vio_msg_;
82  boost::optional<localization_common::CombinedNavState> latest_extrapolated_vio_state_;
83  boost::optional<localization_common::CombinedNavStateCovariances> latest_vio_state_covariances_;
84  boost::optional<gtsam::Pose3> world_T_odom_;
85  std::unique_ptr<gtsam::TangentPreintegration> preintegration_helper_;
87  boost::optional<bool> standstill_;
88  localization_common::RateTimer loc_state_timer_ = localization_common::RateTimer("Loc State Msg");
89  localization_common::PoseInterpolater odom_interpolator_;
90 };
91 } // namespace ros_pose_extrapolator
92 #endif // ROS_POSE_EXTRAPOLATOR_ROS_POSE_EXTRAPOLATOR_WRAPPER_H_
ros_pose_extrapolator::RosPoseExtrapolatorWrapper::LocalizationStateCallback
void LocalizationStateCallback(const ff_msgs::GraphLocState &graph_loc_state_msg)
Definition: ros_pose_extrapolator_wrapper.cc:77
ros_pose_extrapolator::RosPoseExtrapolatorParams
Definition: ros_pose_extrapolator_params.h:24
ros_pose_extrapolator::RosPoseExtrapolatorWrapper::FlightModeCallback
void FlightModeCallback(const ff_msgs::FlightMode &flight_mode)
Definition: ros_pose_extrapolator_wrapper.cc:106
ros_pose_extrapolator
Definition: parameter_reader.h:26
ros_pose_extrapolator::RosPoseExtrapolatorWrapper::LatestExtrapolatedLocalizationMsg
boost::optional< ff_msgs::EkfState > LatestExtrapolatedLocalizationMsg()
Definition: ros_pose_extrapolator_wrapper.cc:147
ros_pose_extrapolator_params.h
ros_pose_extrapolator::RosPoseExtrapolatorWrapper::LatestExtrapolatedStateAndCovariances
boost::optional< std::pair< localization_common::CombinedNavState, localization_common::CombinedNavStateCovariances > > LatestExtrapolatedStateAndCovariances()
Definition: ros_pose_extrapolator_wrapper.cc:111
localization_common::RateTimer
Definition: rate_timer.h:31
ros_pose_extrapolator::RosPoseExtrapolatorWrapper::RosPoseExtrapolatorWrapper
RosPoseExtrapolatorWrapper(const std::string &graph_config_path_prefix="")
Definition: ros_pose_extrapolator_wrapper.cc:35
rate_timer.h
localization_common::TimestampedInterpolater
Definition: timestamped_interpolater.h:40
imu_integrator.h
combined_nav_state_covariances.h
combined_nav_state.h
ros_pose_extrapolator::RosPoseExtrapolatorWrapper::GraphVIOStateCallback
void GraphVIOStateCallback(const ff_msgs::GraphVIOState &graph_vio_state_msg)
Definition: ros_pose_extrapolator_wrapper.cc:63
ros_pose_extrapolator::RosPoseExtrapolatorWrapper
Definition: ros_pose_extrapolator_wrapper.h:43
imu_measurement.h
ros_pose_extrapolator::RosPoseExtrapolatorWrapper::ImuCallback
void ImuCallback(const sensor_msgs::Imu &imu_msg)
Definition: ros_pose_extrapolator_wrapper.cc:102
pose_interpolater.h