Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
hpp-rbprm-corba
Commits
611bd2cc
Commit
611bd2cc
authored
Jan 03, 2019
by
Pierre Fernbach
Browse files
rbprmBuilder and rbprmFullbody python classes now inherit from Robot
parent
d6923b8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/hpp/corbaserver/rbprm/rbprmbuilder.py
View file @
611bd2cc
...
...
@@ -17,19 +17,17 @@
# <http://www.gnu.org/licenses/>.
from
hpp.corbaserver.rbprm
import
Client
as
RbprmClient
from
hpp.corbaserver
import
Client
as
BasicClien
t
from
hpp.corbaserver
.robot
import
Robo
t
import
hpp.gepetto.blender.exportmotion
as
em
## Load and handle a RbprmDevice robot for rbprm planning
#
# A RbprmDevice robot is a dual representation of a robots. One robot describes the
# trunk of the robot, and a set of robots describe the range of motion of each limb of the robot.
class
Builder
(
ob
jec
t
):
class
Builder
(
R
ob
o
t
):
## Constructor
def
__init__
(
self
,
load
=
True
):
self
.
tf_root
=
"base_link"
self
.
rootJointType
=
dict
()
self
.
client
=
BasicClient
()
self
.
clientRbprm
=
RbprmClient
()
self
.
load
=
load
...
...
@@ -51,26 +49,13 @@ class Builder (object):
self
.
clientRbprm
.
rbprm
.
loadRobotRomModel
(
urdfNameroms
,
rootJointType
,
packageName
,
urdfNameroms
,
urdfSuffix
,
srdfSuffix
)
self
.
clientRbprm
.
rbprm
.
initNewProblemSolver
()
self
.
clientRbprm
.
rbprm
.
loadRobotCompleteModel
(
urdfName
,
rootJointType
,
packageName
,
urdfName
,
urdfSuffix
,
srdfSuffix
)
self
.
name
=
urdfName
self
.
displayName
=
urdfName
self
.
tf_root
=
"base_link"
self
.
rootJointType
=
rootJointType
self
.
jointNames
=
self
.
client
.
robot
.
getJointNames
()
self
.
allJointNames
=
self
.
client
.
robot
.
getAllJointNames
()
Robot
.
__init__
(
self
,
urdfName
,
rootJointType
,
False
)
self
.
client
.
robot
.
meshPackageName
=
meshPackageName
self
.
meshPackageName
=
meshPackageName
self
.
rankInConfiguration
=
dict
()
self
.
rankInVelocity
=
dict
()
self
.
packageName
=
packageName
self
.
urdfName
=
urdfName
self
.
urdfSuffix
=
urdfSuffix
self
.
srdfSuffix
=
srdfSuffix
rankInConfiguration
=
rankInVelocity
=
0
for
j
in
self
.
jointNames
:
self
.
rankInConfiguration
[
j
]
=
rankInConfiguration
rankInConfiguration
+=
self
.
client
.
robot
.
getJointConfigSize
(
j
)
self
.
rankInVelocity
[
j
]
=
rankInVelocity
rankInVelocity
+=
self
.
client
.
robot
.
getJointNumberDof
(
j
)
...
...
@@ -110,200 +95,3 @@ class Builder (object):
# \param filename name of the output file where to save the output
def
exportPath
(
self
,
viewer
,
problem
,
pathId
,
stepsize
,
filename
):
em
.
exportPath
(
viewer
,
self
.
client
.
robot
,
problem
,
pathId
,
stepsize
,
filename
)
## \name Degrees of freedom
# \{
## Get size of configuration
# \return size of configuration
def
getConfigSize
(
self
):
return
self
.
client
.
robot
.
getConfigSize
()
# Get size of velocity
# \return size of velocity
def
getNumberDof
(
self
):
return
self
.
client
.
robot
.
getNumberDof
()
## \}
## \name Joints
#\{
## Get joint names in the same order as in the configuration.
def
getJointNames
(
self
):
return
self
.
client
.
robot
.
getJointNames
()
## Get joint names in the same order as in the configuration.
def
getAllJointNames
(
self
):
return
self
.
client
.
robot
.
getAllJointNames
()
## Get joint position.
def
getJointPosition
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointPosition
(
jointName
)
## Set static position of joint in its parent frame
def
setJointPosition
(
self
,
jointName
,
position
):
return
self
.
client
.
robot
.
setJointPosition
(
jointName
,
position
)
## Get joint number degrees of freedom.
def
getJointNumberDof
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointNumberDof
(
jointName
)
## Get joint number config size.
def
getJointConfigSize
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointConfigSize
(
jointName
)
## set bounds for the joint
def
setJointBounds
(
self
,
jointName
,
inJointBound
):
return
self
.
client
.
robot
.
setJointBounds
(
jointName
,
inJointBound
)
## Set bounds on the translation part of the freeflyer joint.
#
# Valid only if the robot has a freeflyer joint.
def
setTranslationBounds
(
self
,
xmin
,
xmax
,
ymin
,
ymax
,
zmin
,
zmax
):
self
.
client
.
robot
.
setJointBounds
\
(
self
.
displayName
+
"base_joint_x"
,
[
xmin
,
xmax
])
self
.
client
.
robot
.
setJointBounds
\
(
self
.
displayName
+
"base_joint_y"
,
[
ymin
,
ymax
])
self
.
client
.
robot
.
setJointBounds
\
(
self
.
displayName
+
"base_joint_z"
,
[
zmin
,
zmax
])
## Get link position in joint frame
#
# Joints are oriented in a different way as in urdf standard since
# rotation and uni-dimensional translation joints act around or along
# their x-axis. This method returns the position of the urdf link in
# world frame.
#
# \param jointName name of the joint
# \return position of the link in world frame.
def
getLinkPosition
(
self
,
jointName
):
return
self
.
client
.
robot
.
getLinkPosition
(
jointName
)
## Get link name
#
# \param jointName name of the joint,
# \return name of the link.
def
getLinkName
(
self
,
jointName
):
return
self
.
client
.
robot
.
getLinkName
(
jointName
)
def
getLinkNames
(
self
,
jointName
):
return
self
.
client
.
robot
.
getLinkNames
(
jointName
)
## \}
## \name Access to current configuration
#\{
## Set current configuration of composite robot
#
# \param q configuration of the composite robot
def
setCurrentConfig
(
self
,
q
):
self
.
client
.
robot
.
setCurrentConfig
(
q
)
## Get current configuration of composite robot
#
# \return configuration of the composite robot
def
getCurrentConfig
(
self
):
return
self
.
client
.
robot
.
getCurrentConfig
()
## Shoot random configuration
# \return dofArray Array of degrees of freedom.
def
shootRandomConfig
(
self
):
return
self
.
client
.
robot
.
shootRandomConfig
()
## \}
## \name Bodies
# \{
## Get the list of objects attached to a joint.
# \param inJointName name of the joint.
# \return list of names of CollisionObject attached to the body.
def
getJointInnerObjects
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointInnerObjects
(
jointName
)
## Get list of collision objects tested with the body attached to a joint
# \param inJointName name of the joint.
# \return list of names of CollisionObject
def
getJointOuterObjects
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointOuterObjects
(
jointName
)
## Get position of robot object
# \param objectName name of the object.
# \return transformation as a hpp.Transform object
def
getObjectPosition
(
self
,
objectName
):
return
Transform
(
self
.
client
.
robot
.
getObjectPosition
(
objectName
))
## \brief Remove an obstacle from outer objects of a joint body
#
# \param objectName name of the object to remove,
# \param jointName name of the joint owning the body,
# \param collision whether collision with object should be computed,
# \param distance whether distance to object should be computed.
def
removeObstacleFromJoint
(
self
,
objectName
,
jointName
,
collision
,
distance
):
return
self
.
client
.
obstacle
.
removeObstacleFromJoint
\
(
objectName
,
jointName
,
collision
,
distance
)
## \}
## \name Collision checking and distance computation
# \{
## Test collision with obstacles and auto-collision.
#
# Check whether current configuration of robot is valid by calling
# CkwsDevice::collisionTest ().
# \return whether configuration is valid
# \note Deprecated. Use isConfigValid instead.
def
collisionTest
(
self
):
print
"Deprecated. Use isConfigValid instead"
return
self
.
client
.
robot
.
collisionTest
()
## Check the validity of a configuration.
#
# Check whether a configuration of robot is valid.
# \param cfg a configuration
# \return whether configuration is valid
def
isConfigValid
(
self
,
cfg
):
return
self
.
client
.
robot
.
isConfigValid
(
cfg
)
## Compute distances between bodies and obstacles
#
# \return list of distances,
# \return names of the objects belonging to a body
# \return names of the objects tested with inner objects,
# \return closest points on the body,
# \return closest points on the obstacles
# \note outer objects for a body can also be inner objects of another
# body.
def
distancesToCollision
(
self
):
return
self
.
client
.
robot
.
distancesToCollision
()
## \}
## \}
## \name Mass and inertia
# \{
## Get mass of robot
def
getMass
(
self
):
return
self
.
client
.
robot
.
getMass
()
## Get position of center of mass
def
getCenterOfMass
(
self
):
return
self
.
client
.
robot
.
getCenterOfMass
()
## Get Jacobian of the center of mass
def
getJacobianCenterOfMass
(
self
):
return
self
.
client
.
robot
.
getJacobianCenterOfMass
()
##\}
## Get the dimension of the extra configuration space
def
getDimensionExtraConfigSpace
(
self
):
return
self
.
client
.
robot
.
getDimensionExtraConfigSpace
()
## Convert a direction vector to a quaternion (use Eigen::Quaterniond::FromTwoVectors with Z vector)
# \param u the vector director
def
quaternionFromVector
(
self
,
vector
):
return
self
.
client
.
robot
.
quaternionFromVector
(
vector
)
src/hpp/corbaserver/rbprm/rbprmfullbody.py
View file @
611bd2cc
...
...
@@ -17,7 +17,7 @@
# <http://www.gnu.org/licenses/>.
from
hpp.corbaserver.rbprm
import
Client
as
RbprmClient
from
hpp.corbaserver
import
Client
as
BasicClien
t
from
hpp.corbaserver
.robot
import
Robo
t
import
hpp.gepetto.blender.exportmotion
as
em
from
numpy
import
array
,
matrix
from
spline
import
bezier
...
...
@@ -26,12 +26,10 @@ from spline import bezier
#
# A RbprmDevice robot is a set of two robots. One for the
# trunk of the robot, one for the range of motion
class
FullBody
(
ob
jec
t
):
class
FullBody
(
R
ob
o
t
):
## Constructor
def
__init__
(
self
,
load
=
True
):
self
.
tf_root
=
"base_link"
self
.
rootJointType
=
dict
()
self
.
client
=
BasicClient
()
self
.
clientRbprm
=
RbprmClient
()
self
.
load
=
load
self
.
limbNames
=
[]
...
...
@@ -47,53 +45,28 @@ class FullBody (object):
# \param srdfSuffix optional suffix for the srdf of the robot package
def
loadFullBodyModel
(
self
,
urdfName
,
rootJointType
,
meshPackageName
,
packageName
,
urdfSuffix
,
srdfSuffix
):
self
.
clientRbprm
.
rbprm
.
loadFullBodyRobot
(
urdfName
,
rootJointType
,
packageName
,
urdfName
,
urdfSuffix
,
srdfSuffix
,
self
.
client
.
problem
.
getSelected
(
"problem"
)[
0
])
self
.
name
=
urdfName
self
.
displayName
=
urdfName
self
.
tf_root
=
"base_link"
self
.
rootJointType
=
rootJointType
self
.
jointNames
=
self
.
client
.
robot
.
getJointNames
()
self
.
allJointNames
=
self
.
client
.
robot
.
getAllJointNames
()
Robot
.
__init__
(
self
,
urdfName
,
rootJointType
,
False
)
self
.
client
.
robot
.
meshPackageName
=
meshPackageName
self
.
meshPackageName
=
meshPackageName
self
.
rankInConfiguration
=
dict
()
self
.
rankInVelocity
=
dict
()
self
.
packageName
=
packageName
self
.
urdfName
=
urdfName
self
.
urdfSuffix
=
urdfSuffix
self
.
srdfSuffix
=
srdfSuffix
self
.
octrees
=
{}
rankInConfiguration
=
rankInVelocity
=
0
for
j
in
self
.
jointNames
:
self
.
rankInConfiguration
[
j
]
=
rankInConfiguration
rankInConfiguration
+=
self
.
client
.
robot
.
getJointConfigSize
(
j
)
self
.
rankInVelocity
[
j
]
=
rankInVelocity
rankInVelocity
+=
self
.
client
.
robot
.
getJointNumberDof
(
j
)
# Virtual function to load the fullBody robot model.
#
def
loadFullBodyModelFromActiveRobot
(
self
,
urdfName
,
rootJointType
,
meshPackageName
,
packageName
,
urdfSuffix
,
srdfSuffix
):
self
.
clientRbprm
.
rbprm
.
loadFullBodyRobotFromExistingRobot
()
self
.
name
=
urdfName
self
.
displayName
=
urdfName
self
.
tf_root
=
"base_link"
self
.
rootJointType
=
rootJointType
self
.
jointNames
=
self
.
client
.
robot
.
getJointNames
()
self
.
allJointNames
=
self
.
client
.
robot
.
getAllJointNames
()
Robot
.
__init__
(
self
,
urdfName
,
rootJointType
,
False
)
self
.
client
.
robot
.
meshPackageName
=
meshPackageName
self
.
meshPackageName
=
meshPackageName
self
.
rankInConfiguration
=
dict
()
self
.
rankInVelocity
=
dict
()
self
.
packageName
=
packageName
self
.
urdfName
=
urdfName
self
.
urdfSuffix
=
urdfSuffix
self
.
srdfSuffix
=
srdfSuffix
self
.
octrees
=
{}
rankInConfiguration
=
rankInVelocity
=
0
for
j
in
self
.
jointNames
:
self
.
rankInConfiguration
[
j
]
=
rankInConfiguration
rankInConfiguration
+=
self
.
client
.
robot
.
getJointConfigSize
(
j
)
self
.
rankInVelocity
[
j
]
=
rankInVelocity
rankInVelocity
+=
self
.
client
.
robot
.
getJointNumberDof
(
j
)
## Add a limb to the model
#
...
...
@@ -858,197 +831,6 @@ class FullBody (object):
f1
.
write
(
str
(
configurations
))
f1
.
close
()
## \name Degrees of freedom
# \{
## Get size of configuration
# \return size of configuration
def
getConfigSize
(
self
):
return
self
.
client
.
robot
.
getConfigSize
()
# Get size of velocity
# \return size of velocity
def
getNumberDof
(
self
):
return
self
.
client
.
robot
.
getNumberDof
()
## \}
## \name Joints
#\{
## Get joint names in the same order as in the configuration.
def
getJointNames
(
self
):
return
self
.
client
.
robot
.
getJointNames
()
## Get joint names in the same order as in the configuration.
def
getAllJointNames
(
self
):
return
self
.
client
.
robot
.
getAllJointNames
()
## Get joint position.
def
getJointPosition
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointPosition
(
jointName
)
## Set static position of joint in its parent frame
def
setJointPosition
(
self
,
jointName
,
position
):
return
self
.
client
.
robot
.
setJointPosition
(
jointName
,
position
)
## Get joint number degrees of freedom.
def
getJointNumberDof
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointNumberDof
(
jointName
)
## Get joint number config size.
def
getJointConfigSize
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointConfigSize
(
jointName
)
## set bounds for the joint
def
setJointBounds
(
self
,
jointName
,
inJointBound
):
return
self
.
client
.
robot
.
setJointBounds
(
jointName
,
inJointBound
)
## Set bounds on the translation part of the freeflyer joint.
#
# Valid only if the robot has a freeflyer joint.
def
setTranslationBounds
(
self
,
xmin
,
xmax
,
ymin
,
ymax
,
zmin
,
zmax
):
self
.
client
.
robot
.
setJointBounds
\
(
self
.
displayName
+
"base_joint_x"
,
[
xmin
,
xmax
])
self
.
client
.
robot
.
setJointBounds
\
(
self
.
displayName
+
"base_joint_y"
,
[
ymin
,
ymax
])
self
.
client
.
robot
.
setJointBounds
\
(
self
.
displayName
+
"base_joint_z"
,
[
zmin
,
zmax
])
## Get link position in joint frame
#
# Joints are oriented in a different way as in urdf standard since
# rotation and uni-dimensional translation joints act around or along
# their x-axis. This method returns the position of the urdf link in
# world frame.
#
# \param jointName name of the joint
# \return position of the link in world frame.
def
getLinkPosition
(
self
,
jointName
):
return
self
.
client
.
robot
.
getLinkPosition
(
jointName
)
## Get link name
#
# \param jointName name of the joint,
# \return name of the link.
def
getLinkName
(
self
,
jointName
):
return
self
.
client
.
robot
.
getLinkName
(
jointName
)
## \}
def
getLinkNames
(
self
,
jointName
):
return
self
.
client
.
robot
.
getLinkNames
(
jointName
)
## \name Access to current configuration
#\{
## Set current configuration of composite robot
#
# \param q configuration of the composite robot
def
setCurrentConfig
(
self
,
q
):
self
.
client
.
robot
.
setCurrentConfig
(
q
)
## Get current configuration of composite robot
#
# \return configuration of the composite robot
def
getCurrentConfig
(
self
):
return
self
.
client
.
robot
.
getCurrentConfig
()
## Shoot random configuration
# \return dofArray Array of degrees of freedom.
def
shootRandomConfig
(
self
):
return
self
.
client
.
robot
.
shootRandomConfig
()
## \}
## \name Bodies
# \{
## Get the list of objects attached to a joint.
# \param inJointName name of the joint.
# \return list of names of CollisionObject attached to the body.
def
getJointInnerObjects
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointInnerObjects
(
jointName
)
## Get list of collision objects tested with the body attached to a joint
# \param inJointName name of the joint.
# \return list of names of CollisionObject
def
getJointOuterObjects
(
self
,
jointName
):
return
self
.
client
.
robot
.
getJointOuterObjects
(
jointName
)
## Get position of robot object
# \param objectName name of the object.
# \return transformation as a hpp.Transform object
def
getObjectPosition
(
self
,
objectName
):
return
Transform
(
self
.
client
.
robot
.
getObjectPosition
(
objectName
))
## \brief Remove an obstacle from outer objects of a joint body
#
# \param objectName name of the object to remove,
# \param jointName name of the joint owning the body,
# \param collision whether collision with object should be computed,
# \param distance whether distance to object should be computed.
def
removeObstacleFromJoint
(
self
,
objectName
,
jointName
,
collision
,
distance
):
return
self
.
client
.
obstacle
.
removeObstacleFromJoint
\
(
objectName
,
jointName
,
collision
,
distance
)
## \}
## \name Collision checking and distance computation
# \{
## Test collision with obstacles and auto-collision.
#
# Check whether current configuration of robot is valid by calling
# CkwsDevice::collisionTest ().
# \return whether configuration is valid
# \note Deprecated. Use isConfigValid instead.
def
collisionTest
(
self
):
print
"Deprecated. Use isConfigValid instead"
return
self
.
client
.
robot
.
collisionTest
()
## Check the validity of a configuration.
#
# Check whether a configuration of robot is valid.
# \param cfg a configuration
# \return whether configuration is valid
def
isConfigValid
(
self
,
cfg
):
return
self
.
client
.
robot
.
isConfigValid
(
cfg
)
## Compute distances between bodies and obstacles
#
# \return list of distances,
# \return names of the objects belonging to a body
# \return names of the objects tested with inner objects,
# \return closest points on the body,
# \return closest points on the obstacles
# \note outer objects for a body can also be inner objects of another
# body.
def
distancesToCollision
(
self
):
return
self
.
client
.
robot
.
distancesToCollision
()
## \}
## \}
## \name Mass and inertia
# \{
## Get mass of robot
def
getMass
(
self
):
return
self
.
client
.
robot
.
getMass
()
## Get position of center of mass
def
getCenterOfMass
(
self
):
return
self
.
client
.
robot
.
getCenterOfMass
()
## Get Jacobian of the center of mass
def
getJacobianCenterOfMass
(
self
):
return
self
.
client
.
robot
.
getJacobianCenterOfMass
()
##\}
## Get the dimension of the extra configuration space
def
getDimensionExtraConfigSpace
(
self
):
return
self
.
client
.
robot
.
getDimensionExtraConfigSpace
()
## set a boolean in rbprmFullBody
# if true, the acceleration doesn't account for the stability check
#
...
...
@@ -1061,12 +843,6 @@ class FullBody (object):
def
setReferenceConfig
(
self
,
referenceConfig
):
return
self
.
clientRbprm
.
rbprm
.
setReferenceConfig
(
referenceConfig
)
## Convert a direction vector to a quaternion (use Eigen::Quaterniond::FromTwoVectors with Z vector)
# \param u the vector director
def
quaternionFromVector
(
self
,
vector
):
return
self
.
client
.
robot
.
quaternionFromVector
(
vector
)
## return the time at the given state index (in the path computed during the first phase)
# \param stateId : index of the state
def
getTimeAtState
(
self
,
stateId
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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