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
Stack Of Tasks
talos_integration_tests
Commits
8ee8f6ae
Unverified
Commit
8ee8f6ae
authored
Nov 17, 2020
by
Guilhem Saurel
Committed by
GitHub
Nov 17, 2020
Browse files
Merge pull request #24 from stack-of-tasks/topic/python3
Topic/python3
parents
642d6cdc
78eb2d96
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
8ee8f6ae
...
...
@@ -35,7 +35,6 @@ SET(CATKIN_REQUIRED_COMPONENTS
rospy
talos_gazebo
roscontrol_sot_talos
dynamic_graph_bridge_msgs
)
find_package
(
catkin REQUIRED COMPONENTS
...
...
@@ -77,5 +76,5 @@ if(CATKIN_ENABLE_TESTING)
find_package
(
rostest REQUIRED
)
add_rostest
(
tests/test_kine.test
)
add_rostest
(
tests/test_sot_talos_balance.test
)
add_rostest
(
tests/test_online_walking.test
)
add_rostest
(
tests/test_online_walking.test
)
endif
()
scripts/start_sot_online_walking.py
View file @
8ee8f6ae
...
...
@@ -2,44 +2,40 @@
# O. Stasse 17/01/2020
# LAAS, CNRS
import
os
import
rospy
import
math
import
time
import
roslaunch
import
rospkg
import
unittest
import
math
from
gazebo_msgs.srv
import
*
import
roslaunch
import
rospkg
import
rospy
from
gazebo_msgs.srv
import
GetModelState
from
std_srvs.srv
import
Empty
PKG_NAME
=
'talos_integration_tests'
PKG_NAME
=
'talos_integration_tests'
class
TestSoTTalos
(
unittest
.
TestCase
):
class
TestSoTTalos
(
unittest
.
TestCase
):
def
validation_through_gazebo
(
self
):
gzGetModelPropReq
=
rospy
.
ServiceProxy
(
'/gazebo/get_model_state'
,
GetModelState
)
gzGetModelPropReq
=
rospy
.
ServiceProxy
(
'/gazebo/get_model_state'
,
GetModelState
)
gzGetModelPropResp
=
gzGetModelPropReq
(
model_name
=
'talos'
)
f
=
open
(
"/tmp/output.dat"
,
"w+"
)
f
.
write
(
"x:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
x
)
+
"
\n
"
)
f
.
write
(
"y:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
y
)
+
"
\n
"
)
f
.
write
(
"z:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
z
)
+
"
\n
"
)
f
=
open
(
"/tmp/output.dat"
,
"w+"
)
f
.
write
(
"x:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
x
)
+
"
\n
"
)
f
.
write
(
"y:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
y
)
+
"
\n
"
)
f
.
write
(
"z:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
z
)
+
"
\n
"
)
# dx depends on the timing of the simulation
# which can be different from one computer to another.
# Therefore check only dy and dz.
dx
=
0.0
;
dy
=
gzGetModelPropResp
.
pose
.
position
.
y
-
0.0038
dz
=
gzGetModelPropResp
.
pose
.
position
.
z
-
1.00152
ldistance
=
math
.
sqrt
(
dx
*
dx
+
dy
*
dy
+
dz
*
dz
)
f
.
write
(
"dist:"
+
str
(
ldistance
))
dx
=
0.0
dy
=
gzGetModelPropResp
.
pose
.
position
.
y
-
0.0038
dz
=
gzGetModelPropResp
.
pose
.
position
.
z
-
1.00152
ldistance
=
math
.
sqrt
(
dx
*
dx
+
dy
*
dy
+
dz
*
dz
)
f
.
write
(
"dist:"
+
str
(
ldistance
))
f
.
close
()
if
ldistance
<
0.05
:
self
.
assertTrue
(
True
,
msg
=
"Converged to the desired position"
)
if
ldistance
<
0.05
:
self
.
assertTrue
(
True
,
msg
=
"Converged to the desired position"
)
else
:
self
.
assertFalse
(
True
,
msg
=
"Did not converged to the desired position"
)
self
.
assertFalse
(
True
,
msg
=
"Did not converged to the desired position"
)
def
runTest
(
self
):
# Start roscore
...
...
@@ -56,66 +52,57 @@ class TestSoTTalos(unittest.TestCase):
uuid
=
roslaunch
.
rlutil
.
get_or_generate_uuid
(
None
,
False
)
roslaunch
.
configure_logging
(
uuid
)
cli_args
=
[
talos_data_path
+
'/launch/talos_gazebo_alone.launch'
,
'world:=empty_forced'
,
'enable_leg_passive:=false'
]
cli_args
=
[
talos_data_path
+
'/launch/talos_gazebo_alone.launch'
,
'world:=empty_forced'
,
'enable_leg_passive:=false'
]
roslaunch_args
=
cli_args
[
1
:]
roslaunch_file
=
[(
roslaunch
.
rlutil
.
resolve_launch_arguments
\
(
cli_args
)[
0
],
roslaunch_args
)]
roslaunch_file
=
[(
roslaunch
.
rlutil
.
resolve_launch_arguments
(
cli_args
)[
0
],
roslaunch_args
)]
launch_gazebo_alone
=
roslaunch
.
parent
.
\
ROSLaunchParent
(
uuid
,
roslaunch_file
)
launch_gazebo_alone
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
roslaunch_file
)
launch_gazebo_alone
.
start
()
rospy
.
loginfo
(
"talos_gazebo_alone started"
)
rospy
.
wait_for_service
(
"/gazebo/pause_physics"
)
gazebo_pause_physics
=
rospy
.
ServiceProxy
(
'/gazebo/pause_physics'
,
Empty
)
gazebo_pause_physics
=
rospy
.
ServiceProxy
(
'/gazebo/pause_physics'
,
Empty
)
gazebo_pause_physics
()
time
.
sleep
(
5
)
# Spawn talos model in gazebo
launch_gazebo_spawn_hs
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
talos_data_path
+
'/launch/talos_gazebo_spawn_hs.launch'
])
#launch_gazebo_spawn_hs = roslaunch.parent.ROSLaunchParent(uuid,
launch_gazebo_spawn_hs
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_gazebo_spawn_hs.launch'
])
#
launch_gazebo_spawn_hs = roslaunch.parent.ROSLaunchParent(uuid,
# [ros_data_path+'/launch/talos_gazebo_spawn_hs_wide.launch'])
launch_gazebo_spawn_hs
.
start
()
rospy
.
loginfo
(
"talos_gazebo_spawn_hs started"
)
rospy
.
wait_for_service
(
"/gains/arm_left_1_joint/set_parameters"
)
time
.
sleep
(
5
)
gazebo_unpause_physics
=
rospy
.
\
ServiceProxy
(
'/gazebo/unpause_physics'
,
Empty
)
gazebo_unpause_physics
=
rospy
.
ServiceProxy
(
'/gazebo/unpause_physics'
,
Empty
)
gazebo_unpause_physics
()
# Start roscontrol
launch_bringup
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
talos_data_path
+
'/launch/talos_bringup.launch'
])
launch_bringup
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_bringup.launch'
])
launch_bringup
.
start
()
rospy
.
loginfo
(
"talos_bringup started"
)
# Start sot
roscontrol_sot_talos_path
=
arospack
.
get_path
(
'roscontrol_sot_talos'
)
launch_roscontrol_sot_talos
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
roscontrol_sot_talos_path
+
\
'/launch/sot_talos_controller_gazebo.launch'
])
roscontrol_sot_talos_path
=
arospack
.
get_path
(
'roscontrol_sot_talos'
)
launch_roscontrol_sot_talos
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
roscontrol_sot_talos_path
+
'/launch/sot_talos_controller_gazebo.launch'
])
launch_roscontrol_sot_talos
.
start
()
rospy
.
loginfo
(
"roscontrol_sot_talos started"
)
time
.
sleep
(
5
)
pkg_name
=
'talos_integration_tests'
executable
=
'test_online_walking.py'
node_name
=
'test_online_walking_py'
test_sot_online_walking_node
=
roslaunch
.
core
.
\
Node
(
pkg_name
,
executable
,
name
=
node_name
)
pkg_name
=
'talos_integration_tests'
executable
=
'test_online_walking.py'
node_name
=
'test_online_walking_py'
test_sot_online_walking_node
=
roslaunch
.
core
.
Node
(
pkg_name
,
executable
,
name
=
node_name
)
launch_test_sot_online_walking
=
roslaunch
.
scriptapi
.
ROSLaunch
()
launch_test_sot_online_walking
=
roslaunch
.
scriptapi
.
ROSLaunch
()
launch_test_sot_online_walking
.
start
()
test_sot_online_walking_process
=
launch_test_sot_online_walking
.
\
launch
(
test_sot_online_walking_node
)
test_sot_online_walking_process
=
launch_test_sot_online_walking
.
launch
(
test_sot_online_walking_node
)
r
=
rospy
.
Rate
(
10
)
while
not
rospy
.
is_shutdown
():
...
...
@@ -124,13 +111,12 @@ class TestSoTTalos(unittest.TestCase):
self
.
validation_through_gazebo
()
# If it is finished then find exit status.
if
test_sot_online_walking_process
.
exit_code
!=
0
:
exit_status
=
"test_online_walking failed"
self
.
assertFalse
(
True
,
exit_status
)
self
.
assertFalse
(
True
,
exit_status
)
else
:
exit_status
=
None
exit_status
=
None
print
(
"Stopping SoT"
)
launch_roscontrol_sot_talos
.
shutdown
()
...
...
@@ -145,6 +131,7 @@ class TestSoTTalos(unittest.TestCase):
r
.
sleep
()
if
__name__
==
'__main__'
:
import
rosunit
rosunit
.
unitrun
(
PKG_NAME
,
'test_online_walking'
,
TestSoTTalos
)
rosunit
.
unitrun
(
PKG_NAME
,
'test_online_walking'
,
TestSoTTalos
)
scripts/start_sot_talos_balance.py
View file @
8ee8f6ae
...
...
@@ -2,41 +2,40 @@
# O. Stasse 17/01/2020
# LAAS, CNRS
import
os
import
rospy
import
math
import
time
import
roslaunch
import
rospkg
import
unittest
import
math
from
gazebo_msgs.srv
import
*
import
rospkg
from
gazebo_msgs.srv
import
GetModelState
import
roslaunch
import
rospy
from
std_srvs.srv
import
Empty
PKG_NAME
=
'talos_integration_tests'
PKG_NAME
=
'talos_integration_tests'
class
TestSoTTalos
(
unittest
.
TestCase
):
def
validation_through_gazebo
(
self
):
gzGetModelPropReq
=
rospy
.
ServiceProxy
(
'/gazebo/get_model_state'
,
GetModelState
)
class
TestSoTTalos
(
unittest
.
TestCase
):
def
validation_through_gazebo
(
self
,
x
=
2.8331
,
y
=
0.0405
,
z
=
1.0019
):
gzGetModelPropReq
=
rospy
.
ServiceProxy
(
'/gazebo/get_model_state'
,
GetModelState
)
gzGetModelPropResp
=
gzGetModelPropReq
(
model_name
=
'talos'
)
f
=
open
(
"/tmp/output.dat"
,
"w+"
)
f
.
write
(
"x:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
x
)
+
"
\n
"
)
f
.
write
(
"y:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
y
)
+
"
\n
"
)
f
.
write
(
"z:"
+
str
(
gzGetModelPropResp
.
pose
.
position
.
z
)
+
"
\n
"
)
dx
=
gzGetModelPropResp
.
pose
.
position
.
x
-
2.8331
dy
=
gzGetModelPropResp
.
pose
.
position
.
y
-
0.0405
dz
=
gzGetModelPropResp
.
pose
.
position
.
z
-
1.0019
ldistance
=
math
.
sqrt
(
dx
*
dx
+
dy
*
dy
+
dz
*
dz
)
f
.
write
(
"dist:"
+
str
(
ldistance
))
f
.
close
()
if
ldistance
<
0.009
:
self
.
assertTrue
(
True
,
msg
=
"Converged to the desired position"
)
dx
=
gzGetModelPropResp
.
pose
.
position
.
x
-
x
# No compensation of the angular momentum creates huge drifts along the Y-axis
# so this axis is not relevant for repeatible tests.
# dy = gzGetModelPropResp.pose.position.y - y
dy
=
0
dz
=
gzGetModelPropResp
.
pose
.
position
.
z
-
z
ldistance
=
math
.
sqrt
(
dx
*
dx
+
dy
*
dy
+
dz
*
dz
)
with
open
(
"/tmp/output.dat"
,
"a"
)
as
f
:
f
.
write
(
"x: %f
\n
"
%
gzGetModelPropResp
.
pose
.
position
.
x
)
f
.
write
(
"y: %f
\n
"
%
gzGetModelPropResp
.
pose
.
position
.
y
)
f
.
write
(
"z: %f
\n
"
%
gzGetModelPropResp
.
pose
.
position
.
z
)
f
.
write
(
"dist: %f
\n
"
%
ldistance
)
if
ldistance
<
0.09
:
self
.
assertTrue
(
True
,
msg
=
"Converged to the desired position"
)
else
:
self
.
assertFalse
(
True
,
msg
=
"Did not converged to the desired position"
)
self
.
assertFalse
(
True
,
msg
=
"Did not converged to the desired position"
)
def
runTest
(
self
):
# Start roscore
...
...
@@ -53,10 +52,9 @@ class TestSoTTalos(unittest.TestCase):
uuid
=
roslaunch
.
rlutil
.
get_or_generate_uuid
(
None
,
False
)
roslaunch
.
configure_logging
(
uuid
)
cli_args
=
[
talos_data_path
+
'/launch/talos_gazebo_alone.launch'
,
'world:=empty_forced'
,
'enable_leg_passive:=false'
]
cli_args
=
[
talos_data_path
+
'/launch/talos_gazebo_alone.launch'
,
'world:=empty_forced'
,
'enable_leg_passive:=false'
]
roslaunch_args
=
cli_args
[
1
:]
roslaunch_file
=
[(
roslaunch
.
rlutil
.
resolve_launch_arguments
(
cli_args
)[
0
],
roslaunch_args
)]
...
...
@@ -65,52 +63,46 @@ class TestSoTTalos(unittest.TestCase):
rospy
.
loginfo
(
"talos_gazebo_alone started"
)
rospy
.
wait_for_service
(
"/gazebo/pause_physics"
)
gazebo_pause_physics
=
rospy
.
ServiceProxy
(
'/gazebo/pause_physics'
,
Empty
)
gazebo_pause_physics
=
rospy
.
ServiceProxy
(
'/gazebo/pause_physics'
,
Empty
)
gazebo_pause_physics
()
time
.
sleep
(
5
)
# Spawn talos model in gazebo
launch_gazebo_spawn_hs
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
talos_data_path
+
'/launch/talos_gazebo_spawn_hs.launch'
])
#launch_gazebo_spawn_hs = roslaunch.parent.ROSLaunchParent(uuid,
launch_gazebo_spawn_hs
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_gazebo_spawn_hs.launch'
])
#
launch_gazebo_spawn_hs = roslaunch.parent.ROSLaunchParent(uuid,
# [ros_data_path+'/launch/talos_gazebo_spawn_hs_wide.launch'])
launch_gazebo_spawn_hs
.
start
()
rospy
.
loginfo
(
"talos_gazebo_spawn_hs started"
)
rospy
.
wait_for_service
(
"/gains/arm_left_1_joint/set_parameters"
)
time
.
sleep
(
5
)
gazebo_unpause_physics
=
rospy
.
\
ServiceProxy
(
'/gazebo/unpause_physics'
,
Empty
)
gazebo_unpause_physics
=
rospy
.
ServiceProxy
(
'/gazebo/unpause_physics'
,
Empty
)
gazebo_unpause_physics
()
# Start roscontrol
launch_bringup
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
talos_data_path
+
'/launch/talos_bringup.launch'
])
launch_bringup
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_bringup.launch'
])
launch_bringup
.
start
()
rospy
.
loginfo
(
"talos_bringup started"
)
# Start sot
roscontrol_sot_talos_path
=
arospack
.
get_path
(
'roscontrol_sot_talos'
)
launch_roscontrol_sot_talos
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
roscontrol_sot_talos_path
+
\
'/launch/sot_talos_controller_gazebo.launch'
])
roscontrol_sot_talos_path
=
arospack
.
get_path
(
'roscontrol_sot_talos'
)
launch_roscontrol_sot_talos
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
roscontrol_sot_talos_path
+
'/launch/sot_talos_controller_gazebo.launch'
])
launch_roscontrol_sot_talos
.
start
()
rospy
.
loginfo
(
"roscontrol_sot_talos started"
)
time
.
sleep
(
5
)
pkg_name
=
'talos_integration_tests'
executable
=
'test_sot_talos_balance.py'
node_name
=
'test_sot_talos_balance_py'
test_sot_talos_balance_node
=
roslaunch
.
core
.
\
Node
(
pkg_name
,
executable
,
name
=
node_name
)
pkg_name
=
'talos_integration_tests'
executable
=
'test_sot_talos_balance.py'
node_name
=
'test_sot_talos_balance_py'
test_sot_talos_balance_node
=
roslaunch
.
core
.
Node
(
pkg_name
,
executable
,
name
=
node_name
)
launch_test_sot_talos_balance
=
roslaunch
.
scriptapi
.
ROSLaunch
()
launch_test_sot_talos_balance
=
roslaunch
.
scriptapi
.
ROSLaunch
()
launch_test_sot_talos_balance
.
start
()
test_sot_talos_balance_process
=
launch_test_sot_talos_balance
.
\
launch
(
test_sot_talos_balance_node
)
test_sot_talos_balance_process
=
launch_test_sot_talos_balance
.
launch
(
test_sot_talos_balance_node
)
r
=
rospy
.
Rate
(
10
)
while
not
rospy
.
is_shutdown
():
...
...
@@ -119,13 +111,12 @@ class TestSoTTalos(unittest.TestCase):
self
.
validation_through_gazebo
()
# If it is finished then find exit status.
if
test_sot_talos_balance_process
.
exit_code
!=
0
:
exit_status
=
"test_sot_talos_balance failed"
self
.
assertFalse
(
True
,
exit_status
)
self
.
assertFalse
(
True
,
exit_status
)
else
:
exit_status
=
None
exit_status
=
None
print
(
"Stopping SoT"
)
launch_roscontrol_sot_talos
.
shutdown
()
...
...
@@ -140,6 +131,7 @@ class TestSoTTalos(unittest.TestCase):
r
.
sleep
()
if
__name__
==
'__main__'
:
import
rosunit
rosunit
.
unitrun
(
PKG_NAME
,
'test_sot_talos_balance'
,
TestSoTTalos
)
rosunit
.
unitrun
(
PKG_NAME
,
'test_sot_talos_balance'
,
TestSoTTalos
)
scripts/start_talos_gazebo.py
View file @
8ee8f6ae
...
...
@@ -2,16 +2,14 @@
# O. Stasse 17/01/2020
# LAAS, CNRS
import
os
import
rospy
import
subprocess
import
time
import
roslaunch
import
rospkg
import
rospy
from
std_srvs.srv
import
Empty
# Start roscore
import
subprocess
roscore
=
subprocess
.
Popen
(
'roscore'
)
time
.
sleep
(
1
)
...
...
@@ -24,10 +22,7 @@ rospy.init_node('starting_talos_gazebo', anonymous=True)
uuid
=
roslaunch
.
rlutil
.
get_or_generate_uuid
(
None
,
False
)
roslaunch
.
configure_logging
(
uuid
)
cli_args
=
[
talos_data_path
+
'/launch/talos_gazebo_alone.launch'
,
'world:=empty_forced'
,
'enable_leg_passive:=false'
]
cli_args
=
[
talos_data_path
+
'/launch/talos_gazebo_alone.launch'
,
'world:=empty_forced'
,
'enable_leg_passive:=false'
]
roslaunch_args
=
cli_args
[
1
:]
roslaunch_file
=
[(
roslaunch
.
rlutil
.
resolve_launch_arguments
(
cli_args
)[
0
],
roslaunch_args
)]
...
...
@@ -42,8 +37,8 @@ gazebo_pause_physics()
time
.
sleep
(
5
)
# Spawn talos model in gazebo
launch_gazebo_spawn_hs
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_gazebo_spawn_hs.launch'
])
#launch_gazebo_spawn_hs = roslaunch.parent.ROSLaunchParent(uuid,
[
talos_data_path
+
'/launch/talos_gazebo_spawn_hs.launch'
])
#
launch_gazebo_spawn_hs = roslaunch.parent.ROSLaunchParent(uuid,
# [talos_data_path+'/launch/talos_gazebo_spawn_hs_wide.launch'])
launch_gazebo_spawn_hs
.
start
()
rospy
.
loginfo
(
"talos_gazebo_spawn_hs started"
)
...
...
@@ -54,18 +49,15 @@ gazebo_unpause_physics = rospy.ServiceProxy('/gazebo/unpause_physics', Empty)
gazebo_unpause_physics
()
# Start roscontrol
launch_bringup
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_bringup.launch'
])
launch_bringup
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_bringup.launch'
])
launch_bringup
.
start
()
rospy
.
loginfo
(
"talos_bringup started"
)
# Start sot
roscontrol_sot_talos_path
=
arospack
.
get_path
(
'roscontrol_sot_talos'
)
launch_roscontrol_sot_talos
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
roscontrol_sot_talos_path
+
'/launch/sot_talos_controller_gazebo.launch'
])
roscontrol_sot_talos_path
=
arospack
.
get_path
(
'roscontrol_sot_talos'
)
launch_roscontrol_sot_talos
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
roscontrol_sot_talos_path
+
'/launch/sot_talos_controller_gazebo.launch'
])
launch_roscontrol_sot_talos
.
start
()
rospy
.
loginfo
(
"roscontrol_sot_talos started"
)
rospy
.
spin
()
scripts/start_talos_gazebo_kine.py
View file @
8ee8f6ae
...
...
@@ -2,35 +2,32 @@
# O. Stasse 17/01/2020
# LAAS, CNRS
import
os
import
rospy
import
math
import
time
import
roslaunch
import
rospkg
import
unittest
import
math
from
gazebo_msgs.srv
import
*
import
roslaunch
import
rospkg
import
rospy
from
gazebo_msgs.srv
import
GetLinkState
from
std_srvs.srv
import
Empty
PKG_NAME
=
'talos_integration_tests'
PKG_NAME
=
'talos_integration_tests'
class
TestSoTTalos
(
unittest
.
TestCase
):
def
validation_through_gazebo
(
self
):
gzGetLinkPropReq
=
rospy
.
ServiceProxy
(
'/gazebo/get_link_state'
,
GetLinkState
)
gzGetLinkPropReq
=
rospy
.
ServiceProxy
(
'/gazebo/get_link_state'
,
GetLinkState
)
gzGetLinkPropResp
=
gzGetLinkPropReq
(
link_name
=
'gripper_right_fingertip_1_link'
)
f
=
open
(
"/tmp/output.dat"
,
"w+"
)
f
.
write
(
"x:"
+
str
(
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
x
)
+
"
\n
"
)
f
.
write
(
"y:"
+
str
(
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
y
)
+
"
\n
"
)
f
.
write
(
"z:"
+
str
(
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
z
)
+
"
\n
"
)
dx
=
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
x
-
0.5723
dy
=
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
y
+
0.2885
dz
=
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
z
-
0.7745
ldistance
=
math
.
sqrt
(
dx
*
dx
+
dy
*
dy
+
dz
*
dz
)
f
.
write
(
"dist:"
+
str
(
ldistance
))
f
=
open
(
"/tmp/output.dat"
,
"w+"
)
f
.
write
(
"x:"
+
str
(
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
x
)
+
"
\n
"
)
f
.
write
(
"y:"
+
str
(
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
y
)
+
"
\n
"
)
f
.
write
(
"z:"
+
str
(
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
z
)
+
"
\n
"
)
dx
=
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
x
-
0.5723
dy
=
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
y
+
0.2885
dz
=
gzGetLinkPropResp
.
link_state
.
pose
.
position
.
z
-
0.7745
ldistance
=
math
.
sqrt
(
dx
*
dx
+
dy
*
dy
+
dz
*
dz
)
f
.
write
(
"dist:"
+
str
(
ldistance
))
f
.
close
()
if
ldistance
<
0.009
:
...
...
@@ -38,7 +35,6 @@ class TestSoTTalos(unittest.TestCase):
else
:
self
.
assertTrue
(
False
)
def
runTest
(
self
):
# Start roscore
import
subprocess
...
...
@@ -54,9 +50,10 @@ class TestSoTTalos(unittest.TestCase):
uuid
=
roslaunch
.
rlutil
.
get_or_generate_uuid
(
None
,
False
)
roslaunch
.
configure_logging
(
uuid
)
cli_args
=
[
talos_data_path
+
'/launch/talos_gazebo_alone.launch'
,
'world:=empty_forced'
,
'enable_leg_passive:=false'
,
cli_args
=
[
talos_data_path
+
'/launch/talos_gazebo_alone.launch'
,
'world:=empty_forced'
,
'enable_leg_passive:=false'
,
]
roslaunch_args
=
cli_args
[
1
:]
roslaunch_file
=
[(
roslaunch
.
rlutil
.
resolve_launch_arguments
(
cli_args
)[
0
],
roslaunch_args
)]
...
...
@@ -71,40 +68,37 @@ class TestSoTTalos(unittest.TestCase):
time
.
sleep
(
5
)
# Spawn talos model in gazebo
launch_gazebo_spawn_hs
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
talos_data_path
+
'/launch/talos_gazebo_spawn_hs.launch'
])
#launch_gazebo_spawn_hs = roslaunch.parent.ROSLaunchParent(uuid,
launch_gazebo_spawn_hs
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_gazebo_spawn_hs.launch'
])
#
launch_gazebo_spawn_hs = roslaunch.parent.ROSLaunchParent(uuid,
# [talos_data_path+'/launch/talos_gazebo_spawn_hs_wide.launch'])
launch_gazebo_spawn_hs
.
start
()
rospy
.
loginfo
(
"talos_gazebo_spawn_hs started"
)
rospy
.
wait_for_service
(
"/gains/arm_left_1_joint/set_parameters"
)
time
.
sleep
(
5
)
gazebo_unpause_physics
=
\
rospy
.
ServiceProxy
(
'/gazebo/unpause_physics'
,
Empty
)
gazebo_unpause_physics
=
rospy
.
ServiceProxy
(
'/gazebo/unpause_physics'
,
Empty
)
gazebo_unpause_physics
()
# Start roscontrol
launch_bringup
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
talos_data_path
+
'/launch/talos_bringup.launch'
])
launch_bringup
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
talos_data_path
+
'/launch/talos_bringup.launch'
])
launch_bringup
.
start
()
rospy
.
loginfo
(
"talos_bringup started"
)
# Start sot
roscontrol_sot_talos_path
=
arospack
.
get_path
(
'roscontrol_sot_talos'
)
launch_roscontrol_sot_talos
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
\
[
roscontrol_sot_talos_path
+
\
'/launch/sot_talos_controller_gazebo.launch'
])
roscontrol_sot_talos_path
=
arospack
.
get_path
(
'roscontrol_sot_talos'
)
launch_roscontrol_sot_talos
=
roslaunch
.
parent
.
ROSLaunchParent
(
uuid
,
[
roscontrol_sot_talos_path
+
'/launch/sot_talos_controller_gazebo.launch'
])
launch_roscontrol_sot_talos
.
start
()
rospy
.
loginfo
(
"roscontrol_sot_talos started"
)
time
.
sleep
(
5
)
pkg_name
=
'talos_integration_tests'
executable
=
'test_kine.py'
node_name
=
'test_kine_py'
test_kine_node
=
roslaunch
.
core
.
Node
(
pkg_name
,
executable
,
name
=
node_name
)
pkg_name
=
'talos_integration_tests'
executable
=
'test_kine.py'
node_name
=
'test_kine_py'
test_kine_node
=
roslaunch
.
core
.
Node
(
pkg_name
,
executable
,
name
=
node_name
)
launch_test_kine
=
roslaunch
.
scriptapi
.
ROSLaunch
()
launch_test_kine
=
roslaunch
.
scriptapi
.
ROSLaunch
()
launch_test_kine
.
start
()
test_kine_process
=
launch_test_kine
.
launch
(
test_kine_node
)
...
...
@@ -120,7 +114,7 @@ class TestSoTTalos(unittest.TestCase):
if
test_kine_process
.
exit_code
!=
0
:
exit_status
=
"test_sot_talos_balance failed"
else
:
exit_status
=
None
exit_status
=
None
print
(
"Stopping SoT"
)
launch_roscontrol_sot_talos
.
shutdown
()
...
...
@@ -138,4 +132,4 @@ class TestSoTTalos(unittest.TestCase):
if
__name__
==
'__main__'
:
import
rosunit
rosunit
.
unitrun
(
PKG_NAME
,
'test_sot_talos_kine'
,
TestSoTTalos
)
rosunit
.
unitrun
(
PKG_NAME
,
'test_sot_talos_kine'
,
TestSoTTalos
)
scripts/test_appli_seq_play.py
View file @
8ee8f6ae
#!/usr/bin/python
import
sys
import
rospy
from
dynamic_graph_bridge_msgs.srv
import
RunCommand
from
std_srvs.srv
import
Empty
try
:
# Python 2
input
=
raw_input
except
NameError
:
pass
from
std_srvs.srv
import
*
from
dynamic_graph_bridge_msgs.srv
import
*
def
launchScript
(
code
,
title
,
description
=
""
):
raw_
input
(
title
+
': '
+
description
)
def
launchScript
(
code
,
title
,
description
=
""
):
input
(
title
+
': '
+
description
)
rospy
.
loginfo
(
title
)
rospy
.
loginfo
(
code
)
for
line
in
code
:
if
line
!=
''
and
line
[
0
]
!=
'#'
:
print
line