コード例 #1
0
 def mean_stddev_bias(self,name):
     parent = element(name)
     sub(parent,'mean').text='0'
     sub(parent,'stddev').text='0.0002'
     sub(parent,'bias_mean').text='7.5e-06'
     sub(parent,'bias_stddev').text='8e-07'
     return parent
コード例 #2
0
 def inertial(self,mass,inertia):
     #<inertial>
     ##<mass value="mass">
     ##<inertia/>
     #</inertial>
     inertial = element('inertial')
     sub(inertial,'mass',value=str(mass))
     inertial.append(inertia)
     return inertial
コード例 #3
0
 def sensor_imu(self,bodyname):
     self.robot.append(self.gazebo_ros_imu(bodyname))
     gazebo = element('gazebo',reference=bodyname+'_imuframe')
     sensor = element('sensor',name=bodyname+'_imu',type='imu')
     sub(sensor,'imuTransform').text='0 0 0 0 0 0'
     sub(sensor,'always_on').text='true'
     sub(sensor,'pose').text='0 0 0 0 0 0'
     imu = sub(sensor,'imu')
     imu.append(self.noise_gaussian())
     self.robot.append(gazebo)
コード例 #4
0
    def gazebo(self,refname,color=None,selfcollide=None,sensor=None):
        #<gazebo reference="refname">
        ##<material></material>
        ##<selfCollide></self...>
        ##<plugin/>
        gazebo = element('gazebo',reference=refname)

        if not color is None:
            sub(gazebo,'material').text = 'Gazebo/'+color
        if not selfcollide is None:
            sub(gazebo,'selfCollide').text='true'
        #!!!now printing...!!!#
        if sensor == 'imu':
            self.sensor_imu(refname)

        return gazebo
コード例 #5
0
ファイル: genLAUNCH.py プロジェクト: yi0x262/URDFgenerator
    def robot_state_publisher(self, robotname, pkgname):
        sub(self.launch,
            'arg',
            name='model',
            default='$(find {})/urdf/{}.urdf'.format(pkgname, robotname))
        sub(self.launch,
            'param',
            name='robot_description',
            textfile='$(arg model)')
        sub(self.launch,
            'rosparam',
            file='$(find {})/config/{}.yaml'.format(pkgname, robotname),
            command='load')  #very important

        jsp = self.node('joint_state_publisher', 'joint_state_publisher',
                        'joint_state_publisher')
        rsp = self.node('robot_state_publisher',
                        'robot_state_publisher',
                        'robot_state_publisher',
                        respawn='false',
                        output='screen')
        od = OrderedDict(
        )  #Because element(and python's func) cannot take 'from'(like import,def and so on) as an argument.
        od['from'] = '/joint_states'
        od['to'] = '/' + robotname + '/joint_states'
        rsp.append(element('remap', od))
        self.launch.append(rsp)
コード例 #6
0
    def transmission(self,jointname):
        #<transmission name="..._tr">
        ##<type></type>
        ##<joint>
        ###<hardwareInterface/>
        ##</joint>
        ##<actuator>
        ###<hardwareInterface/>
        ##</actuator>
        #</transmission>

        tr = element('transmission',name=jointname+'_tr')
        #type
        sub(tr,'type').text = 'transmission_interface/SimpleTransmission'
        #joint
        joint = sub(tr,'joint',name=jointname)
        joint.append(self.hardwareInterface('EffortJointInterface'))
        #actuator
        actuator = sub(tr,'actuator',name=jointname+'_mtr')
        actuator.append(self.hardwareInterface('EffortJointInterface'))
        sub(actuator,'mechanicalReduction').text = '1'
        return tr
コード例 #7
0
 def link(self,name,origin,inertial,geometry,gazebo):
     #init link
     #<link>
     ##<inertial/>
     ##<visual/>
     ##<collision/>
     #</link>
     #<gazebo reference=name/>
     link = sub(self.robot,'link',name=name)
     link.append(inertial)
     link.append(self.visual(name,copy(origin),copy(geometry)))
     link.append(self.collision(name,copy(origin),copy(geometry)))
     #gazebo reference
     self.robot.append(gazebo)
