3 @author: Gabriele Buondonno
4 This module contains utilities for running the tests
8 from __future__
import print_function
10 from distutils.util
import strtobool
11 from time
import sleep
24 runCommandClient = rospy.ServiceProxy(
"run_command", RunCommand)
29 Auxiliary function to manage the verbosity of runCommandClient
30 verbosity = 0: simply execute runCommandClient
31 verbosity = 1 (default): if runCommandClient returns something on the standard output or standard error, print it
32 verbosity = 2: print the whole answer returned by runCommandClient
41 elif verbosity == 1
and (out.standardoutput
or out.standarderror):
42 print(
"command: " + code)
43 if out.standardoutput:
44 print(
"standardoutput: " + out.standardoutput)
46 print(
"standarderror: " + out.standarderror)
52 Auxiliary function to quickly extract return values from runCommandClient.
53 This will only work when the result in a plain object data type (such as an in or float) or a string
58 def launch_script(code, title, description="", verbosity=1, interactive=True):
60 input(title +
": " + description)
67 if line ==
"" or line.startswith(indent):
68 codeblock +=
"\n" + line
72 rospy.logdebug(answer)
74 if line !=
"" and line[0] !=
"#":
75 if line.endswith(
":"):
80 rospy.logdebug(answer)
81 rospy.loginfo(
"...done with " + title)
84 def run_test(appli, verbosity=1, interactive=True):
86 rospy.loginfo(
"Waiting for run_command")
87 rospy.wait_for_service(
"/run_command")
88 rospy.loginfo(
"...ok")
90 rospy.loginfo(
"Waiting for start_dynamic_graph")
91 rospy.wait_for_service(
"/start_dynamic_graph")
92 rospy.loginfo(
"...ok")
94 runCommandStartDynamicGraph = rospy.ServiceProxy(
"start_dynamic_graph", Empty)
96 initCode = open(appli,
"r").read().split(
"\n")
98 rospy.loginfo(
"Stack of Tasks launched")
101 initCode,
"initialize SoT", verbosity=verbosity, interactive=interactive
104 input(
"Wait before starting the dynamic graph")
105 runCommandStartDynamicGraph()
107 except rospy.ServiceException
as e:
108 rospy.logerr(
"Service call failed: %s" % e)
112 c =
input(text +
" [y/N] ")
124 print(
"Calibrating sensors...")
127 print(
"Sensors are calibrated!")
128 print(
"You can now put the robot on the ground")
130 print(
"Skipping sensor calibration")
138 c =
input(
"Calibrate wrist force sensors? [y/N] ")
144 input(
"Wait before running the calibration")
145 print(
"Calibrating sensors...")
148 print(
"Sensors are calibrated!")
150 print(
"Skipping sensor calibration")
156 sot_talos_balance_folder =
False
157 print(
"No folder data")
159 test_folder = argv[1]
160 sot_talos_balance_folder =
False
161 print(
"Using folder " + test_folder)
164 raise ValueError(
"Unrecognized option: " + argv[1])
165 test_folder = argv[2]
166 sot_talos_balance_folder =
True
167 print(
"Using folder " + test_folder +
" from sot_talos_balance")
169 raise ValueError(
"Bad options")
172 print(
"Sending folder info...")
173 if test_folder
is None:
177 runCommandClient(
"sot_talos_balance_folder = " + str(sot_talos_balance_folder))
179 return test_folder, sot_talos_balance_folder
def ask_for_confirmation(text)
def run_ft_calibration(sensor_name, force=False)
def run_ft_wrist_calibration(sensor_name, force=False)
def runVerboseCommandClient(code, verbosity=1)
def evalCommandClient(code)
def run_test(appli, verbosity=1, interactive=True)
def launch_script(code, title, description="", verbosity=1, interactive=True)
def get_file_folder(argv, send=True)