Skip to content

Commit

Permalink
add test-samplerobot-emergency.py and test EmergencyStopper in test-s…
Browse files Browse the repository at this point in the history
…amplerobot.test
  • Loading branch information
mmurooka committed Jul 26, 2015
1 parent c33d891 commit 70f68b2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sample/SampleRobot/samplerobot_emergency_stopper.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import time

def init ():
global hcf, init_pose, reset_pose
global hcf, init_pose, reset_pose, hrpsys_version
hcf = HrpsysConfigurator()
hcf.getRTCList = hcf.getRTCListUnstable
hcf.init ("SampleRobot(Robot)0", "$(PROJECT_DIR)/../model/sample1.wrl")
init_pose = [0]*29
reset_pose = [0.0,-0.772215,0.0,1.8338,-1.06158,0.0,0.523599,0.0,0.0,-2.44346,0.15708,-0.113446,0.637045,0.0,-0.772215,0.0,1.8338,-1.06158,0.0,0.523599,0.0,0.0,-2.44346,-0.15708,-0.113446,-0.637045,0.0,0.0,0.0]
hrpsys_version = hcf.seq.ref.get_component_profile().version
print("hrpsys_version = %s"%hrpsys_version)

def angleDistance (angle1, angle2):
return sum([abs(i-j) for (i,j) in zip(angle1,angle2)])
Expand Down Expand Up @@ -101,11 +103,12 @@ def demoEmergencyStopReleaseWhenDeactivated():

def demo(key_interaction=False):
init()
if key_interaction:
demoEmergencyStopWithKeyInteracton()
else:
demoEmergencyStop()
demoEmergencyStopReleaseWhenDeactivated()
if hrpsys_version >= '315.6.0':
if key_interaction:
demoEmergencyStopWithKeyInteracton()
else:
demoEmergencyStop()
demoEmergencyStopReleaseWhenDeactivated()

if __name__ == '__main__':
demo()
23 changes: 23 additions & 0 deletions test/test-samplerobot-emergency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python

import imp, sys, os, time

# set path to hrpsys to use HrpsysConfigurator
from subprocess import check_output
sys.path.append(os.path.join(check_output(['pkg-config', 'hrpsys-base', '--variable=prefix']).rstrip(),'share/hrpsys/samples/SampleRobot/')) # set path to SampleRobot

import samplerobot_emergency_stopper

if __name__ == '__main__':
samplerobot_emergency_stopper.demo()

## IGNORE ME: this code used for rostest
if [s for s in sys.argv if "--gtest_output=xml:" in s] :
import unittest, rostest
rostest.run('hrpsys', 'samplerobot_emergency_stopper', unittest.TestCase, sys.argv)






2 changes: 2 additions & 0 deletions test/test-samplerobot.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@
args="-ORBInitRef NameService=corbaloc:iiop:localhost:2809/NameService" retry="2"/>
<test test-name="samplerobot_abc" pkg="hrpsys" type="test-samplerobot-abc.py"
args="-ORBInitRef NameService=corbaloc:iiop:localhost:2809/NameService" retry="2" time-limit="600"/>
<test test-name="samplerobot_es" pkg="hrpsys" type="test-samplerobot-emergency.py"
args="-ORBInitRef NameService=corbaloc:iiop:localhost:2809/NameService" retry="2"/>
</launch>

0 comments on commit 70f68b2

Please sign in to comment.