Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
example-robot-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guilhem Saurel
example-robot-data
Commits
d65e828b
Commit
d65e828b
authored
6 years ago
by
Carlos Mastalli
Browse files
Options
Downloads
Patches
Plain Diff
[unittest] Formatting these files
parent
00a1ef59
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
unittest/test_all.py
+9
-9
9 additions, 9 deletions
unittest/test_all.py
unittest/test_load.py
+5
-2
5 additions, 2 deletions
unittest/test_load.py
unittest/unittest_utils.py
+25
-21
25 additions, 21 deletions
unittest/unittest_utils.py
with
39 additions
and
32 deletions
unittest/test_all.py
+
9
−
9
View file @
d65e828b
...
...
@@ -2,20 +2,20 @@ import unittest
import
sys
testmodules
=
[
'
test_load
'
,
'
test_load
'
,
]
suite
=
unittest
.
TestSuite
()
for
t
in
testmodules
:
try
:
# If the module defines a suite() function, call it to get the suite.
mod
=
__import__
(
t
,
globals
(),
locals
(),
[
'
suite
'
])
suitefn
=
getattr
(
mod
,
'
suite
'
)
suite
.
addTest
(
suitefn
())
except
(
ImportError
,
AttributeError
):
# else, just load all the test cases from the module.
suite
.
addTest
(
unittest
.
defaultTestLoader
.
loadTestsFromName
(
t
))
try
:
# If the module defines a suite() function, call it to get the suite.
mod
=
__import__
(
t
,
globals
(),
locals
(),
[
'
suite
'
])
suitefn
=
getattr
(
mod
,
'
suite
'
)
suite
.
addTest
(
suitefn
())
except
(
ImportError
,
AttributeError
):
# else, just load all the test cases from the module.
suite
.
addTest
(
unittest
.
defaultTestLoader
.
loadTestsFromName
(
t
))
result
=
unittest
.
TextTestRunner
().
run
(
suite
)
sys
.
exit
(
len
(
result
.
errors
)
+
len
(
result
.
failures
))
This diff is collapsed.
Click to expand it.
unittest/test_load.py
+
5
−
2
View file @
d65e828b
...
...
@@ -16,29 +16,32 @@ class RobotTestCase(unittest.TestCase):
self
.
assertEqual
(
model
.
nv
,
self
.
NV
,
"
Wrong nv value.
"
)
def
test_q0
(
self
):
self
.
assertTrue
(
hasattr
(
self
.
ROBOT
,
"
q0
"
),
"
It doesn
'
t have q0
"
)
self
.
assertTrue
(
hasattr
(
self
.
ROBOT
,
"
q0
"
),
"
It doesn
'
t have q0
"
)
class
TalosArmTest
(
RobotTestCase
):
RobotTestCase
.
ROBOT
=
loadTalosArm
()
RobotTestCase
.
NQ
=
7
RobotTestCase
.
NV
=
7
class
TalosArmFloatingTest
(
RobotTestCase
):
RobotTestCase
.
ROBOT
=
loadTalosArm
()
RobotTestCase
.
NQ
=
14
RobotTestCase
.
NV
=
13
class
TalosTest
(
RobotTestCase
):
RobotTestCase
.
ROBOT
=
loadTalos
()
RobotTestCase
.
NQ
=
39
RobotTestCase
.
NV
=
38
class
HyQTest
(
RobotTestCase
):
RobotTestCase
.
ROBOT
=
loadHyQ
()
RobotTestCase
.
NQ
=
19
RobotTestCase
.
NV
=
18
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
unittest/unittest_utils.py
+
25
−
21
View file @
d65e828b
import
pinocchio
from
pinocchio.utils
import
*
from
pinocchio.robot_wrapper
import
RobotWrapper
import
numpy
as
np
def
readParamsFromSrdf
(
robot
,
SRDF_PATH
,
verbose
):
rmodel
=
robot
.
model
pinocchio
.
loadRotorParameters
(
rmodel
,
SRDF_PATH
,
verbose
)
rmodel
.
armature
=
\
np
.
multiply
(
rmodel
.
rotorInertia
.
flat
,
np
.
square
(
rmodel
.
rotorGearRatio
.
flat
))
try
:
pinocchio
.
loadReferenceConfigurations
(
rmodel
,
SRDF_PATH
,
verbose
)
robot
.
q0
.
flat
[:]
=
rmodel
.
referenceConfigurations
[
"
half_sitting
"
].
copy
()
except
:
print
"
loadReferenceConfigurations did not work. Please check your Pinocchio Version
"
rmodel
=
robot
.
model
pinocchio
.
loadRotorParameters
(
rmodel
,
SRDF_PATH
,
verbose
)
rmodel
.
armature
=
\
np
.
multiply
(
rmodel
.
rotorInertia
.
flat
,
np
.
square
(
rmodel
.
rotorGearRatio
.
flat
))
try
:
pinocchio
.
getNeutralConfiguration
(
rmodel
,
SRDF_PATH
,
verbose
)
robot
.
q0
.
flat
[:]
=
rmodel
.
neutralConfiguration
.
copy
()
pinocchio
.
loadReferenceConfigurations
(
rmodel
,
SRDF_PATH
,
verbose
)
robot
.
q0
.
flat
[:]
=
\
rmodel
.
referenceConfigurations
[
"
half_sitting
"
].
copy
()
except
:
robot
.
q0
.
flat
[:]
=
pinocchio
.
neutral
(
rmodel
)
return
print
"
loadReferenceConfigurations did not work. Please check your
\
Pinocchio Version
"
try
:
pinocchio
.
getNeutralConfiguration
(
rmodel
,
SRDF_PATH
,
verbose
)
robot
.
q0
.
flat
[:]
=
rmodel
.
neutralConfiguration
.
copy
()
except
:
robot
.
q0
.
flat
[:]
=
pinocchio
.
neutral
(
rmodel
)
return
def
loadTalosArm
(
modelPath
=
'
/opt/openrobots/share/example-robot-data
'
):
URDF_FILENAME
=
"
talos_left_arm.urdf
"
URDF_SUBPATH
=
"
/talos/
"
+
URDF_FILENAME
...
...
@@ -34,6 +37,7 @@ def loadTalosArm(modelPath='/opt/openrobots/share/example-robot-data'):
readParamsFromSrdf
(
robot
,
modelPath
+
SRDF_SUBPATH
,
False
)
return
robot
def
loadTalos
(
modelPath
=
'
/opt/openrobots/share/example-robot-data
'
):
URDF_FILENAME
=
"
talos_reduced.urdf
"
SRDF_FILENAME
=
"
talos.srdf
"
...
...
@@ -41,21 +45,21 @@ def loadTalos(modelPath='/opt/openrobots/share/example-robot-data'):
URDF_SUBPATH
=
"
/talos/
"
+
URDF_FILENAME
# Load URDF file
robot
=
RobotWrapper
.
BuildFromURDF
(
modelPath
+
URDF_SUBPATH
,
[
modelPath
],
pinocchio
.
JointModelFreeFlyer
())
pinocchio
.
JointModelFreeFlyer
())
# Load SRDF file
readParamsFromSrdf
(
robot
,
modelPath
+
SRDF_SUBPATH
,
False
)
assert
((
robot
.
model
.
armature
[:
6
]
==
0.
).
all
())
assert
((
robot
.
model
.
armature
[:
6
]
==
0.
).
all
())
return
robot
def
loadHyQ
(
modelPath
=
'
/opt/openrobots/share/example-robot-data
'
):
from
pinocchio
import
JointModelFreeFlyer
URDF_FILENAME
=
"
hyq_no_sensors.urdf
"
URDF_SUBPATH
=
"
/hyq/
"
+
URDF_FILENAME
robot
=
RobotWrapper
.
BuildFromURDF
(
modelPath
+
URDF_SUBPATH
,
[
modelPath
],
pinocchio
.
JointModelFreeFlyer
())
# TODO define default position inside srdf
robot
.
q0
.
flat
[
7
:]
=
[
-
0.2
,
0.75
,
-
1.5
,
-
0.2
,
-
0.75
,
1.5
,
-
0.2
,
0.75
,
-
1.5
,
-
0.2
,
-
0.75
,
1.5
]
robot
.
q0
.
flat
[
7
:]
=
[
-
0.2
,
0.75
,
-
1.5
,
-
0.2
,
-
0.75
,
1.5
,
-
0.2
,
0.75
,
-
1.5
,
-
0.2
,
-
0.75
,
1.5
]
robot
.
q0
[
2
]
=
0.57750958
robot
.
model
.
referenceConfigurations
[
"
half_sitting
"
]
=
robot
.
q0
return
robot
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment