10 #include "../core/topic.h" 11 #include "../core/watcher.h" 13 #include <geometry_msgs/PointStamped.h> 14 #include <geometry_msgs/PoseStamped.h> 15 #include <tf2_msgs/TFMessage.h> 16 #include <visualization_msgs/InteractiveMarker.h> 17 #include <visualization_msgs/InteractiveMarkerFeedback.h> 18 #include <visualization_msgs/InteractiveMarkerInit.h> 19 #include <visualization_msgs/InteractiveMarkerUpdate.h> 25 bool show_descriptions =
false;
26 double description_size = 1.0;
27 Eigen::Vector2d description_offset = Eigen::Vector2d::Zero();
28 std::shared_ptr<Material> description_material;
33 std::vector<std::shared_ptr<VisualizationMarker>> _markers;
34 int _interaction_mode = 0;
36 Eigen::Quaterniond _orientation = Eigen::Quaterniond::Identity();
38 std::shared_ptr<InteractiveMarkerParameters> _params;
42 const visualization_msgs::InteractiveMarkerControl &message,
43 const std::shared_ptr<InteractiveMarkerParameters> ¶ms,
45 virtual bool interact(
const Interaction &interaction)
override;
46 void update(
const visualization_msgs::InteractiveMarkerControl &message);
48 const std::string &controlName()
const {
return _name; }
52 std::shared_ptr<TextRenderer> _text;
55 std::vector<std::shared_ptr<InteractiveMarkerControl>> _controls;
57 bool _dragged =
false;
58 std::shared_ptr<InteractiveMarkerParameters> _params;
63 const std::shared_ptr<InteractiveMarkerParameters> ¶ms,
65 void update(
const visualization_msgs::InteractiveMarker &message);
66 void update(
const visualization_msgs::InteractiveMarkerPose &message);
68 const std::string &markerName()
const {
return _name; }
69 virtual bool interact(
const Interaction &interaction)
override;
75 std::map<std::string, std::shared_ptr<InteractiveMarker>> _markers;
76 std::shared_ptr<InteractiveMarkerParameters> _params;
80 const std::shared_ptr<InteractiveMarkerParameters> ¶ms);
81 void init(
const visualization_msgs::InteractiveMarkerInit &message);
82 void update(
const visualization_msgs::InteractiveMarkerUpdate &message);
85 std::shared_ptr<InteractiveMarker> marker(
const std::string &name);
90 std::shared_ptr<InteractiveMarkerParameters> _params;
91 std::shared_ptr<InteractiveMarkerArray> _markers;
93 visualization_msgs::InteractiveMarker makePointMarker();
94 visualization_msgs::InteractiveMarker makePoseMarker();
95 visualization_msgs::InteractiveMarker makeRotationMarker();
103 std::shared_ptr<Subscriber<visualization_msgs::InteractiveMarkerUpdate>>
105 std::shared_ptr<Subscriber<visualization_msgs::InteractiveMarkerInit>>
108 std::shared_ptr<Publisher<visualization_msgs::InteractiveMarkerFeedback>>
110 static std::vector<std::string> listTopicNamespaces();
113 PROPERTY(std::string, topicNamespace,
"",
114 list = [](
const Property &property) {
115 return InteractiveMarkerDisplay::listTopicNamespaces();
117 PROPERTY(
bool, showDescriptions,
true);
118 PROPERTY(
double, descriptionSize, 0.2, min = 0);
119 PROPERTY(Eigen::Vector2d, descriptionOffset, Eigen::Vector2d(0, 0.85));
121 PROPERTY(
double, descriptionOpacity, 1.0, min = 0, max = 1);
129 struct PublishThreadData {
130 std::condition_variable _stop_condition;
131 std::mutex _publish_mutex;
132 bool _stop_flag =
false;
134 std::shared_ptr<PublishThreadData> _publish_thread_data;
140 virtual void publish(
const std::string &frame,
141 const Eigen::Isometry3d &pose) = 0;
142 static uint64_t publisherClock() {
143 return std::chrono::duration_cast<std::chrono::seconds>(
144 std::chrono::steady_clock::now().time_since_epoch())
149 PROPERTY(
Frame, frame);
150 PROPERTY(
Pose, transform);
151 PROPERTY(
double, scale, 1.0, min = 0.0);
153 virtual bool interact(
const Interaction &interaction)
override;
154 virtual void refresh()
override;
160 PROPERTY(std::string, childFrame);
162 virtual void publish(
const std::string &frame,
163 const Eigen::Isometry3d &pose)
override;
168 static std::array<double, 16> poseToArray(
const Eigen::Isometry3d &pose) {
169 std::array<double, 16> ret;
170 for (
size_t row = 0; row < pose.matrix().rows(); row++) {
171 for (
size_t col = 0; col < pose.matrix().cols(); col++) {
172 ret.at(row * pose.matrix().cols() + col) = pose.matrix()(row, col);