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 =
72 visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
75 int_marker.controls.push_back(linear_control);
82 void processFeedback(
const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
85 << feedback->pose.position.x <<
", " << feedback->pose.position.y
86 <<
", " << feedback->pose.position.z );
89 visualization_msgs::InteractiveMarker int_marker;
93 if( feedback->pose.position.x < 0 && !
is_red )
95 printf(
"turning red.\n" );
100 if( feedback->pose.position.x >= 0 &&
is_red )
102 printf(
"turning green.\n" );
110 printf(
"changed.\n" );
111 int_marker.pose = feedback->pose;
112 server->
insert( int_marker );
120 visualization_msgs::InteractiveMarker int_marker;
121 int_marker.header.frame_id =
"/base_link";
122 int_marker.name =
"crazy_marker";
123 int_marker.description =
"Unusual 1-DOF Control";
126 visualization_msgs::Marker box_marker;
127 box_marker.type = visualization_msgs::Marker::CUBE;
128 box_marker.scale.x = 1;
129 box_marker.scale.y = .3;
130 box_marker.scale.z = .3;
131 box_marker.color.r = .3;
132 box_marker.color.g = .1;
133 box_marker.color.b = 1;
134 box_marker.color.a = 1.0;
135 box_marker.pose.position.y = -1.0;
138 visualization_msgs::InteractiveMarkerControl box_control;
139 box_control.always_visible =
true;
140 box_control.markers.push_back( box_marker );
141 box_control.name =
"crazy";
144 box_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
148 box_control.orientation.w = 1;
149 box_control.orientation.x = 0;
150 box_control.orientation.y = 1;
151 box_control.orientation.z = 0;
152 box_control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
156 int_marker.controls.push_back( box_control );
157 int_marker.pose.position.y = 3;
167 << feedback->pose.position.x <<
", " 168 << feedback->pose.position.y <<
", " 169 << feedback->pose.position.z <<
"; quat " 170 << feedback->pose.orientation.x <<
", " 171 << feedback->pose.orientation.y <<
", " 172 << feedback->pose.orientation.z <<
", " 173 << feedback->pose.orientation.w );
175 bool changed =
false;
176 visualization_msgs::InteractiveMarker int_marker;
180 if( feedback->pose.orientation.z < 0 && !
is_linear )
182 printf(
"turning linear.\n" );
187 if( feedback->pose.position.x > 0 &&
is_linear )
189 printf(
"turning rotary.\n" );
197 printf(
"changed.\n" );
198 int_marker.pose.position.x = 0;
199 int_marker.pose.orientation.x = 0;
200 int_marker.pose.orientation.y = 0;
201 int_marker.pose.orientation.z = 0;
202 int_marker.pose.orientation.w = 1;
203 server->
insert( int_marker );
208 int main(
int argc,
char** argv)
210 ros::init(argc, argv,
"interactive_marker_test");
216 visualization_msgs::InteractiveMarker int_marker =
makeMarker(0, 1, 0);
223 visualization_msgs::InteractiveMarker crazy_marker =
makeCrazyMarker(
true );
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
visualization_msgs::InteractiveMarker makeCrazyMarker(bool linear)
ROSCPP_DECL void spin(Spinner &spinner)
visualization_msgs::InteractiveMarker makeMarker(float r, float g, float b)
void processFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
void processCrazyFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback)
interactive_markers::InteractiveMarkerServer * server
void insert(const visualization_msgs::InteractiveMarker &int_marker)
#define ROS_INFO_STREAM(args)
int main(int argc, char **argv)