|
From: <wa...@us...> - 2009-07-20 06:36:54
|
Revision: 19185
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=19185&view=rev
Author: wattsk
Date: 2009-07-20 06:36:45 +0000 (Mon, 20 Jul 2009)
Log Message:
-----------
Moved runtime_test to new package, diagnostic_test, and updated expected battery test. Upgraded CSV exporter in diagnostics_analysis
Modified Paths:
--------------
pkg/trunk/stacks/hardware_test/diagnostics_analysis/csv/export_csv.py
pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/battery_presence.yaml
pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/expected_batteries.launch
pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/manifest.xml
Added Paths:
-----------
pkg/trunk/stacks/hardware_test/diagnostic_test/
pkg/trunk/stacks/hardware_test/diagnostic_test/CMakeLists.txt
pkg/trunk/stacks/hardware_test/diagnostic_test/Makefile
pkg/trunk/stacks/hardware_test/diagnostic_test/manifest.xml
pkg/trunk/stacks/hardware_test/diagnostic_test/scripts/
pkg/trunk/stacks/hardware_test/diagnostic_test/scripts/diagnostic_test.py
pkg/trunk/stacks/hardware_test/diagnostic_test/src/
pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/
pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/__init__.py
pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/expected.py
pkg/trunk/stacks/hardware_test/diagnostic_test/test/
pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_publisher.py
pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_status.yaml
pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_tester.launch
pkg/trunk/stacks/hardware_test/diagnostic_test/test/publish_test.launch
pkg/trunk/stacks/hardware_test/diagnostics_analysis/output/
Removed Paths:
-------------
pkg/trunk/stacks/hardware_test/runtime_monitor/scripts/runtime_test
pkg/trunk/stacks/hardware_test/runtime_monitor/src/runtime_monitor/expected.py
pkg/trunk/stacks/hardware_test/runtime_monitor/src/runtime_monitor/test_test.py
pkg/trunk/stacks/hardware_test/runtime_monitor/test.yaml
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/CMakeLists.txt
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/CMakeLists.txt (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/CMakeLists.txt 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.4.6)
+include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
+rospack(diagnostic_test)
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/Makefile
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/Makefile (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/Makefile 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1 @@
+include $(shell rospack find mk)/cmake.mk
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/manifest.xml
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/manifest.xml (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/manifest.xml 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1,20 @@
+<package>
+<description brief='A program to test and analyze diagnostics on robot'>
+
+Monitors diagnostics by testing them. Checking battery prescence, checking motors are OK, etc.
+
+</description>
+<author>Kevin Watts</author>
+<license>BSD</license>
+<review status="proposal cleared" notes=""/>
+<url>http://pr.willowgarage.com/wiki/diagnostic_test</url>
+<export>
+<cpp cflags="-I${prefix}/include " lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib"/>
+</export>
+<depend package="rospy"/>
+<depend package="diagnostic_msgs"/>
+<sysdepend os="ubuntu" version="7.04-feisty" package="libwxgtk2.8-dev"/>
+<sysdepend os="ubuntu" version="8.04-feisty" package="python-wxgtk2.8"/>
+<sysdepend os="ubuntu" version="8.04-hardy" package="libwxgtk2.8-dev"/>
+<sysdepend os="ubuntu" version="8.04-hardy" package="python-wxgtk2.8"/>
+</package>
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/scripts/diagnostic_test.py
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/scripts/diagnostic_test.py (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/scripts/diagnostic_test.py 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1,175 @@
+#!/usr/bin/env python
+# Software License Agreement (BSD License)
+#
+# Copyright (c) 2008, 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 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.
+#
+
+## A basic node to monitor diagnostics for expected status
+
+PKG = 'diagnostic_test'
+
+import roslib; roslib.load_manifest(PKG)
+
+import sys, time
+import rospy
+from diagnostic_msgs.msg import DiagnosticMessage, DiagnosticStatus, DiagnosticValue, DiagnosticString
+
+NAME = 'diagnostic_test'
+
+latest_messages = {}
+test_name = 'uninitialized'
+package = 'uninitialized'
+last_runtime = 0
+startup_delay = 5.0
+start_time = 0
+
+## Records status as dictionary by labels for strings, values
+## Also stores last time of message, allows stale checks.
+def status_to_map(status):
+ str_map = {}
+ for s in status.strings:
+ str_map[s.label] = s.value;
+ for val in status.values:
+ str_map[val.label] = val.value;
+ str_map["name"]= status.name
+ str_map["message"] = status.message
+ str_map["level"] = status.level
+
+ # Store last time message was recorded
+ str_map["last_time"] = rospy.get_time()
+ return str_map
+
+## The test takes the latest_messages dictionary, the private parameters
+## and the status name (the name of the DiagnosticStatus message
+## it publishes)
+def analyze(test_impl, params):
+ return test_impl.test(latest_messages, params)
+
+def callback(message, args):
+ for s in message.status:
+ latest_messages[s.name] = status_to_map(s)
+ execute_test(args)
+
+## Performs designated test using latest messages. Publishes to /diagnostics
+## Never tests greater than max frequency.
+##@param args (Test implementation, private parameters for test)
+def execute_test(args):
+ global publisher
+ global last_runtime
+
+ if rospy.get_time() < start_time + startup_delay:
+ rospy.logdebug("Waiting to for startup delay")
+ return
+
+ # Don't execute at greater than max frequency
+ time_step = rospy.get_time() - last_runtime
+ if 1.0 / time_step > options.max_freq:
+ return
+ else:
+ last_runtime = rospy.get_time()
+
+ test_impl, params = args
+
+ msg = DiagnosticMessage()
+ msg.status = [analyze(test_impl, params)]
+ publisher.publish(msg)
+
+## Starts up test, subscribes and publishes to diagnostics
+def diagnostic_test(package, test_name):
+ # retrieve the test implementation
+ roslib.load_manifest(package)
+ __import__("%s.%s"%(package, test_name))
+ try:
+ pypkg = sys.modules[package]
+ except KeyError:
+ print >> sys.stderr, "ERROR: cannot locate test package %s"%package
+ rospy.logerr("cannot locate test package %s"%package)
+ sys.exit(1)
+ test_impl = getattr(pypkg, test_name)
+
+ # must be inited before reading parameters
+ rospy.init_node(NAME, anonymous=True)
+ global start_time, last_runtime
+ last_runtime = rospy.get_time()
+ start_time = rospy.get_time()
+
+ # get it's parameters
+ params = rospy.get_param("~")
+
+ rospy.Subscriber("/diagnostics", DiagnosticMessage, callback, (test_impl, params))
+
+ # Publish results in diagnostics
+ global publisher
+ publisher = rospy.Publisher('/diagnostics', DiagnosticMessage)
+
+ # Always executes at greater than the min frequency
+ while not rospy.is_shutdown():
+ if rospy.get_time() - last_runtime > 1/options.min_freq:
+ execute_test((test_impl, params))
+ time.sleep(0.5/options.min_freq)
+
+if __name__ == '__main__':
+ from optparse import OptionParser
+ parser = OptionParser(usage="usage: %prog [options]", prog='runtime_test')
+ parser.add_option("--test", metavar="TEST_NAME",
+ dest="test_name", default='',
+ type="string", help="test name")
+ parser.add_option("--package", metavar="ROS_PACKAGE",
+ dest="package", default='diagnostic_test',
+ type="string", help="package test is in")
+ parser.add_option("--min_freq", metavar="MIN_FREQ",
+ dest="min_freq", default='0.5',
+ type="float", help="Minimum Execution Frequency(Hz)")
+ parser.add_option("--max_freq", metavar="MAX_FREQ",
+ dest="max_freq", default='1.0',
+ type="float", help="Maximum Execution Frequency(Hz)")
+ parser.add_option("--startup_delay", metavar="STARTUP_DELAY",
+ dest="startup_delay", default='10.0',
+ type="float", help="Time to wait before Polling(Seconds)")
+
+
+ options, args = parser.parse_args()
+
+
+ # expected or default
+ package = options.package
+ startup_delay = options.startup_delay
+
+ if options.test_name:
+ test_name = options.test_name
+ else:
+ parser.error("Diagnostic test must be given test to run")
+
+ try:
+ diagnostic_test(package, options.test_name)
+ except KeyboardInterrupt, e:
+ pass
+ print "exiting"
Property changes on: pkg/trunk/stacks/hardware_test/diagnostic_test/scripts/diagnostic_test.py
___________________________________________________________________
Added: svn:executable
+ *
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/__init__.py
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/__init__.py (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/__init__.py 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1 @@
+
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/expected.py
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/expected.py (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/src/diagnostic_test/expected.py 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# Software License Agreement (BSD License)
+#
+# Copyright (c) 2008, 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 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.
+#
+
+import rospy
+from diagnostic_msgs.msg import *
+
+stat_dict = { 0: 'OK', 1: 'Warning', 2: 'Error' }
+
+def test(latest_msgs, parameters):
+ status = DiagnosticStatus()
+ status.name = 'Expected Test'
+ status.level = 0
+ status.message = 'OK'
+ status.strings = []
+ status.values = []
+
+ if "name" in parameters:
+ status.name = 'Expected %s' % parameters["name"]
+
+ timeout = 3
+ if "timeout" in parameters:
+ timeout = float(parameters["timeout"])
+
+ if "expected_present" in parameters:
+ for name in parameters["expected_present"]:
+ if name in latest_msgs and rospy.get_time() - latest_msgs[name]["last_time"] < timeout:
+ msg = 'OK'
+ elif name in latest_msgs:
+ msg = 'Stale - Error'
+ status.level = max(status.level, 2)
+ else:
+ msg = 'Missing - Error'
+ status.level = max(status.level, 2)
+ status.strings.append(DiagnosticString(label = name, value = msg))
+
+
+ if "desired_present" in parameters:
+ for name in parameters["desired_present"]:
+ if name in latest_msgs and rospy.get_time() - latest_msgs[name]["last_time"] < timeout:
+ msg = 'OK'
+ elif name in latest_msgs:
+ msg = 'Stale - Warning'
+ status.level = max(status.level, 1)
+ else:
+ msg = 'Missing - Warning'
+ status.level = max(status.level, 1)
+ status.strings.append(DiagnosticString(label = name, value = msg))
+
+ status.message = stat_dict[status.level]
+
+ return status
+
+
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_publisher.py
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_publisher.py (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_publisher.py 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# Software License Agreement (BSD License)
+#
+# Copyright (c) 2008, 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 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.
+#
+
+# Author: Kevin Watts
+
+# Performs testing on diagnostic_test scripts
+
+import roslib
+roslib.load_manifest('diagnostic_test')
+
+import sys
+import rospy
+from diagnostic_msgs.msg import *
+import time
+
+def make_status_msg(name):
+ status = DiagnosticStatus()
+ status.name = name
+ status.level = 0
+ status.message = 'OK'
+ return status
+
+if __name__ == '__main__':
+ rospy.init_node('diagnostic_test_tester')
+
+ pub = rospy.Publisher('/diagnostics', DiagnosticMessage)
+
+ while not rospy.is_shutdown():
+ msg = DiagnosticMessage()
+
+ msg.status.append(make_status_msg('Expected 1'))
+ msg.status.append(make_status_msg('Expected 2'))
+ msg.status.append(make_status_msg('Desired 1'))
+
+ pub.publish(msg)
+ time.sleep(1.0)
+
+
+
Property changes on: pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_publisher.py
___________________________________________________________________
Added: svn:executable
+ *
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_status.yaml
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_status.yaml (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_status.yaml 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1,13 @@
+expected_present: [
+ 'Expected 1',
+ 'Expected 2',
+ 'Expected 3']
+
+desired_present: [
+ 'Desired 1',
+ 'Desired 2',
+ 'Desired 3']
+
+timeout: 3
+
+name: Tester
\ No newline at end of file
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_tester.launch
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_tester.launch (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/test/expected_tester.launch 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1,7 @@
+<launch>
+ <group ns="diagnostic_test">
+ <node pkg="diagnostic_test" type="diagnostic_test.py" args="--test=expected --min_freq=1.0 --max_freq=2.0 --startup_delay=10.0" output="screen" name="expected_test" >
+ <rosparam command="load" file="$(find diagnostic_test)/test/expected_status.yaml" />
+ </node>
+ </group>
+</launch>
\ No newline at end of file
Added: pkg/trunk/stacks/hardware_test/diagnostic_test/test/publish_test.launch
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostic_test/test/publish_test.launch (rev 0)
+++ pkg/trunk/stacks/hardware_test/diagnostic_test/test/publish_test.launch 2009-07-20 06:36:45 UTC (rev 19185)
@@ -0,0 +1,3 @@
+<launch>
+ <node pkg="diagnostic_test" type="expected_publisher.py" />
+</launch>
\ No newline at end of file
Modified: pkg/trunk/stacks/hardware_test/diagnostics_analysis/csv/export_csv.py
===================================================================
--- pkg/trunk/stacks/hardware_test/diagnostics_analysis/csv/export_csv.py 2009-07-20 01:24:10 UTC (rev 19184)
+++ pkg/trunk/stacks/hardware_test/diagnostics_analysis/csv/export_csv.py 2009-07-20 06:36:45 UTC (rev 19185)
@@ -65,12 +65,15 @@
stats[name] = {}
stats[name]['string_fields'] = [s.label for s in status.strings]
stats[name]['float_fields'] = [s.label for s in status.values]
+ stats[name]['level'] = status.level
+ stats[name]['message'] = status.message
file_name = name.replace(' ', '_').replace('(', '').replace(')', '').replace('/', '__').replace('.', '').replace('#', '')
stats[name]['file'] = file(output_dir + '/' + file_name + '.csv', 'w')
fields = stats[name]['string_fields'] + stats[name]['float_fields'];
- stats[name]['file'].write(', '.join(['timestamp'] + [f.replace(',','') for f in fields]) + '\n')
+ stats[name]['file'].write(', '.join(['timestamp'] + ['Level', 'Message'] +
+ [f.replace(',','') for f in fields]) + '\n')
# Need stuff for different string fields
# Store as dictionary, then convert to CSV?
@@ -84,8 +87,11 @@
#print "ERROR, mismatched field names in component %s. Label: %s" %(name, s.label)
#return stats
continue
+
# Should make time machine readable better
- stats[name]['file'].write(', '.join([time.asctime(t)] + [s.value.replace('\n', ' ').replace(',','') for s in status.strings] + [str(s.value) for s in status.values]) + '\n')
+ stats[name]['file'].write(', '.join([time.asctime(t)] + [str(status.level), status.message] +
+ [s.value.replace('\n', ' ').replace(',','') for s in status.strings] +
+ [str(s.value) for s in status.values]) + '\n')
def output(stats):
Deleted: pkg/trunk/stacks/hardware_test/runtime_monitor/scripts/runtime_test
===================================================================
--- pkg/trunk/stacks/hardware_test/runtime_monitor/scripts/runtime_test 2009-07-20 01:24:10 UTC (rev 19184)
+++ pkg/trunk/stacks/hardware_test/runtime_monitor/scripts/runtime_test 2009-07-20 06:36:45 UTC (rev 19185)
@@ -1,176 +0,0 @@
-#!/usr/bin/env python
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2008, 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 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.
-#
-
-## A basic node to monitor diagnostics for expected status
-
-import roslib; roslib.load_manifest('runtime_monitor')
-
-import sys, time
-import rospy
-from diagnostic_msgs.msg import DiagnosticMessage, DiagnosticStatus, DiagnosticValue, DiagnosticString
-
-NAME = 'runtime_test'
-
-# must initialize a node before we call get_time()
-rospy.init_node(NAME, anonymous=True)
-
-latest_messages = {}
-test_name = 'uninitialized'
-status_name = 'Runtime Test'
-package = 'uninitialized'
-last_runtime = 0
-startup_delay = 5.0
-start_time = rospy.get_time()
-
-## Records status as dictionary by labels for strings, values
-## Also stores last time of message, allows stale checks.
-def status_to_map(status):
- str_map = {}
- for s in status.strings:
- str_map[s.label] = s.value;
- for val in status.values:
- str_map[val.label] = val.value;
- str_map["name"]= status.name
- str_map["message"] = status.message
-
- # Store last time message was recorded
- str_map["last_time"] = rospy.get_time()
- return str_map
-
-## The test takes the latest_messages dictionary, the private parameters
-## and the status name (the name of the DiagnosticStatus message
-## it publishes)
-def analyze(test_impl, params):
- return test_impl.test(latest_messages, params, status_name)
-
-def callback(message, args):
- for s in message.status:
- latest_messages[s.name] = status_to_map(s)
- execute_test(args)
-
-def execute_test(args):
- global publisher
- global last_runtime
-
- if rospy.get_time() < start_time + startup_delay:
- rospy.logdebug("Waiting to for startup delay")
- return
-
- # Don't execute at greater than max frequency
- time_step = rospy.get_time() - last_runtime
- if 1.0 / time_step > options.max_freq:
- return
- else:
- last_runtime = rospy.get_time()
-
- test_impl, params = args
-
- msg = DiagnosticMessage()
- msg.status = [analyze(test_impl, params)]
- publisher.publish(msg)
-
-def runtime_test(package, test_name):
- # retrieve the test implementation
- roslib.load_manifest(package)
- __import__("%s.%s"%(package, test_name))
- try:
- pypkg = sys.modules[package]
- except KeyError:
- print >> sys.stderr, "ERROR: cannot locate test package %s"%package
- rospy.logerr("cannot locate test package %s"%package)
- sys.exit(1)
- test_impl = getattr(pypkg, test_name)
-
- # must be inited before reading parameters
- rospy.init_node(NAME, anonymous=True)
- global last_runtime
- last_runtime = rospy.get_time()
-
- # get it's parameters
- params = rospy.get_param("~")
-
- rospy.Subscriber("/diagnostics", DiagnosticMessage, callback, (test_impl, params))
-
- # Publish results in diagnostics
- global publisher
- publisher = rospy.Publisher('/diagnostics', DiagnosticMessage)
-
- # Always executes at greater than the min frequency
- while not rospy.is_shutdown():
- if rospy.get_time() - last_runtime > 1/options.min_freq:
- execute_test((test_impl, params))
- time.sleep(0.5/options.min_freq)
-
-if __name__ == '__main__':
- from optparse import OptionParser
- parser = OptionParser(usage="usage: %prog [options]", prog='runtime_test')
- parser.add_option("--test", metavar="TEST_NAME",
- dest="test_name", default='',
- type="string", help="test name")
- parser.add_option("--name", metavar="STATUS_NAME",
- dest="status_name", default='Runtime Test',
- type="string", help="Name of status message")
- parser.add_option("--package", metavar="ROS_PACKAGE",
- dest="package", default='runtime_monitor',
- type="string", help="package test is in")
- parser.add_option("--min_freq", metavar="min_frequency",
- dest="min_freq", default='0.5',
- type="float", help="Minimum Execution Frequency(Hz)")
- parser.add_option("--max_freq", metavar="max_frequency",
- dest="max_freq", default='1.0',
- type="float", help="Maximum Execution Frequency(Hz)")
- parser.add_option("--startup_delay", metavar="startup_delay",
- dest="startup_delay", default='5.0',
- type="float", help="Time to wait before Polling(Seconds)")
-
-
- options, args = parser.parse_args()
-
-
- # expected or default
- package = options.package
- startup_delay = options.startup_delay
-
- status_name = options.status_name
-
- if options.test_name:
- test_name = options.test_name
- else:
- parser.error("you must give me a test to run")
-
- try:
- runtime_test(package, options.test_name)
- except KeyboardInterrupt, e:
- pass
- print "exiting"
Deleted: pkg/trunk/stacks/hardware_test/runtime_monitor/src/runtime_monitor/expected.py
===================================================================
--- pkg/trunk/stacks/hardware_test/runtime_monitor/src/runtime_monitor/expected.py 2009-07-20 01:24:10 UTC (rev 19184)
+++ pkg/trunk/stacks/hardware_test/runtime_monitor/src/runtime_monitor/expected.py 2009-07-20 06:36:45 UTC (rev 19185)
@@ -1,80 +0,0 @@
-#!/usr/bin/env python
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2008, 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 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.
-#
-
-#import roslib
-#roslib.load_manifest(PKG)
-
-import rospy
-from diagnostic_msgs.msg import *
-
-stat_dict = { 0: 'OK', 1: 'Warning', 2: 'Error' }
-
-def test(latest_msgs, parameters, test_name):
- status = DiagnosticStatus()
- status.name = 'Expected %s' % test_name
- status.level = 0
- status.message = 'OK'
- status.strings = []
- status.values = []
-
- if "expected_present" in parameters:
- for name in parameters["expected_present"]:
- if name in latest_msgs and rospy.get_time() - latest_msgs[name]["last_time"] < 3.0:
- msg = 'OK'
- elif name in latest_msgs:
- msg = 'Stale - Error'
- status.level = max(status.level, 2)
- else:
- msg = 'Missing - Error'
- status.level = max(status.level, 2)
- status.strings.append(DiagnosticString(label = name, value = msg))
-
-
- if "desired_present" in parameters:
- for name in parameters["desired_present"]:
- if name in latest_msgs and rospy.get_time() - latest_msgs[name]["last_time"] < 3.0:
- msg = 'OK'
- elif name in latest_msgs:
- msg = 'Stale - Warning'
- status.level = max(status.level, 1)
- else:
- msg = 'Missing - Warning'
- status.level = max(status.level, 1)
- status.strings.append(DiagnosticString(label = name, value = msg))
-
- status.message = stat_dict[status.level]
-
- return status
-
-
Deleted: pkg/trunk/stacks/hardware_test/runtime_monitor/src/runtime_monitor/test_test.py
===================================================================
--- pkg/trunk/stacks/hardware_test/runtime_monitor/src/runtime_monitor/test_test.py 2009-07-20 01:24:10 UTC (rev 19184)
+++ pkg/trunk/stacks/hardware_test/runtime_monitor/src/runtime_monitor/test_test.py 2009-07-20 06:36:45 UTC (rev 19185)
@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2008, 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 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.
-#
-
-#import roslib
-#roslib.load_manifest(PKG)
-
-import sys
-import rospy
-from diagnostic_msgs.msg import *
-
-
-
-
-def test(latest_status, parameters, test_name):
- status = DiagnosticStatus()
- status.name = test_name
- status.level = 0
- status.message = 'OK'
- status.strings = []
- status.values = []
-
- for name in parameters["expected_present"]:
- if name in latest_status:
- msg = 'OK'
- else:
- msg = 'Error'
- status.strings.append(DiagnosticString(label = name, value = msg))
-
- return status
-
-
-
Deleted: pkg/trunk/stacks/hardware_test/runtime_monitor/test.yaml
===================================================================
--- pkg/trunk/stacks/hardware_test/runtime_monitor/test.yaml 2009-07-20 01:24:10 UTC (rev 19184)
+++ pkg/trunk/stacks/hardware_test/runtime_monitor/test.yaml 2009-07-20 06:36:45 UTC (rev 19185)
@@ -1,12 +0,0 @@
-run_id: 07e737e0-d21a-11dd-a091-e9379913be2c
-runtime:
- expected:
- desired_present: [Realtime Control Loop]
- expected_present: ['EtherCAT Device #19 (fl_caster_rotation_motor)', 'EtherCAT
- Device #18 (fl_caster_r_wheel_motor)', 'EtherCAT Device #17 (fl_caster_l_wheel_motor)',
- 'EtherCAT Device #14 (head_tilt_motor)', 'EtherCAT Device #13 (head_pan_motor)',
- 'EtherCAT Device #12 (laser_tilt_mount_motor)', 'EtherCAT Device #11 (torso_lift_motor)',
- 'EtherCAT Device #10 (fr_caster_rotation_motor)', 'EtherCAT Device #09 (fr_caster_r_wheel_motor)',
- 'EtherCAT Device #08 (fr_caster_l_wheel_motor)', 'EtherCAT Device #07 (bl_caster_rotation_motor)',
- 'EtherCAT Device #06 (bl_caster_r_wheel_motor)', 'EtherCAT Device #05 (bl_caster_l_wheel_motor)',
- 'EtherCAT Device #04 (br_caster_rotation_motor)']
Modified: pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/battery_presence.yaml
===================================================================
--- pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/battery_presence.yaml 2009-07-20 01:24:10 UTC (rev 19184)
+++ pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/battery_presence.yaml 2009-07-20 06:36:45 UTC (rev 19185)
@@ -22,3 +22,6 @@
desired_present: []
+name: Batteries
+
+timeout: 5
\ No newline at end of file
Modified: pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/expected_batteries.launch
===================================================================
--- pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/expected_batteries.launch 2009-07-20 01:24:10 UTC (rev 19184)
+++ pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/expected_batteries.launch 2009-07-20 06:36:45 UTC (rev 19185)
@@ -1,6 +1,6 @@
<launch>
-<group ns="runtime">
- <node pkg="runtime_monitor" type="runtime_test" args="--name=Batteries --test=expected --min_freq=1.0 --max_freq=2.0 --startup_delay=10.0" output="screen" name="battery_presence">
+<group ns="diagnostic_test">
+ <node pkg="diagnostic_test" type="diagnostic_test.py" args="--test=expected --min_freq=1.0 --max_freq=2.0 --startup_delay=10.0" output="screen" name="battery_presence">
<rosparam command="load" file="$(find ocean_battery_driver)/battery_presence.yaml"/>
</node>
</group>
Modified: pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/manifest.xml
===================================================================
--- pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/manifest.xml 2009-07-20 01:24:10 UTC (rev 19184)
+++ pkg/trunk/stacks/pr2_drivers/ocean_battery_driver/manifest.xml 2009-07-20 06:36:45 UTC (rev 19185)
@@ -6,5 +6,6 @@
<depend package="rospy" />
<depend package="diagnostic_msgs" />
<depend package="robot_msgs" />
+ <depend package="diagnostic_test" />
<rosdep name="wxpython"/>
</package>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|