コード例 #8
0
 def joint_revolute(self,name,parent,child,xyz,rpy,axis,limits):
     #<joint name="name" type="revolute">
     ##<parent link="parentname"/>
     ##<child link="childname"/>
     ##<origin/>
     ##<axis xyz="xyz"/>
     ##<limit params="limits"/>#<-inaccuracy
     #</joint>
     #<transmission/>
     joint = sub(self.robot,'joint',name=name,type='revolute')
     joint.extend(self.parentchild(parent,child))
     joint.append(self.origin(xyz,rpy))
     joint.append(self.axis(axis))
     joint.append(self.limits_revolute(limits))
     self.robot.append(self.transmission(name))
コード例 #9
0
 def noise_gaussian(self):
     #<noise>
     ##<type>gaussian</>
     ##<rate>
     ###<mean>0.0</>
     ###<stddev>0.03</>
     ###<bias_mean>7.5e-06</>
     ###<bias_stddev>8e-07</>
     ##</rate>
     ##<accel>
     ###...
     ##</accel>
     #</noise>
     noise = element('noise')
     sub(noise,'type').text='gaussian'
     rate = self.mean_stddev_bias('rate')
     accel = self.mean_stddev_bias('accel')
     noise.extend((rate,accel))
     return noise
コード例 #10
0
 def gazebo_ros_imu(self,bodyname):
     #ref:https://gitlab.com/nasa-jsc-robotics/val_description/blob/ddaf8378741839f26ae6d734dbe6e4441b9b1e23/model/robots/common/xacro/sensors/microstrain.xacro
     gazebo = element('gazebo')
     plugin = element('plugin',name='gazebo_ros_imu',filename='libgazebo_ros_imu.so')
     sub(plugin,'topicName').text=bodyname+'/imu'
     sub(plugin,'bodyName').text=bodyname
     sub(plugin,'serviceName').text=bodyname+'/imu_service'
     sub(plugin,'frameName').text=bodyname+'_imuframe'
     sub(plugin,'updateRate').text='100.0'
     sub(plugin,'gaussianNoise').text='0.0'
     #sub(plugin,'xyzOffset').text='0,0,0'
     #sub(plugin,'rpyOffset').text='0,0,0'
     gazebo.append(plugin)
     return gazebo
コード例 #11
0
 def gazebo_ros_control(self,robotname):
     gazebo = element('gazebo')
     plugin = sub(gazebo,'plugin',name='gazebo_ros_control',filename='libgazebo_ros_control.so')
     sub(plugin,'robotNamespace').text = robotname
     sub(plugin,'robotSimType').text = 'gazebo_ros_control/DefaultRobotHWSim'
     return gazebo
コード例 #12
0
 def joint_fixed(self,name,parent,child):
     #<joint name="name" type="fixed">
     ##<parent link="parentname"/>
     #</joint>
     joint = sub(self.robot,'joint',name=name,type='fixed')
     joint.extend(self.parentchild(parent,child))
コード例 #13
0
ファイル: snippet.py プロジェクト: someburner/GistsHub
from plistlib import readPlist
from cgi import escape
from lxml.etree import SubElement as sub
import lxml.etree

# Load in apple mail rules file
rules_file = '~/Library/Mail/V2/MailData/SyncedRules.plist'
rules = readPlist(rules_file)

# Create gmail filters xml header
APPS_NAMESPACE = 'http://schemas.google.com/apps/2006'
NSMAP = {None: 'http://www.w3.org/2005/Atom', 'apps': APPS_NAMESPACE}
feed = lxml.etree.Element('feed', nsmap=NSMAP)
title = sub(feed, 'title').text = 'Mail Filters'

author = sub(feed, 'author')
sub(author, 'name').text = 'Adam Walz'
sub(author, 'email').text = '*****@*****.**'

# Parse apple mail rules
prop = '{' + APPS_NAMESPACE + "}property"
for rule in rules:
    if rule['Criteria'][0]['Header'] == 'AnyMessage':
        continue

    # All mail rules have the following sub elements
    entry = sub(feed, 'entry')
    sub(entry, 'category', attrib={'term': 'filter'})
    sub(entry, 'title').text = 'Mail Filter'
    sub(entry, 'content')
コード例 #14
0
ファイル: genLAUNCH.py プロジェクト: yi0x262/URDFgenerator
 def empty_world(self, **args):
     include = element('include',
                       file='$(find gazebo_ros)/launch/empty_world.launch')
     for i, j in args.items():
         sub(include, 'arg', name=i, value=j)
     self.launch.append(include)