41 using namespace visualization_msgs;
55 marker.type = Marker::CUBE;
56 marker.scale.x = msg.scale * 0.45;
57 marker.scale.y = msg.scale * 0.45;
58 marker.scale.z = msg.scale * 0.45;
69 InteractiveMarkerControl control;
70 control.always_visible =
true;
71 control.markers.push_back(
makeBox(msg) );
72 msg.controls.push_back( control );
74 return msg.controls.back();
89 t.setOrigin(tf::Vector3(0.0, 0.0, sin(
float(
counter)/140.0) * 2.0));
93 t.setOrigin(tf::Vector3(0.0, 0.0, 0.0));
102 void processFeedback(
const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
104 std::ostringstream
s;
105 s <<
"Feedback from marker '" << feedback->marker_name <<
"' "
106 <<
" / control '" << feedback->control_name <<
"'";
108 std::ostringstream mouse_point_ss;
109 if( feedback->mouse_point_valid )
111 mouse_point_ss <<
" at " << feedback->mouse_point.x
112 <<
", " << feedback->mouse_point.y
113 <<
", " << feedback->mouse_point.z
114 <<
" in frame " << feedback->header.frame_id;
117 switch ( feedback->event_type )
119 case visualization_msgs::InteractiveMarkerFeedback::BUTTON_CLICK:
120 ROS_INFO_STREAM(
s.str() <<
": button click" << mouse_point_ss.str() <<
"." );
123 case visualization_msgs::InteractiveMarkerFeedback::MENU_SELECT:
124 ROS_INFO_STREAM(
s.str() <<
": menu item " << feedback->menu_entry_id <<
" clicked" << mouse_point_ss.str() <<
"." );
127 case visualization_msgs::InteractiveMarkerFeedback::POSE_UPDATE:
130 << feedback->pose.position.x
131 <<
", " << feedback->pose.position.y
132 <<
", " << feedback->pose.position.z
133 <<
"\norientation = "
134 << feedback->pose.orientation.w
135 <<
", " << feedback->pose.orientation.x
136 <<
", " << feedback->pose.orientation.y
137 <<
", " << feedback->pose.orientation.z
138 <<
"\nframe: " << feedback->header.frame_id
139 <<
" time: " << feedback->header.stamp.sec <<
"sec, "
140 << feedback->header.stamp.nsec <<
" nsec" );
143 case visualization_msgs::InteractiveMarkerFeedback::MOUSE_DOWN:
144 ROS_INFO_STREAM(
s.str() <<
": mouse down" << mouse_point_ss.str() <<
"." );
147 case visualization_msgs::InteractiveMarkerFeedback::MOUSE_UP:
157 void alignMarker(
const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
159 geometry_msgs::Pose pose = feedback->pose;
161 pose.position.x = round(pose.position.x-0.5)+0.5;
162 pose.position.y = round(pose.position.y-0.5)+0.5;
165 <<
" aligning position = "
166 << feedback->pose.position.x
167 <<
", " << feedback->pose.position.y
168 <<
", " << feedback->pose.position.z
171 <<
", " << pose.position.y
172 <<
", " << pose.position.z );
174 server->setPose( feedback->marker_name, pose );
179 double rand(
double min,
double max )
181 double t = (double)
rand() / (double)RAND_MAX;
196 int_marker.description =
"Simple 6-DOF Control";
202 InteractiveMarkerControl control;
207 int_marker.description +=
"\n(fixed orientation)";
208 control.orientation_mode = InteractiveMarkerControl::FIXED;
213 std::string mode_text;
214 if(
interaction_mode == visualization_msgs::InteractiveMarkerControl::MOVE_3D ) mode_text =
"MOVE_3D";
215 if(
interaction_mode == visualization_msgs::InteractiveMarkerControl::ROTATE_3D ) mode_text =
"ROTATE_3D";
216 if(
interaction_mode == visualization_msgs::InteractiveMarkerControl::MOVE_ROTATE_3D ) mode_text =
"MOVE_ROTATE_3D";
218 int_marker.description = std::string(
"3D Control") + (show_6dof ?
" + 6-DOF controls" :
"") +
"\n" + mode_text;
226 control.name =
"rotate_x";
227 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
229 control.name =
"move_x";
230 control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
236 control.name =
"rotate_z";
237 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
239 control.name =
"move_z";
240 control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
246 control.name =
"rotate_y";
247 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
249 control.name =
"move_y";
250 control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
270 int_marker.description =
"6-DOF\n(Arbitrary Axes)";
274 InteractiveMarkerControl control;
276 for (
int i=0; i<3; i++ )
281 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
283 control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
304 InteractiveMarkerControl control;
307 control.orientation_mode = InteractiveMarkerControl::VIEW_FACING;
308 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
309 control.orientation.w = 1;
310 control.name =
"rotate";
316 control.orientation_mode = InteractiveMarkerControl::VIEW_FACING;
317 control.interaction_mode = InteractiveMarkerControl::MOVE_PLANE;
318 control.independent_marker_orientation =
true;
319 control.name =
"move";
322 control.always_visible =
true;
345 InteractiveMarkerControl control;
350 control.interaction_mode = InteractiveMarkerControl::MOVE_ROTATE;
352 control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
369 int_marker.description =
"Chess Piece\n(2D Move + Alignment)";
371 InteractiveMarkerControl control;
376 control.interaction_mode = InteractiveMarkerControl::MOVE_PLANE;
381 control.always_visible =
true;
406 InteractiveMarkerControl control;
411 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
412 control.orientation_mode = InteractiveMarkerControl::FIXED;
418 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
419 control.orientation_mode = InteractiveMarkerControl::INHERIT;
436 int_marker.description =
"Context Menu\n(Right Click)";
438 InteractiveMarkerControl control;
440 control.interaction_mode = InteractiveMarkerControl::MENU;
441 control.name =
"menu_only_control";
444 control.markers.push_back( marker );
445 control.always_visible =
true;
463 int_marker.description =
"Button\n(Left Click)";
465 InteractiveMarkerControl control;
467 control.interaction_mode = InteractiveMarkerControl::BUTTON;
468 control.name =
"button_control";
471 control.markers.push_back( marker );
472 control.always_visible =
true;
489 int_marker.description =
"Marker Attached to a\nMoving Frame";
491 InteractiveMarkerControl control;
496 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
499 control.interaction_mode = InteractiveMarkerControl::MOVE_PLANE;
500 control.always_visible =
true;
510 int main(
int argc,
char** argv)