marker_helper.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 """
00004 Copyright (c) 2012, General Motors, Co.
00005 All rights reserved.
00006 
00007 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00008 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00009 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00010 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00011 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00012 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00013 SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS OR BUSINESS
00014 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00015 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00016 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00017 POSSIBILITY OF SUCH DAMAGE.
00018 """
00019 
00020 from interactive_markers.interactive_marker_server import *
00021 from interactive_markers.menu_handler import *
00022 
00023 def makeBox( msg ):
00024     marker = Marker()
00025     marker.type = Marker.CUBE
00026     marker.scale.x = msg.scale * 0.25
00027     marker.scale.y = msg.scale * 0.25
00028     marker.scale.z = msg.scale * 0.25
00029     marker.color.r = 0.5
00030     marker.color.g = 0.5
00031     marker.color.b = 0.5
00032     marker.color.a = 1.0
00033     return marker
00034 
00035 def makeSphere( msg, scale ):
00036     marker = Marker()
00037     marker.type = Marker.SPHERE
00038     marker.scale.x = msg.scale * scale
00039     marker.scale.y = msg.scale * scale
00040     marker.scale.z = msg.scale * scale
00041     marker.color.r = 1.0
00042     marker.color.g = 1.0
00043     marker.color.b = 1.0
00044     marker.color.a = 1.0
00045     return marker
00046 
00047 def makeMesh( msg, mesh_str, p, sf=1 ):
00048     marker = Marker()
00049     marker.type = Marker.MESH_RESOURCE
00050     marker.scale.x = sf
00051     marker.scale.y = sf
00052     marker.scale.z = sf
00053     marker.color.r = 0.0
00054     marker.color.g = 0.5
00055     marker.color.b = 0.0
00056     marker.color.a = 0.5
00057     marker.pose = p
00058     marker.mesh_resource = mesh_str
00059     return marker
00060 
00061 def makeBoxControl( msg ):
00062     control =  InteractiveMarkerControl()
00063     control.always_visible = False
00064     control.markers.append( makeBox(msg) )
00065     msg.controls.append( control )
00066     return control
00067 
00068 def makeBoxMenu( msg ):
00069     control =  InteractiveMarkerControl()
00070     control.interaction_mode = InteractiveMarkerControl.MENU
00071     control.always_visible = False
00072     control.markers.append( makeBox(msg) )
00073     msg.controls.append( control )
00074     return control
00075 
00076 def makeMeshControl( msg, mesh_name, p ):
00077     control =  InteractiveMarkerControl()
00078     control.always_visible = False
00079     control.markers.append( makeMesh(msg, mesh_name, p, 0.99) )
00080     msg.controls.append( control )
00081     return control
00082 
00083 def makeSphereControl( msg, sphere ):
00084     control =  InteractiveMarkerControl()
00085     control.always_visible = False
00086     control.markers.append( makeSphere(msg, sphere) )
00087     msg.controls.append( control )
00088     return control
00089 
00090 def makeXTransControl () :
00091     control = InteractiveMarkerControl()
00092     control.orientation.w = 1
00093     control.orientation.x = 1
00094     control.orientation.y = 0
00095     control.orientation.z = 0
00096     control.name = "move_x"
00097     control.interaction_mode = InteractiveMarkerControl.MOVE_AXIS
00098     return control
00099 
00100 def makeYTransControl () :
00101     control = InteractiveMarkerControl()
00102     control.orientation.w = 1
00103     control.orientation.x = 0
00104     control.orientation.y = 1
00105     control.orientation.z = 0
00106     control.name = "move_y"
00107     control.interaction_mode = InteractiveMarkerControl.MOVE_AXIS
00108     return control
00109 
00110 def makeZTransControl () :
00111     control = InteractiveMarkerControl()
00112     control.orientation.w = 1
00113     control.orientation.x = 0
00114     control.orientation.y = 0
00115     control.orientation.z = 1
00116     control.name = "move_z"
00117     control.interaction_mode = InteractiveMarkerControl.MOVE_AXIS
00118     return control
00119 
00120 def makeXRotControl () :
00121     control = InteractiveMarkerControl()
00122     control.orientation.w = 1
00123     control.orientation.x = 1
00124     control.orientation.y = 0
00125     control.orientation.z = 0
00126     control.name = "rotate_x"
00127     control.interaction_mode = InteractiveMarkerControl.ROTATE_AXIS
00128     return control
00129 
00130 def makeYRotControl () :
00131     control = InteractiveMarkerControl()
00132     control.orientation.w = 1
00133     control.orientation.x = 0
00134     control.orientation.y = 1
00135     control.orientation.z = 0
00136     control.name = "rotate_y"
00137     control.interaction_mode = InteractiveMarkerControl.ROTATE_AXIS
00138     return control
00139 
00140 def makeZRotControl () :
00141     control = InteractiveMarkerControl()
00142     control.orientation.w = 1
00143     control.orientation.x = 0
00144     control.orientation.y = 0
00145     control.orientation.z = 1
00146     control.name = "rotate_z"
00147     control.interaction_mode = InteractiveMarkerControl.ROTATE_AXIS
00148     return control
00149 
00150 
00151 


r2_teleop
Author(s): Paul Dinh
autogenerated on Fri Jan 3 2014 11:34:08