Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jason Chemin
hpp-rbprm-corba
Commits
6975a6ac
Commit
6975a6ac
authored
Apr 30, 2018
by
Pierre Fernbach
Browse files
update script for stairs
parent
7e3a5d45
Changes
2
Hide whitespace changes
Inline
Side-by-side
script/dynamic/stairs10_hrp2_interStatic.py
0 → 100644
View file @
6975a6ac
from
hpp.corbaserver.rbprm.rbprmbuilder
import
Builder
from
hpp.corbaserver.rbprm.rbprmfullbody
import
FullBody
from
hpp.gepetto
import
Viewer
from
tools
import
*
import
stairs10_hrp2_pathKino
as
tp
import
time
import
omniORB.any
from
constraint_to_dae
import
*
from
display_tools
import
*
from
planning.configs.stairs10_bauzil_stairs
import
*
from
disp_bezier
import
*
from
hpp.corbaserver.rbprm.rbprmstate
import
State
,
StateHelper
packageName
=
"hrp2_14_description"
meshPackageName
=
"hrp2_14_description"
rootJointType
=
"freeflyer"
##
# Information to retrieve urdf and srdf files.
urdfName
=
"hrp2_14"
urdfSuffix
=
"_reduced_safe20"
srdfSuffix
=
""
pId
=
tp
.
ps
.
numberPaths
()
-
1
fullBody
=
FullBody
()
tPlanning
=
0.
fullBody
.
loadFullBodyModel
(
urdfName
,
rootJointType
,
meshPackageName
,
packageName
,
urdfSuffix
,
srdfSuffix
)
fullBody
.
setJointBounds
(
"base_joint_xyz"
,
[
0
,
2
,
0.6
,
1.1
,
0.35
,
1.5
])
fullBody
.
setJointBounds
(
"LLEG_JOINT3"
,
[
0.4
,
2.61799
])
fullBody
.
setJointBounds
(
"RLEG_JOINT3"
,
[
0.4
,
2.61799
])
fullBody
.
client
.
basic
.
robot
.
setDimensionExtraConfigSpace
(
tp
.
extraDof
)
fullBody
.
client
.
basic
.
robot
.
setExtraConfigSpaceBounds
([
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
])
ps
=
tp
.
ProblemSolver
(
fullBody
)
ps
.
client
.
problem
.
setParameter
(
"aMax"
,
omniORB
.
any
.
to_any
(
tp
.
aMax
))
ps
.
client
.
problem
.
setParameter
(
"vMax"
,
omniORB
.
any
.
to_any
(
tp
.
vMax
))
r
=
tp
.
Viewer
(
ps
,
viewerClient
=
tp
.
r
.
client
,
displayArrows
=
False
,
displayCoM
=
True
)
view
=
[
0.8
,
0.75
,
4.85
,
-
0.7071
,
0
,
0
,
0.7071
]
r
.
client
.
gui
.
setCameraTransform
(
0
,
view
)
q_init
=
[
0
,
0
,
0.648702
,
1.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.261799388
,
0.174532925
,
0.0
,
-
0.523598776
,
0.0
,
0.0
,
0.17
,
0.261799388
,
-
0.174532925
,
0.0
,
-
0.523598776
,
0.0
,
0.0
,
0.17
,
0.0
,
0.0
,
-
0.453785606
,
0.872664626
,
-
0.41887902
,
0.0
,
0.0
,
0.0
,
-
0.453785606
,
0.872664626
,
-
0.41887902
,
0.0
,
0
,
0
,
0
,
0
,
0
,
0
];
r
(
q_init
)
q_ref
=
q_init
[::]
fullBody
.
setCurrentConfig
(
q_init
)
fullBody
.
setReferenceConfig
(
q_init
)
#~ AFTER loading obstacles
tStart
=
time
.
time
()
rLegOffset
=
[
0
,
0
,
-
0.0955
]
rLegLimbOffset
=
[
0
,
0
,
-
0.035
]
#0.035
rLegNormal
=
[
0
,
0
,
1
]
rLegx
=
0.09
;
rLegy
=
0.05
#fullBody.addLimbDatabase("./db/hrp2_rleg_db.db",rLegId,"forward")
fullBody
.
addLimb
(
rLegId
,
rleg
,
''
,
rLegOffset
,
rLegNormal
,
rLegx
,
rLegy
,
100000
,
"fixedStep06"
,
0.01
,
"_6_DOF"
,
limbOffset
=
rLegLimbOffset
,
kinematicConstraintsMin
=
0.5
)
fullBody
.
runLimbSampleAnalysis
(
rLegId
,
"ReferenceConfiguration"
,
True
)
#fullBody.saveLimbDatabase(rLegId, "./db/hrp2_rleg_db.db")
lLegOffset
=
[
0
,
0
,
-
0.0955
]
lLegLimbOffset
=
[
0
,
0
,
0.035
]
lLegNormal
=
[
0
,
0
,
1
]
lLegx
=
0.09
;
lLegy
=
0.05
#fullBody.addLimbDatabase("./db/hrp2_lleg_db.db",lLegId,"forward")
fullBody
.
addLimb
(
lLegId
,
lleg
,
''
,
lLegOffset
,
rLegNormal
,
lLegx
,
lLegy
,
100000
,
"fixedStep06"
,
0.01
,
"_6_DOF"
,
limbOffset
=
lLegLimbOffset
,
kinematicConstraintsMin
=
0.5
)
fullBody
.
runLimbSampleAnalysis
(
lLegId
,
"ReferenceConfiguration"
,
True
)
#fullBody.saveLimbDatabase(lLegId, "./db/hrp2_lleg_db.db")
tGenerate
=
time
.
time
()
-
tStart
print
"generate databases in : "
+
str
(
tGenerate
)
+
" s"
"""
fullBody.addLimbDatabase("./db/hrp2_rleg_db.db",rLegId,"forward")
fullBody.addLimbDatabase("./db/hrp2_lleg_db.db",lLegId,"forward")
tLoad = time.time() - tStart
print "Load databases in : "+str(tLoad)+" s"
"""
q_0
=
fullBody
.
getCurrentConfig
();
#~ fullBody.createOctreeBoxes(r.client.gui, 1, rarmId, q_0,)
eps
=
0.0001
configSize
=
fullBody
.
getConfigSize
()
-
fullBody
.
client
.
basic
.
robot
.
getDimensionExtraConfigSpace
()
q_init
[
0
:
7
]
=
tp
.
ps
.
configAtParam
(
pId
,
eps
)[
0
:
7
]
# use this to get the correct orientation
q_goal
=
q_ref
[::]
q_goal
[
0
:
7
]
=
tp
.
ps
.
configAtParam
(
pId
,
tp
.
ps
.
pathLength
(
pId
)
-
0.0001
)[
0
:
7
]
dir_init
=
[
0
,
0
,
0
]
acc_init
=
[
0
,
0
,
0
]
dir_goal
=
tp
.
ps
.
configAtParam
(
pId
,
eps
)[
tp
.
indexECS
:
tp
.
indexECS
+
3
]
acc_goal
=
[
0
,
0
,
0
]
robTreshold
=
3
# copy extraconfig for start and init configurations
q_init
[
configSize
:
configSize
+
3
]
=
dir_init
[::]
q_init
[
configSize
+
3
:
configSize
+
6
]
=
acc_init
[::]
q_goal
[
configSize
:
configSize
+
3
]
=
dir_goal
[::]
q_goal
[
configSize
+
3
:
configSize
+
6
]
=
[
0
,
0
,
0
]
# FIXME : test
q_init
[
2
]
=
q_ref
[
2
]
+
0.0005
q_goal
[
2
]
=
q_ref
[
2
]
+
0.6005
# Randomly generating a contact configuration at q_init
fullBody
.
setStaticStability
(
True
)
fullBody
.
setCurrentConfig
(
q_init
)
r
(
q_init
)
# Randomly generating a contact configuration at q_end
fullBody
.
setCurrentConfig
(
q_goal
)
#q_goal = fullBody.generateContacts(q_goal, dir_goal,acc_goal,robTreshold)
r
(
q_goal
)
# specifying the full body configurations as start and goal state of the problem
r
.
addLandmark
(
'hrp2_14/BODY'
,
0.3
)
r
(
q_init
)
fullBody
.
setStartState
(
q_init
,[
lLegId
,
rLegId
])
fullBody
.
setEndState
(
q_goal
,[
lLegId
,
rLegId
])
fullBody
.
setStaticStability
(
True
)
# only set it after the init/goal configuration are computed
from
hpp.gepetto
import
PathPlayer
pp
=
PathPlayer
(
fullBody
.
client
.
basic
,
r
)
import
fullBodyPlayerHrp2
tStart
=
time
.
time
()
configsFull
=
fullBody
.
interpolate
(
0.01
,
pathId
=
pId
,
robustnessTreshold
=
robTreshold
,
filterStates
=
True
,
testReachability
=
True
,
quasiStatic
=
True
)
tInterpolateConfigs
=
time
.
time
()
-
tStart
print
"number of configs : "
,
len
(
configsFull
)
print
"generated in "
+
str
(
tInterpolateConfigs
)
+
" s"
r
(
configsFull
[
len
(
configsFull
)
-
1
])
from
generate_contact_sequence
import
*
beginState
=
0
endState
=
len
(
configsFull
)
-
1
configs
=
configsFull
[
beginState
:
endState
+
1
]
cs
=
generateContactSequence
(
fullBody
,
configs
,
beginState
,
endState
,
r
)
#displayContactSequence(r,configsFull)
filename
=
OUTPUT_DIR
+
"/"
+
OUTPUT_SEQUENCE_FILE
cs
.
saveAsXML
(
filename
,
"ContactSequence"
)
print
"save contact sequence : "
,
filename
"""
s0 = State(fullBody,q=q_init,limbsIncontact = [rLegId,lLegId])
s0 = State(fullBody,q=configsFull[10],limbsIncontact = [rLegId,lLegId])
s1,success = StateHelper.removeContact(s0,lLegId)
r(s1.q())
fullBody.isReachableFromState(s1.sId,s1.sId)
displayOneStepConstraints(r)
"""
script/dynamic/stairs10_hrp2_pathKino.py
0 → 100644
View file @
6975a6ac
## Importing helper class for setting up a reachability planning problem
from
hpp.corbaserver.rbprm.rbprmbuilder
import
Builder
# Importing Gepetto viewer helper class
from
hpp.gepetto
import
Viewer
import
time
import
math
import
omniORB.any
from
planning.configs.stairs10_bauzil_stairs
import
*
from
hpp.corbaserver
import
Client
from
hpp.corbaserver.robot
import
Robot
as
Parent
from
hpp.corbaserver.rbprm.problem_solver
import
ProblemSolver
class
Robot
(
Parent
):
rootJointType
=
'freeflyer'
packageName
=
'hpp-rbprm-corba'
meshPackageName
=
'hpp-rbprm-corba'
# URDF file describing the trunk of the robot HyQ
urdfName
=
'hrp2_trunk_flexible'
urdfSuffix
=
""
srdfSuffix
=
""
def
__init__
(
self
,
robotName
,
load
=
True
):
Parent
.
__init__
(
self
,
robotName
,
self
.
rootJointType
,
load
)
self
.
tf_root
=
"base_footprint"
self
.
client
.
basic
=
Client
()
self
.
load
=
load
rootJointType
=
'freeflyer'
packageName
=
'hpp-rbprm-corba'
meshPackageName
=
'hpp-rbprm-corba'
urdfName
=
'hrp2_trunk_arms_flexible'
urdfNameRoms
=
[
rLegId
,
lLegId
,
rArmId
,
lArmId
]
urdfSuffix
=
""
srdfSuffix
=
""
# Creating an instance of the helper class, and loading the robot
rbprmBuilder
=
Builder
()
rbprmBuilder
.
loadModel
(
urdfName
,
urdfNameRoms
,
rootJointType
,
meshPackageName
,
packageName
,
urdfSuffix
,
srdfSuffix
)
# The following lines set constraint on the valid configurations:
# a configuration is valid only if all limbs can create a contact ...
rbprmBuilder
.
setFilter
([
'hrp2_lleg_rom'
,
'hrp2_rleg_rom'
])
#rbprmBuilder.setAffordanceFilter('hrp2_rarm_rom', ['Lean'])
#rbprmBuilder.setAffordanceFilter('hrp2_larm_rom', ['Lean'])
rbprmBuilder
.
setAffordanceFilter
(
'hrp2_lleg_rom'
,
[
'Support'
,])
rbprmBuilder
.
setAffordanceFilter
(
'hrp2_rleg_rom'
,
[
'Support'
])
vMax
=
0.2
;
aMax
=
0.1
;
extraDof
=
6
rbprmBuilder
.
setJointBounds
(
"base_joint_xyz"
,
[
0
,
2
,
0.6
,
1.1
,
0.45
,
1.5
])
rbprmBuilder
.
setJointBounds
(
'CHEST_JOINT0'
,[
-
0.05
,
0.05
])
rbprmBuilder
.
setJointBounds
(
'CHEST_JOINT1'
,[
-
0.05
,
0.05
])
# We also bound the rotations of the torso. (z, y, x)
rbprmBuilder
.
boundSO3
([
-
math
.
pi
,
math
.
pi
,
-
0.1
,
0.1
,
-
0.1
,
0.1
])
rbprmBuilder
.
client
.
basic
.
robot
.
setDimensionExtraConfigSpace
(
extraDof
)
rbprmBuilder
.
client
.
basic
.
robot
.
setExtraConfigSpaceBounds
([
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
])
indexECS
=
rbprmBuilder
.
getConfigSize
()
-
rbprmBuilder
.
client
.
basic
.
robot
.
getDimensionExtraConfigSpace
()
# Creating an instance of HPP problem solver and the viewer
from
hpp.corbaserver.rbprm.problem_solver
import
ProblemSolver
ps
=
ProblemSolver
(
rbprmBuilder
)
ps
.
client
.
problem
.
setParameter
(
"aMax"
,
omniORB
.
any
.
to_any
(
aMax
))
ps
.
client
.
problem
.
setParameter
(
"vMax"
,
omniORB
.
any
.
to_any
(
vMax
))
ps
.
client
.
problem
.
setParameter
(
"orientedPath"
,
omniORB
.
any
.
to_any
(
0.
))
ps
.
client
.
problem
.
setParameter
(
"friction"
,
omniORB
.
any
.
to_any
(
MU
))
ps
.
client
.
problem
.
setParameter
(
"sizeFootX"
,
omniORB
.
any
.
to_any
(
0.24
))
ps
.
client
.
problem
.
setParameter
(
"sizeFootY"
,
omniORB
.
any
.
to_any
(
0.14
))
r
=
Viewer
(
ps
,
displayArrows
=
True
)
from
hpp.corbaserver.affordance.affordance
import
AffordanceTool
afftool
=
AffordanceTool
()
afftool
.
setAffordanceConfig
(
'Support'
,
[
0.5
,
0.03
,
0.2
])
afftool
.
loadObstacleModel
(
packageName
,
ENV_NAME
,
ENV_PREFIX
,
r
,
reduceSizes
=
[
0.17
,
0
,
0
])
#r.loadObstacleModel (packageName, "ground", "planning")
afftool
.
visualiseAffordances
(
'Support'
,
r
,
r
.
color
.
lightYellow
)
r
.
addLandmark
(
r
.
sceneName
,
1
)
# Setting initial and goal configurations
q_init
=
rbprmBuilder
.
getCurrentConfig
();
q_init
[
3
:
7
]
=
[
1
,
0
,
0
,
0
]
q_init
[
0
:
3
]
=
[
0.05
,
0.86
,
0.61
];
r
(
q_init
)
#q_init [0:3] = [0.05, 0.86, 0.59]; r (q_init)
rbprmBuilder
.
setCurrentConfig
(
q_init
)
q_goal
=
q_init
[::]
q_goal
[
0
:
3
]
=
[
1.83
,
0.86
,
1.15
];
r
(
q_goal
)
#q_goal [0:3] = [1.83, 0.86, 1.13]; r(q_goal)
# Choosing a path optimizer
ps
.
setInitialConfig
(
q_init
)
ps
.
addGoalConfig
(
q_goal
)
# Choosing RBPRM shooter and path validation methods.
ps
.
client
.
problem
.
selectConFigurationShooter
(
"RbprmShooter"
)
ps
.
client
.
problem
.
selectPathValidation
(
"RbprmPathValidation"
,
0.01
)
# Choosing kinodynamic methods :
ps
.
selectSteeringMethod
(
"RBPRMKinodynamic"
)
ps
.
selectDistance
(
"KinodynamicDistance"
)
ps
.
addPathOptimizer
(
"RandomShortcutDynamic"
)
ps
.
addPathOptimizer
(
"OrientedPathOptimizer"
)
ps
.
selectPathPlanner
(
"DynamicPlanner"
)
#solve the problem :
r
(
q_init
)
ps
.
client
.
problem
.
prepareSolveStepByStep
()
ps
.
client
.
problem
.
finishSolveStepByStep
()
q_far
=
q_init
[::]
q_far
[
2
]
=
-
3
r
(
q_far
)
from
hpp.gepetto
import
PathPlayer
pp
=
PathPlayer
(
rbprmBuilder
.
client
.
basic
,
r
)
pp
.
dt
=
0.03
pp
.
displayVelocityPath
(
0
)
r
.
client
.
gui
.
setVisibility
(
"path_0_root"
,
"ALWAYS_ON_TOP"
)
"""
camera = [0.6293167471885681,
-9.560577392578125,
10.504343032836914,
0.9323806762695312,
0.36073973774909973,
0.008668755181133747,
0.02139890193939209]
r.client.gui.setCameraTransform(0,camera)
"""
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment