Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CARTOGRAPHER_RVIZ_SRC_DRAWABLE_SUBMAP_H_
00018 #define CARTOGRAPHER_RVIZ_SRC_DRAWABLE_SUBMAP_H_
00019
00020 #include <future>
00021 #include <memory>
00022
00023 #include "Eigen/Core"
00024 #include "Eigen/Geometry"
00025 #include "OgreSceneManager.h"
00026 #include "OgreSceneNode.h"
00027 #include "absl/synchronization/mutex.h"
00028 #include "cartographer/io/submap_painter.h"
00029 #include "cartographer/mapping/id.h"
00030 #include "cartographer/transform/rigid_transform.h"
00031 #include "cartographer_ros/submap.h"
00032 #include "cartographer_ros_msgs/SubmapEntry.h"
00033 #include "cartographer_ros_msgs/SubmapQuery.h"
00034 #include "cartographer_rviz/ogre_slice.h"
00035 #include "ros/ros.h"
00036 #include "rviz/display_context.h"
00037 #include "rviz/frame_manager.h"
00038 #include "rviz/ogre_helpers/axes.h"
00039 #include "rviz/ogre_helpers/movable_text.h"
00040 #include "rviz/properties/bool_property.h"
00041
00042 namespace cartographer_rviz {
00043
00044
00045
00046 class DrawableSubmap : public QObject {
00047 Q_OBJECT
00048
00049 public:
00050 DrawableSubmap(const ::cartographer::mapping::SubmapId& submap_id,
00051 ::rviz::DisplayContext* display_context,
00052 Ogre::SceneNode* map_node, ::rviz::Property* submap_category,
00053 bool visible, const bool pose_axes_visible,
00054 float pose_axes_length, float pose_axes_radius);
00055 ~DrawableSubmap() override;
00056 DrawableSubmap(const DrawableSubmap&) = delete;
00057 DrawableSubmap& operator=(const DrawableSubmap&) = delete;
00058
00059
00060
00061 void Update(const ::std_msgs::Header& header,
00062 const ::cartographer_ros_msgs::SubmapEntry& metadata);
00063
00064
00065
00066 bool MaybeFetchTexture(ros::ServiceClient* client);
00067
00068
00069 bool QueryInProgress();
00070
00071
00072
00073
00074
00075 void SetAlpha(double current_tracking_z, float fade_out_distance_in_meters);
00076
00077
00078
00079 void SetSliceVisibility(size_t slice_index, bool visible);
00080
00081 ::cartographer::mapping::SubmapId id() const { return id_; }
00082 int version() const { return metadata_version_; }
00083 bool visibility() const { return visibility_->getBool(); }
00084 void set_visibility(const bool visibility) {
00085 visibility_->setBool(visibility);
00086 }
00087 void set_pose_markers_visibility(const bool visibility) {
00088 pose_axes_visible_ = visibility;
00089 TogglePoseMarkerVisibility();
00090 }
00091
00092 Q_SIGNALS:
00093
00094 void RequestSucceeded();
00095
00096 private Q_SLOTS:
00097
00098 void UpdateSceneNode();
00099 void ToggleVisibility();
00100 void TogglePoseMarkerVisibility();
00101
00102 private:
00103 const ::cartographer::mapping::SubmapId id_;
00104
00105 absl::Mutex mutex_;
00106 ::rviz::DisplayContext* const display_context_;
00107 Ogre::SceneNode* const submap_node_;
00108 Ogre::SceneNode* const submap_id_text_node_;
00109 std::vector<std::unique_ptr<OgreSlice>> ogre_slices_;
00110 ::cartographer::transform::Rigid3d pose_ GUARDED_BY(mutex_);
00111 ::rviz::Axes pose_axes_;
00112 bool pose_axes_visible_;
00113 ::rviz::MovableText submap_id_text_;
00114 std::chrono::milliseconds last_query_timestamp_ GUARDED_BY(mutex_);
00115 bool query_in_progress_ GUARDED_BY(mutex_) = false;
00116 int metadata_version_ GUARDED_BY(mutex_) = -1;
00117 std::future<void> rpc_request_future_;
00118 std::unique_ptr<::cartographer::io::SubmapTextures> submap_textures_
00119 GUARDED_BY(mutex_);
00120 float current_alpha_ = 0.f;
00121 std::unique_ptr<::rviz::BoolProperty> visibility_;
00122 };
00123
00124 }
00125
00126 #endif // CARTOGRAPHER_RVIZ_SRC_DRAWABLE_SUBMAP_H_