Go to the documentation of this file.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
00028
00029
00030 #include <moveit/robot_interaction/interactive_marker_helpers.h>
00031 #include <tf/transform_datatypes.h>
00032
00033 #include <boost/math/constants/constants.hpp>
00034
00035 namespace robot_interaction
00036 {
00037
00038 visualization_msgs::InteractiveMarker makeEmptyInteractiveMarker(const std::string& name,
00039 const geometry_msgs::PoseStamped &stamped,
00040 double scale)
00041 {
00042 visualization_msgs::InteractiveMarker int_marker;
00043 int_marker.header = stamped.header;
00044 int_marker.name = name;
00045 int_marker.scale = scale;
00046 int_marker.pose = stamped.pose;
00047 return int_marker;
00048 }
00049
00050 void addTArrowMarker(visualization_msgs::InteractiveMarker &im)
00051 {
00052
00053 visualization_msgs::Marker m;
00054 m.type = visualization_msgs::Marker::ARROW;
00055 m.scale.x = 0.6 * im.scale;
00056 m.scale.y = 0.12 * im.scale;
00057 m.scale.z = 0.12 * im.scale;
00058 m.ns = "goal_pose_arrow_marker";
00059 m.id = 1;
00060 m.action = visualization_msgs::Marker::ADD;
00061 m.header = im.header;
00062 m.pose = im.pose;
00063
00064 tf::Quaternion imq;
00065 tf::quaternionMsgToTF(m.pose.orientation, imq);
00066 imq=imq*tf::createQuaternionFromRPY(0, -boost::math::constants::pi<double>() / 2.0, 0);
00067 tf::quaternionTFToMsg(imq, m.pose.orientation);
00068 m.color.r = 0.0f;
00069 m.color.g = 1.0f;
00070 m.color.b = 0.0f;
00071 m.color.a = 1.0f;
00072
00073 visualization_msgs::Marker mc;
00074 mc.type = visualization_msgs::Marker::CYLINDER;
00075 mc.scale.x = 0.05 * im.scale;
00076 mc.scale.y = 0.05 * im.scale;
00077 mc.scale.z = 0.15 * im.scale;
00078 mc.ns = "goal_pose_arrow_marker";
00079 mc.id = 2;
00080 mc.action = visualization_msgs::Marker::ADD;
00081 mc.header = im.header;
00082 mc.pose = im.pose;
00083
00084 tf::quaternionMsgToTF(mc.pose.orientation, imq);
00085 imq=imq*tf::createQuaternionFromRPY(boost::math::constants::pi<double>() / 2.0, 0, 0);
00086 tf::quaternionTFToMsg(imq, mc.pose.orientation);
00087 mc.pose.position.x -= 0.04;
00088 mc.pose.position.z += 0.01;
00089 mc.color.r = 0.0f;
00090 mc.color.g = 1.0f;
00091 mc.color.b = 0.0f;
00092 mc.color.a = 1.0f;
00093
00094 visualization_msgs::InteractiveMarkerControl m_control;
00095 m_control.always_visible = true;
00096 m_control.interaction_mode=m_control.BUTTON;
00097 m_control.markers.push_back(m);
00098 m_control.markers.push_back(mc);
00099
00100
00101 im.controls.push_back(m_control);
00102 }
00103
00104 void addErrorMarker(visualization_msgs::InteractiveMarker &im)
00105 {
00106
00107 visualization_msgs::Marker err;
00108 err.type = visualization_msgs::Marker::MESH_RESOURCE;
00109 err.scale.x = 0.002 * im.scale;
00110 err.scale.y = 0.002 * im.scale;
00111 err.scale.z = 0.002 * im.scale;
00112 err.mesh_resource = "package://moveit_ros_planning_interface/resources/access-denied.dae";
00113 err.ns = "robot_interaction_error";
00114 err.id = 1;
00115 err.action = visualization_msgs::Marker::ADD;
00116 err.header = im.header;
00117 err.pose = im.pose;
00118 err.pose.orientation.x = err.pose.orientation.y = 0.7071067811865476;
00119 err.pose.orientation.z = err.pose.orientation.w = 0.0;
00120 err.color.r = 1.0f;
00121 err.color.g = 0.0f;
00122 err.color.b = 0.0f;
00123 err.color.a = 1.0f;
00124
00125 visualization_msgs::InteractiveMarkerControl err_control;
00126 err_control.always_visible = false;
00127 err_control.markers.push_back(err);
00128
00129
00130 im.controls.push_back(err_control);
00131 }
00132
00133 void addPlanarXYControl(visualization_msgs::InteractiveMarker& int_marker, bool orientation_fixed)
00134 {
00135 visualization_msgs::InteractiveMarkerControl control;
00136
00137 if (orientation_fixed)
00138 control.orientation_mode = visualization_msgs::InteractiveMarkerControl::FIXED;
00139 control.orientation.w = 1;
00140 control.orientation.x = 1;
00141 control.orientation.y = 0;
00142 control.orientation.z = 0;
00143 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
00144 int_marker.controls.push_back(control);
00145
00146 control.orientation.w = 1;
00147 control.orientation.x = 0;
00148 control.orientation.y = 1;
00149 control.orientation.z = 0;
00150 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
00151 int_marker.controls.push_back(control);
00152
00153 control.orientation.w = 1;
00154 control.orientation.x = 0;
00155 control.orientation.y = 0;
00156 control.orientation.z = 1;
00157 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
00158 int_marker.controls.push_back(control);
00159 }
00160
00161 void add6DOFControl(visualization_msgs::InteractiveMarker& int_marker, bool orientation_fixed)
00162 {
00163 addOrientationControl(int_marker, orientation_fixed);
00164 addPositionControl(int_marker, orientation_fixed);
00165 }
00166
00167 void addOrientationControl(visualization_msgs::InteractiveMarker& int_marker, bool orientation_fixed)
00168 {
00169 visualization_msgs::InteractiveMarkerControl control;
00170
00171 if (orientation_fixed)
00172 control.orientation_mode = visualization_msgs::InteractiveMarkerControl::FIXED;
00173 control.orientation.w = 1;
00174 control.orientation.x = 1;
00175 control.orientation.y = 0;
00176 control.orientation.z = 0;
00177 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
00178 int_marker.controls.push_back(control);
00179
00180 control.orientation.w = 1;
00181 control.orientation.x = 0;
00182 control.orientation.y = 1;
00183 control.orientation.z = 0;
00184 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
00185 int_marker.controls.push_back(control);
00186
00187 control.orientation.w = 1;
00188 control.orientation.x = 0;
00189 control.orientation.y = 0;
00190 control.orientation.z = 1;
00191 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_AXIS;
00192 int_marker.controls.push_back(control);
00193 }
00194
00195 void addPositionControl(visualization_msgs::InteractiveMarker& int_marker, bool orientation_fixed)
00196 {
00197 visualization_msgs::InteractiveMarkerControl control;
00198
00199 if (orientation_fixed)
00200 control.orientation_mode = visualization_msgs::InteractiveMarkerControl::FIXED;
00201 control.orientation.w = 1;
00202 control.orientation.x = 1;
00203 control.orientation.y = 0;
00204 control.orientation.z = 0;
00205 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
00206 int_marker.controls.push_back(control);
00207
00208 control.orientation.w = 1;
00209 control.orientation.x = 0;
00210 control.orientation.y = 1;
00211 control.orientation.z = 0;
00212 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
00213 int_marker.controls.push_back(control);
00214
00215 control.orientation.w = 1;
00216 control.orientation.x = 0;
00217 control.orientation.y = 0;
00218 control.orientation.z = 1;
00219 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_AXIS;
00220 int_marker.controls.push_back(control);
00221 }
00222
00223 void addViewPlaneControl(visualization_msgs::InteractiveMarker& int_marker, double radius, const std_msgs::ColorRGBA& color, bool position, bool orientation)
00224 {
00225 visualization_msgs::InteractiveMarkerControl control;
00226 control.orientation_mode = visualization_msgs::InteractiveMarkerControl::VIEW_FACING;
00227 if (position && orientation)
00228 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_ROTATE_3D;
00229 else if (orientation)
00230 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::ROTATE_3D;
00231 else
00232 control.interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_3D;
00233 control.independent_marker_orientation = true;
00234 control.name = "move";
00235
00236 visualization_msgs::Marker marker;
00237
00238 marker.type = visualization_msgs::Marker::SPHERE;
00239 marker.scale.x = radius * 2.0;
00240 marker.scale.y = radius * 2.0;
00241 marker.scale.z = radius * 2.0;
00242 marker.color = color;
00243
00244 control.markers.push_back( marker );
00245 control.always_visible = false;
00246
00247 int_marker.controls.push_back(control);
00248 }
00249
00250 visualization_msgs::InteractiveMarker makePlanarXYMarker(const std::string& name,
00251 const geometry_msgs::PoseStamped &stamped,
00252 double scale,
00253 bool orientation_fixed)
00254 {
00255 visualization_msgs::InteractiveMarker int_marker = makeEmptyInteractiveMarker(name, stamped, scale);
00256 addPlanarXYControl(int_marker, orientation_fixed);
00257 return int_marker;
00258 }
00259
00260 visualization_msgs::InteractiveMarker make6DOFMarker(const std::string& name,
00261 const geometry_msgs::PoseStamped &stamped,
00262 double scale,
00263 bool orientation_fixed)
00264 {
00265 visualization_msgs::InteractiveMarker int_marker = makeEmptyInteractiveMarker(name, stamped, scale);
00266 add6DOFControl(int_marker, orientation_fixed);
00267 return int_marker;
00268 }
00269
00270 }