39 visualization_msgs::InteractiveMarker
makeMarker(
float r,
float g,
float b)
42 visualization_msgs::InteractiveMarker int_marker;
43 int_marker.header.frame_id =
"base_link";
44 int_marker.name =
"my_marker";
45 int_marker.description =
"Simple 1-DOF Control";
48 visualization_msgs::Marker box_marker;
49 box_marker.type = visualization_msgs::Marker::CUBE;
50 box_marker.scale.x = 0.45;
51 box_marker.scale.y = 0.45;
52 box_marker.scale.z = 0.45;
53 box_marker.color.r = r;
54 box_marker.color.g = g;
55 box_marker.color.b = b;
56 box_marker.color.a = 1.0;
59 visualization_msgs::InteractiveMarkerControl box_control;
60 box_control.always_visible =
true;
61 box_control.markers.push_back(box_marker);
64 int_marker.controls.push_back(box_control);
69 visualization_msgs::InteractiveMarkerControl linear_control;
70 linear_control.name =
"move_x";
71 linear_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
74 int_marker.controls.push_back(linear_control);
81 void processFeedback(
const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback)
83 ROS_INFO_STREAM(feedback->marker_name <<
" is now at " << feedback->pose.position.x <<
", "
84 << feedback->pose.position.y <<
", "
85 << feedback->pose.position.z);
88 visualization_msgs::InteractiveMarker int_marker;
92 if (feedback->pose.position.x < 0 && !
is_red)
94 printf(
"turning red.\n");
99 if (feedback->pose.position.x >= 0 &&
is_red)
101 printf(
"turning green.\n");
109 printf(
"changed.\n");
110 int_marker.pose = feedback->pose;
119 visualization_msgs::InteractiveMarker int_marker;
120 int_marker.header.frame_id =
"base_link";
121 int_marker.name =
"crazy_marker";
122 int_marker.description =
"Unusual 1-DOF Control";
125 visualization_msgs::Marker box_marker;
126 box_marker.type = visualization_msgs::Marker::CUBE;
127 box_marker.scale.x = 1;
128 box_marker.scale.y = .3;
129 box_marker.scale.z = .3;
130 box_marker.color.r = .3;
131 box_marker.color.g = .1;
132 box_marker.color.b = 1;
133 box_marker.color.a = 1.0;
134 box_marker.pose.position.y = -1.0;
137 visualization_msgs::InteractiveMarkerControl box_control;
138 box_control.always_visible =
true;
139 box_control.markers.push_back(box_marker);
140 box_control.name =
"crazy";
143 box_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
147 box_control.orientation.w = 1;
148 box_control.orientation.x = 0;
149 box_control.orientation.y = 1;
150 box_control.orientation.z = 0;
151 box_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
155 int_marker.controls.push_back(box_control);
156 int_marker.pose.position.y = 3;
166 <<
" is now at pos " << feedback->pose.position.x <<
", " << feedback->pose.position.y
167 <<
", " << feedback->pose.position.z <<
"; quat " << feedback->pose.orientation.x
168 <<
", " << feedback->pose.orientation.y <<
", " << feedback->pose.orientation.z <<
", "
169 << feedback->pose.orientation.w);
171 bool changed =
false;
172 visualization_msgs::InteractiveMarker int_marker;
176 if (feedback->pose.orientation.z < 0 && !
is_linear)
178 printf(
"turning linear.\n");
183 if (feedback->pose.position.x > 0 &&
is_linear)
185 printf(
"turning rotary.\n");
193 printf(
"changed.\n");
194 int_marker.pose.position.x = 0;
195 int_marker.pose.orientation.x = 0;
196 int_marker.pose.orientation.y = 0;
197 int_marker.pose.orientation.z = 0;
198 int_marker.pose.orientation.w = 1;
204 int main(
int argc,
char** argv)
206 ros::init(argc, argv,
"interactive_marker_test");
212 visualization_msgs::InteractiveMarker int_marker =
makeMarker(0, 1, 0);
219 visualization_msgs::InteractiveMarker crazy_marker =
makeCrazyMarker(
true);