prop.py
Go to the documentation of this file.
00001 import ConfigParser, os
00002 import rospy
00003 
00004 class Marker():
00005     def __init__(self):
00006         self.name = ''
00007         self.position = [0,0,0]
00008     def __str__(self):
00009         return "%s: %f %f %f"%(self.name, self.position[0], self.position[1],
00010                               self.position[2])
00011 
00012 class Prop():
00013     def __init__(self):
00014         self.Name=''
00015         self.ExtraStretch=0.1
00016         self.PositionOffset=[0, 0, 0]
00017         self.RotationOrder='ZYX'
00018         self.OrientationOffset = [0, 0, 0]
00019         self.Markers=[]
00020 
00021     def __str__(self):
00022         str = ''
00023         str = str + ("[%s]\n"%(self.Name))
00024         #print "PositionOffset: %f %f"%([0,1])
00025         #print ["{0:f}".format(i) for i in self.PositionOffset])
00026         str =  str + ("\n".join("%s"%(x) for x in self.Markers))
00027         return str
00028         # print "RotationOrder: %f %f %f"%(self.PositionOffset[:])
00029         # print "OrientationOffset: %f %f %f"%(self.PositionOffset)
00030         # print "ExtraStretch: %f"%(self.PositionOffset)
00031         # print "Number of markers: %i"%(self.PositionOffset)
00032 
00033     def parse_prop_file(self,file):
00034         config = ConfigParser.ConfigParser()
00035         config.readfp(file)
00036         self.Name = config.get('RigidBody','Name',1)
00037         if self.Name == '':
00038             return False
00039         self.ExtraStretch = config.getfloat('RigidBody','ExtraStretch')
00040         self.RotationOrder = config.get('RigidBody','RotationOrder')
00041         # now the more difficult stuff
00042         pos_offset = config.get('RigidBody','PositionOffset')
00043         self.PositionOffset = [float(x) for x in eval(pos_offset)]
00044         orientation_offset = config.get('RigidBody','OrientationOffset')
00045         self.OrientationOffset = [float(x) for x in eval(orientation_offset)]
00046         markers = config.get('RigidBody','NumberOfMarkers')
00047         m = markers.split('\n')
00048         number_of_markers = int(m[0])
00049         for x in m[1:]:
00050             line = x.split(',')
00051             marker = Marker()
00052             elements = [s.strip() for s in line]
00053             if len(elements) != 6:
00054                 rospy.logerr( "Parsing of Markers failed!" )
00055                 return False
00056             marker.name = elements[4]
00057             marker.position[0] = float(elements[0])/1000
00058             marker.position[1] = float(elements[1])/1000
00059             marker.position[2] = float(elements[2])/1000
00060             self.Markers.append(marker)
00061             # TODO: what is the remainder?
00062         rospy.loginfo("parsing of %s done"%(self.Name))
00063         return True
00064 
00065 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


cortex_stream
Author(s): Daniel Maier
autogenerated on Wed Oct 31 2012 08:22:56