00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _trajectory_planner_nodelet_aux_CPP_
00028 #define _trajectory_planner_nodelet_aux_CPP_
00029
00030 #include "trajectory_planner_nodelet.h"
00031
00032 void processFeedback( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
00033 {
00034 std::ostringstream s;
00035 s << "Feedback from marker '" << feedback->marker_name << "' "
00036 << " / control '" << feedback->control_name << "'";
00037
00038 std::ostringstream mouse_point_ss;
00039 if( feedback->mouse_point_valid )
00040 {
00041 mouse_point_ss << " at " << feedback->mouse_point.x
00042 << ", " << feedback->mouse_point.y
00043 << ", " << feedback->mouse_point.z
00044 << " in frame " << feedback->header.frame_id;
00045 }
00046
00047 switch ( feedback->event_type )
00048 {
00049 case visualization_msgs::InteractiveMarkerFeedback::POSE_UPDATE:
00050 manage_vt->set_attractor_point(feedback->pose.position.x, feedback->pose.position.y, 2.0*asin(feedback->pose.orientation.z));
00051
00052 break;
00053 }
00054
00055 server->applyChanges();
00056 }
00057
00058
00059 Marker makeBox( InteractiveMarker &msg )
00060 {
00061 Marker marker;
00062
00063 marker.type = Marker::ARROW;
00064 marker.scale.x = msg.scale;
00065 marker.scale.y = msg.scale;
00066 marker.scale.z = msg.scale;
00067 marker.color.r = 0;
00068 marker.color.g = 0.7;
00069 marker.color.b = 0;
00070 marker.color.a = 0.6;
00071 return marker;
00072 }
00073
00074
00075 InteractiveMarkerControl& makeBoxControl( InteractiveMarker &msg )
00076 {
00077 InteractiveMarkerControl control;
00078 control.always_visible = true;
00079 control.markers.push_back( makeBox(msg) );
00080 msg.controls.push_back( control );
00081
00082 return msg.controls.back();
00083 }
00084
00085
00086 void make6DofMarker( bool fixed )
00087 {
00088 InteractiveMarker int_marker;
00089 int_marker.header.frame_id = "/vehicle_odometry";
00090 int_marker.pose.position.x = 5;
00091 int_marker.pose.position.y = 0;
00092 int_marker.pose.position.z = 0;
00093 int_marker.scale = 0.4;
00094
00095 int_marker.name = "Control target";
00096 int_marker.description = "Control the final \nposition of the robot";
00097
00098
00099 makeBoxControl(int_marker);
00100 InteractiveMarkerControl control;
00101
00102 control.orientation.w = 1;
00103 control.orientation.x = 1;
00104 control.orientation.y = 0;
00105 control.orientation.z = 0;
00106 control.name = "move_x";
00107 control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
00108 int_marker.controls.push_back(control);
00109
00110 control.orientation.w = 1;
00111 control.orientation.x = 0;
00112 control.orientation.y = 0;
00113 control.orientation.z = 1;
00114 control.name = "move_y";
00115 control.interaction_mode = InteractiveMarkerControl::MOVE_AXIS;
00116 int_marker.controls.push_back(control);
00117
00118 control.orientation.w = 1;
00119 control.orientation.x = 0;
00120 control.orientation.y = 1;
00121 control.orientation.z = 0;
00122 control.interaction_mode = InteractiveMarkerControl::ROTATE_AXIS;
00123 control.name = "rotate_z";
00124 int_marker.controls.push_back(control);
00125
00126 server->insert(int_marker);
00127 server->setCallback(int_marker.name, &processFeedback);
00128 }
00129 #endif