|
From: <stu...@us...> - 2009-08-28 23:25:36
|
Revision: 23305
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=23305&view=rev
Author: stuglaser
Date: 2009-08-28 23:25:27 +0000 (Fri, 28 Aug 2009)
Log Message:
-----------
Added a test for ensuring that the milestone2 controller come up
Modified Paths:
--------------
pkg/trunk/sandbox/mechanism_control_test/manifest.xml
Added Paths:
-----------
pkg/trunk/demos/milestone2/milestone2_tests/test/test_controllers_load.launch
pkg/trunk/sandbox/mechanism_control_test/scripts/
pkg/trunk/sandbox/mechanism_control_test/scripts/test_controllers_loaded.py
Added: pkg/trunk/demos/milestone2/milestone2_tests/test/test_controllers_load.launch
===================================================================
--- pkg/trunk/demos/milestone2/milestone2_tests/test/test_controllers_load.launch (rev 0)
+++ pkg/trunk/demos/milestone2/milestone2_tests/test/test_controllers_load.launch 2009-08-28 23:25:27 UTC (rev 23305)
@@ -0,0 +1,11 @@
+<launch>
+
+ <include file="$(find pr2_defs)/launch/upload_pr2.launch" />
+ <include file="$(find milestone2_actions)/config/controllers.xml" />
+ <node pkg="mechanism_control_test" type="mechanism_controller_test" args="-x /robot_description_new" />
+
+ <test test-name="test_controllers_loaded" pkg="mechanism_control_test" type="test_controllers_loaded.py"
+ args="pr2_base_controller pr2_base_odometry head_controller r_gripper_effort_controller r_gripper_position_controller torso_lift_velocity_controller r_arm_constraint_cartesian_wrench_controller r_arm_constraint_cartesian_twist_controller r_arm_constraint_cartesian_pose_controller r_arm_constraint_cartesian_trajectory_controller r_arm_cartesian_tff_controller r_arm_cartesian_wrench_controller r_arm_cartesian_twist_controller r_arm_cartesian_pose_controller r_arm_cartesian_trajectory_controller r_arm_hybrid_controller laser_tilt_controller r_arm_joint_trajectory_controller" />
+
+
+</launch>
Modified: pkg/trunk/sandbox/mechanism_control_test/manifest.xml
===================================================================
--- pkg/trunk/sandbox/mechanism_control_test/manifest.xml 2009-08-28 23:24:50 UTC (rev 23304)
+++ pkg/trunk/sandbox/mechanism_control_test/manifest.xml 2009-08-28 23:25:27 UTC (rev 23305)
@@ -8,10 +8,10 @@
<depend package="roscpp" />
<depend package="pr2_hardware_interface" />
<depend package="pr2_mechanism_control" />
+ <depend package="rostest" />
+ <depend package="hardware_interface" />
+ <depend package="mechanism_control" />
- <!-- The controllers packages for testing -->
- <!--<depend package="robot_mechanism_controllers" />-->
-
<url>http://pr.willowgarage.com</url>
<repository>http://pr.willowgarage.com/repos</repository>
<export>
Added: pkg/trunk/sandbox/mechanism_control_test/scripts/test_controllers_loaded.py
===================================================================
--- pkg/trunk/sandbox/mechanism_control_test/scripts/test_controllers_loaded.py (rev 0)
+++ pkg/trunk/sandbox/mechanism_control_test/scripts/test_controllers_loaded.py 2009-08-28 23:25:27 UTC (rev 23305)
@@ -0,0 +1,90 @@
+#! /usr/bin/env python
+# Copyright (c) 2009, Willow Garage, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the Willow Garage, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Tests that controllers are loaded. Fails if any of the controllers on the
+# argument list have not loaded after no new controllers are loaded for 10
+# seconds.
+
+# Author: Stuart Glaser
+
+STABLIZE_TIME = 10.0
+
+import roslib; roslib.load_manifest('mechanism_control_test')
+import sys, time
+import unittest
+import rospy
+from mechanism_msgs.srv import *
+from mechanism_control import mechanism
+from mechanism_msgs.srv import *
+
+rospy.wait_for_service('list_controllers')
+list_controllers_srv = rospy.ServiceProxy('list_controllers', ListControllers)
+def list_controllers():
+ resp = list_controllers_srv().controllers
+ # HACK until #2654 is fixed
+ controllers = []
+ for c in resp:
+ i = c.index(' ')
+ controllers.append(c[:i])
+ return controllers
+
+#resp = s.call(ListControllersRequest())
+
+
+class TestControllersLoaded(unittest.TestCase):
+ def test_controllers_loaded(self):
+ #controllers_expected = rospy.myargv()[1:]
+ controllers_expected = [c for c in rospy.myargv()[1:] if not c.startswith('-')]
+ controllers_up = list_controllers()
+
+ count = 0
+ while not rospy.is_shutdown():
+ time.sleep(STABLIZE_TIME)
+ controllers_up_latest = list_controllers()
+ controllers_up_latest.sort()
+ print ".",
+ if controllers_up_latest == controllers_up:
+ break
+
+ controllers_up = controllers_up_latest
+
+ count += 1
+ if count > 100:
+ self.fail("The loaded controllers won't stabilize! Giving up")
+ return
+ print
+
+ print "Expected: ", ', '.join(controllers_expected)
+ print "Up: ", ', '.join(controllers_up)
+ for c in controllers_expected:
+ self.assert_(c in controllers_up, "Expected controller %s to be loaded, but it wasn't" % c)
+
+
+if __name__ == '__main__':
+ import rostest
+ rostest.rosrun("test_controller_loaded", "test_controllers_loaded", TestControllersLoaded)
Property changes on: pkg/trunk/sandbox/mechanism_control_test/scripts/test_controllers_loaded.py
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|