robot.py 4.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
# Copyright (c) 2019 CNRS
# Author: Pierre Fernbach
#
# This file is part of hpp-rbprm-robot-data.
# hpp_tutorial is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# hpp_tutorial is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Lesser Public License for more details.  You should have
# received a copy of the GNU Lesser General Public License along with
# hpp_tutorial.  If not, see
# <http://www.gnu.org/licenses/>.

from hpp.corbaserver.rbprm.rbprmfullbody import FullBody as Parent
from pinocchio import SE3, Quaternion
import numpy as np

class Robot (Parent):
    ##
    #  Information to retrieve urdf and srdf files.

27
28
    packageName = "anymal_description"
    meshPackageName = "anymal_description"
29
    rootJointType = "freeflyer"
30
    urdfName = "anymal"
Pierre Fernbach's avatar
Pierre Fernbach committed
31
32
    urdfSuffix = "_reachability"
    srdfSuffix = "_reachability"
33
34

    ## Information about the names of thes joints defining the limbs of the robot
Pierre Fernbach's avatar
Pierre Fernbach committed
35
36
    rLegId = 'RFleg'
    rleg = 'RF_HAA'
Pierre Fernbach's avatar
Pierre Fernbach committed
37
    rfoot = 'RF_KFE'
Pierre Fernbach's avatar
Pierre Fernbach committed
38
39
    lLegId = 'LFleg'
    lleg = 'LF_HAA'
Pierre Fernbach's avatar
Pierre Fernbach committed
40
    lfoot = 'LF_KFE'
Pierre Fernbach's avatar
Pierre Fernbach committed
41
42
    lArmId = 'LHleg'
    larm = 'LH_HAA'
Pierre Fernbach's avatar
Pierre Fernbach committed
43
    lhand = 'LH_KFE'
Pierre Fernbach's avatar
Pierre Fernbach committed
44
45
    rArmId = 'RHleg'
    rarm = 'RH_HAA'
Pierre Fernbach's avatar
Pierre Fernbach committed
46
    rhand = 'RH_KFE'
47
48


Pierre Fernbach's avatar
Pierre Fernbach committed
49
    referenceConfig =[0.,0.,0.444, 0.,0.,0.,1., # FF
Pierre Fernbach's avatar
Pierre Fernbach committed
50
51
52
53
        0.04, 0.74, -1.08,0.34,-0.04,0.,
        0.04, -0.74, 1.08,-0.34,-0.04,0.,
        -0.04, 0.74, -1.08,0.34,0.04, 0.,
        -0.04, -0.74, 1.08,-0.34,0.04,0.
Pierre Fernbach's avatar
Pierre Fernbach committed
54
        ]
55
56
    
    # informations required to generate the limbs databases the limbs : 
Pierre Fernbach's avatar
Pierre Fernbach committed
57
58
59
    nbSamples = 50000
    octreeSize = 0.01
    cType = "_3_DOF"
Pierre Fernbach's avatar
Pierre Fernbach committed
60
    offset = [0.,0.,-0.33]
61
62
    normal = [0,0,1]
    legx = 0.02; legy = 0.02
Pierre Fernbach's avatar
Pierre Fernbach committed
63
    kinematicConstraintsPath="package://anymal-rbprm/com_inequalities/"
64
65
66
67
    rLegKinematicConstraints=kinematicConstraintsPath+rleg+"_com_constraints.obj"
    lLegKinematicConstraints=kinematicConstraintsPath+lleg+"_com_constraints.obj" 
    rArmKinematicConstraints=kinematicConstraintsPath+rarm+"_com_constraints.obj" 
    lArmKinematicConstraints=kinematicConstraintsPath+larm+"_com_constraints.obj"
Pierre Fernbach's avatar
Pierre Fernbach committed
68
    minDist = 0.2    
69
70

    # data used by scripts :
Pierre Fernbach's avatar
Pierre Fernbach committed
71
72
    limbs_names = [rLegId,lArmId,lLegId,rArmId] # default order to try to remove contacts at the beginning of the contact plan
    dict_limb_rootJoint = {rLegId:rleg, lLegId:lleg, rArmId:rarm, lArmId:larm}
73
74
75
76
    dict_limb_joint = {rLegId:rfoot, lLegId:lfoot, rArmId:rhand, lArmId:lhand}
    dict_limb_color_traj = {rfoot:[0,1,0,1], lfoot:[1,0,0,1],rhand:[0,0,1,1],lhand:[0.9,0.5,0,1]}
    FOOT_SAFETY_SIZE = 0.01
    # size of the contact surface (x,y)
Pierre Fernbach's avatar
Pierre Fernbach committed
77
    dict_size={rfoot:[0.031 , 0.031], lfoot:[0.031 , 0.031],rhand:[0.031 , 0.031],lhand:[0.031 , 0.031]}
78
79
80
81
82
83
84
85

    #various offset used by scripts
    MRsole_offset = SE3.Identity()
    MRsole_offset.translation = np.matrix(offset).T
    MLsole_offset = MRsole_offset.copy()
    MRhand_offset = MRsole_offset.copy()
    MLhand_offset = MRsole_offset.copy()
    dict_offset = {rfoot:MRsole_offset, lfoot:MLsole_offset, rhand:MRhand_offset, lhand:MLhand_offset}
Pierre Fernbach's avatar
Pierre Fernbach committed
86
    dict_normal = {rfoot:normal, lfoot:normal, rhand:normal, lhand:normal}
87
88
89
90
91
92
93
94
95
96
97
98
99
    # display transform :
    MRsole_display = SE3.Identity()
    MLsole_display = SE3.Identity()
    MRhand_display = SE3.Identity()
    MLhand_display = SE3.Identity()
    dict_display_offset = {rfoot:MRsole_display, lfoot:MLsole_display, rhand:MRhand_display, lhand:MLhand_display}

    def __init__ (self, name = None,load = True):
        Parent.__init__ (self,load)
        if load:
            self.loadFullBodyModel(self.urdfName, self.rootJointType, self.meshPackageName, self.packageName, self.urdfSuffix, self.srdfSuffix)
        if name != None:
            self.name = name
Pierre Fernbach's avatar
Pierre Fernbach committed
100
101
102

    def loadAllLimbs(self,heuristic, analysis = None, nbSamples = nbSamples, octreeSize = octreeSize):
        for id in self.limbs_names:
Pierre Fernbach's avatar
Pierre Fernbach committed
103
            print "add limb : ",id
Pierre Fernbach's avatar
Pierre Fernbach committed
104
            eff = self.dict_limb_joint[id]
Pierre Fernbach's avatar
Pierre Fernbach committed
105
            print "effector name = ",eff
106
            self.addLimb(id,self.dict_limb_rootJoint[id],eff,self.dict_offset[eff].translation.T.tolist()[0],self.dict_normal[eff],self.dict_size[eff][0]/2.,self.dict_size[eff][1]/2.,nbSamples,heuristic,octreeSize,self.cType,kinematicConstraintsPath=self.kinematicConstraintsPath+self.dict_limb_rootJoint[id]+"_com_constraints.obj",kinematicConstraintsMin=self.minDist)
Pierre Fernbach's avatar
Pierre Fernbach committed
107
108
109
            if analysis :
                self.runLimbSampleAnalysis(id, analysis, True)