39 #include <tf2/LinearMath/Quaternion.h>
40 #include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
44 visualization_msgs::msg::InteractiveMarker
47 visualization_msgs::msg::InteractiveMarker int_marker;
48 int_marker.header = stamped.header;
49 int_marker.name =
name;
50 int_marker.scale = scale;
51 int_marker.pose = stamped.pose;
58 visualization_msgs::msg::Marker m;
59 m.type = visualization_msgs::msg::Marker::ARROW;
60 m.scale.x = 0.6 * im.scale;
61 m.scale.y = 0.12 * im.scale;
62 m.scale.z = 0.12 * im.scale;
63 m.ns =
"goal_pose_arrow_marker";
65 m.action = visualization_msgs::msg::Marker::ADD;
69 tf2::Quaternion imq, tmq;
70 tf2::fromMsg(m.pose.orientation, imq);
71 tmq.setRPY(0, -M_PI / 2.0, 0);
73 m.pose.orientation = tf2::toMsg(imq);
79 visualization_msgs::msg::Marker mc;
80 mc.type = visualization_msgs::msg::Marker::CYLINDER;
81 mc.scale.x = 0.05 * im.scale;
82 mc.scale.y = 0.05 * im.scale;
83 mc.scale.z = 0.15 * im.scale;
84 mc.ns =
"goal_pose_arrow_marker";
86 mc.action = visualization_msgs::msg::Marker::ADD;
87 mc.header = im.header;
90 tf2::fromMsg(mc.pose.orientation, imq);
91 tmq.setRPY(M_PI / 2.0, 0, 0);
93 mc.pose.orientation = tf2::toMsg(imq);
94 mc.pose.position.x -= 0.04;
95 mc.pose.position.z += 0.01;
101 visualization_msgs::msg::InteractiveMarkerControl m_control;
102 m_control.always_visible =
true;
103 m_control.interaction_mode = m_control.BUTTON;
104 m_control.markers.push_back(m);
105 m_control.markers.push_back(mc);
108 im.controls.push_back(m_control);
114 visualization_msgs::msg::Marker err;
115 err.type = visualization_msgs::msg::Marker::MESH_RESOURCE;
116 err.scale.x = 0.002 * im.scale;
117 err.scale.y = 0.002 * im.scale;
118 err.scale.z = 0.002 * im.scale;
119 err.mesh_resource =
"package://moveit_ros_planning_interface/resources/access-denied.dae";
120 err.ns =
"robot_interaction_error";
122 err.action = visualization_msgs::msg::Marker::ADD;
123 err.header = im.header;
125 err.pose.orientation.x = err.pose.orientation.y = 0.7071067811865476;
126 err.pose.orientation.z = err.pose.orientation.w = 0.0;
132 visualization_msgs::msg::InteractiveMarkerControl err_control;
133 err_control.always_visible =
false;
134 err_control.markers.push_back(err);
137 im.controls.push_back(err_control);
141 static const double SQRT2INV = 0.707106781;
143 void addPlanarXYControl(visualization_msgs::msg::InteractiveMarker& int_marker,
bool orientation_fixed)
145 visualization_msgs::msg::InteractiveMarkerControl
control;
147 if (orientation_fixed)
149 control.orientation.w = SQRT2INV;
150 control.orientation.x = SQRT2INV;
153 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
154 int_marker.controls.push_back(
control);
156 control.orientation.w = SQRT2INV;
158 control.orientation.y = SQRT2INV;
160 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_AXIS;
161 int_marker.controls.push_back(
control);
163 control.orientation.w = SQRT2INV;
166 control.orientation.z = SQRT2INV;
167 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
168 int_marker.controls.push_back(
control);
171 void add6DOFControl(visualization_msgs::msg::InteractiveMarker& int_marker,
bool orientation_fixed)
179 visualization_msgs::msg::InteractiveMarkerControl
control;
181 if (orientation_fixed)
183 control.orientation.w = SQRT2INV;
184 control.orientation.x = SQRT2INV;
187 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_AXIS;
188 int_marker.controls.push_back(
control);
190 control.orientation.w = SQRT2INV;
192 control.orientation.y = SQRT2INV;
194 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_AXIS;
195 int_marker.controls.push_back(
control);
197 control.orientation.w = SQRT2INV;
200 control.orientation.z = SQRT2INV;
201 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_AXIS;
202 int_marker.controls.push_back(
control);
205 void addPositionControl(visualization_msgs::msg::InteractiveMarker& int_marker,
bool orientation_fixed)
207 visualization_msgs::msg::InteractiveMarkerControl
control;
209 if (orientation_fixed)
211 control.orientation.w = SQRT2INV;
212 control.orientation.x = SQRT2INV;
215 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
216 int_marker.controls.push_back(
control);
218 control.orientation.w = SQRT2INV;
220 control.orientation.y = SQRT2INV;
222 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
223 int_marker.controls.push_back(
control);
225 control.orientation.w = SQRT2INV;
228 control.orientation.z = SQRT2INV;
229 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_AXIS;
230 int_marker.controls.push_back(
control);
234 const std_msgs::msg::ColorRGBA& color,
bool position,
bool orientation)
236 visualization_msgs::msg::InteractiveMarkerControl
control;
237 control.orientation_mode = visualization_msgs::msg::InteractiveMarkerControl::VIEW_FACING;
238 if (position && orientation)
239 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_ROTATE_3D;
240 else if (orientation)
241 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::ROTATE_3D;
243 control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::MOVE_3D;
244 control.independent_marker_orientation =
true;
247 visualization_msgs::msg::Marker marker;
249 marker.type = visualization_msgs::msg::Marker::SPHERE;
250 marker.scale.x = radius * 2.0;
251 marker.scale.y = radius * 2.0;
252 marker.scale.z = radius * 2.0;
253 marker.color = color;
255 control.markers.push_back(marker);
256 control.always_visible =
false;
258 int_marker.controls.push_back(
control);
262 const geometry_msgs::msg::PoseStamped& stamped,
263 double scale,
bool orientation_fixed)
271 const geometry_msgs::msg::PoseStamped& stamped,
double scale,
272 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)