40 #if __has_include(<tf2/LinearMath/Quaternion.hpp>)
41 #include <tf2/LinearMath/Quaternion.hpp>
43 #include <tf2/LinearMath/Quaternion.h>
45 #include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
49 visualization_msgs::msg::InteractiveMarker
52 visualization_msgs::msg::InteractiveMarker int_marker;
53 int_marker.header = stamped.header;
54 int_marker.name =
name;
55 int_marker.scale = scale;
56 int_marker.pose = stamped.pose;
63 visualization_msgs::msg::Marker m;
64 m.type = visualization_msgs::msg::Marker::ARROW;
65 m.scale.x = 0.6 * im.scale;
66 m.scale.y = 0.12 * im.scale;
67 m.scale.z = 0.12 * im.scale;
68 m.ns =
"goal_pose_arrow_marker";
70 m.action = visualization_msgs::msg::Marker::ADD;
74 tf2::Quaternion imq, tmq;
75 tf2::fromMsg(m.pose.orientation, imq);
76 tmq.setRPY(0, -M_PI / 2.0, 0);
78 m.pose.orientation = tf2::toMsg(imq);
84 visualization_msgs::msg::Marker mc;
85 mc.type = visualization_msgs::msg::Marker::CYLINDER;
86 mc.scale.x = 0.05 * im.scale;
87 mc.scale.y = 0.05 * im.scale;
88 mc.scale.z = 0.15 * im.scale;
89 mc.ns =
"goal_pose_arrow_marker";
91 mc.action = visualization_msgs::msg::Marker::ADD;
92 mc.header = im.header;
95 tf2::fromMsg(mc.pose.orientation, imq);
96 tmq.setRPY(M_PI / 2.0, 0, 0);
98 mc.pose.orientation = tf2::toMsg(imq);
99 mc.pose.position.x -= 0.04;
100 mc.pose.position.z += 0.01;
106 visualization_msgs::msg::InteractiveMarkerControl m_control;
107 m_control.always_visible =
true;
108 m_control.interaction_mode = m_control.BUTTON;
109 m_control.markers.push_back(m);
110 m_control.markers.push_back(mc);
113 im.controls.push_back(m_control);
119 visualization_msgs::msg::Marker err;
120 err.type = visualization_msgs::msg::Marker::MESH_RESOURCE;
121 err.scale.x = 0.002 * im.scale;
122 err.scale.y = 0.002 * im.scale;
123 err.scale.z = 0.002 * im.scale;
124 err.mesh_resource =
"package://moveit_ros_planning_interface/resources/access-denied.dae";
125 err.ns =
"robot_interaction_error";
127 err.action = visualization_msgs::msg::Marker::ADD;
128 err.header = im.header;
130 err.pose.orientation.x = err.pose.orientation.y = 0.7071067811865476;
131 err.pose.orientation.z = err.pose.orientation.w = 0.0;
137 visualization_msgs::msg::InteractiveMarkerControl err_control;
138 err_control.always_visible =
false;
139 err_control.markers.push_back(err);
142 im.controls.push_back(err_control);
146 static const double SQRT2INV = 0.707106781;
148 void addPlanarXYControl(visualization_msgs::msg::InteractiveMarker& int_marker,
bool orientation_fixed)
150 visualization_msgs::msg::InteractiveMarkerControl
control;
152 if (orientation_fixed)
154 control.orientation.w = SQRT2INV;
155 control.orientation.x = SQRT2INV;
158 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
159 int_marker.controls.push_back(
control);
161 control.orientation.w = SQRT2INV;
163 control.orientation.y = SQRT2INV;
165 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_AXIS;
166 int_marker.controls.push_back(
control);
168 control.orientation.w = SQRT2INV;
171 control.orientation.z = SQRT2INV;
172 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
173 int_marker.controls.push_back(
control);
176 void add6DOFControl(visualization_msgs::msg::InteractiveMarker& int_marker,
bool orientation_fixed)
184 visualization_msgs::msg::InteractiveMarkerControl
control;
186 if (orientation_fixed)
188 control.orientation.w = SQRT2INV;
189 control.orientation.x = SQRT2INV;
192 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_AXIS;
193 int_marker.controls.push_back(
control);
195 control.orientation.w = SQRT2INV;
197 control.orientation.y = SQRT2INV;
199 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_AXIS;
200 int_marker.controls.push_back(
control);
202 control.orientation.w = SQRT2INV;
205 control.orientation.z = SQRT2INV;
206 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_AXIS;
207 int_marker.controls.push_back(
control);
210 void addPositionControl(visualization_msgs::msg::InteractiveMarker& int_marker,
bool orientation_fixed)
212 visualization_msgs::msg::InteractiveMarkerControl
control;
214 if (orientation_fixed)
216 control.orientation.w = SQRT2INV;
217 control.orientation.x = SQRT2INV;
220 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
221 int_marker.controls.push_back(
control);
223 control.orientation.w = SQRT2INV;
225 control.orientation.y = SQRT2INV;
227 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
228 int_marker.controls.push_back(
control);
230 control.orientation.w = SQRT2INV;
233 control.orientation.z = SQRT2INV;
234 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
235 int_marker.controls.push_back(
control);
239 const std_msgs::msg::ColorRGBA& color,
bool position,
bool orientation)
241 visualization_msgs::msg::InteractiveMarkerControl
control;
242 control.orientation_mode = visualization_msgs::msg::InteractiveMarkerControl::VIEW_FACING;
243 if (position && orientation)
244 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_ROTATE_3D;
245 else if (orientation)
246 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_3D;
248 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_3D;
249 control.independent_marker_orientation =
true;
252 visualization_msgs::msg::Marker marker;
254 marker.type = visualization_msgs::msg::Marker::SPHERE;
255 marker.scale.x = radius * 2.0;
256 marker.scale.y = radius * 2.0;
257 marker.scale.z = radius * 2.0;
258 marker.color = color;
260 control.markers.push_back(marker);
261 control.always_visible =
false;
263 int_marker.controls.push_back(
control);
267 const geometry_msgs::msg::PoseStamped& stamped,
268 double scale,
bool orientation_fixed)
276 const geometry_msgs::msg::PoseStamped& stamped,
double scale,
277 bool orientation_fixed)
void addViewPlaneControl(visualization_msgs::msg::InteractiveMarker &int_marker, double radius, const std_msgs::msg::ColorRGBA &color, bool position=true, bool orientation=true)
void addTArrowMarker(visualization_msgs::msg::InteractiveMarker &im)
void add6DOFControl(visualization_msgs::msg::InteractiveMarker &int_marker, bool orientation_fixed=false)
visualization_msgs::msg::InteractiveMarker make6DOFMarker(const std::string &name, const geometry_msgs::msg::PoseStamped &stamped, double scale, bool orientation_fixed=false)
void addOrientationControl(visualization_msgs::msg::InteractiveMarker &int_marker, bool orientation_fixed=false)
visualization_msgs::msg::InteractiveMarker makeEmptyInteractiveMarker(const std::string &name, const geometry_msgs::msg::PoseStamped &stamped, double scale)
void addErrorMarker(visualization_msgs::msg::InteractiveMarker &im)
void addPlanarXYControl(visualization_msgs::msg::InteractiveMarker &int_marker, bool orientation_fixed=false)
visualization_msgs::msg::InteractiveMarker makePlanarXYMarker(const std::string &name, const geometry_msgs::msg::PoseStamped &stamped, double scale, bool orientation_fixed=false)
void addPositionControl(visualization_msgs::msg::InteractiveMarker &int_marker, bool orientation_fixed=false)