4 PKG = 
'hironx_ros_bridge'     8     import hironx_ros_bridge
    10     import roslib; roslib.load_manifest(PKG)
    11     import hironx_ros_bridge
    13 from hironx_ros_bridge 
import hironx_client 
as hironx
    15 from hrpsys 
import rtm
    27 from rtm 
import connectPorts, disconnectPorts
    49         av0 = [-0.6, 0, -100, 15.2, 9.4, 3.2]
    50         av1 = [-0.6, -90, -100, 15.2, 9.4, 3.2]
    51         self.robot.setJointAnglesOfGroup( 
"rarm" , av0,  5)
    52         pose0 = robot.getReferencePose(
"RARM_JOINT5")
    57         self.robot.setJointAnglesOfGroup( 
"rarm" , av1,  5)
    58         self.robot.setJointAnglesOfGroup( 
"rarm" , av0,  5)
    60         pose1 = self.robot.getReferencePose(
"RARM_JOINT5")
    61         print "setJointAnglesOfGroup : reach goal?  ", numpy.linalg.norm(numpy.array(pose1)-numpy.array(pose0)) < 5.0e-3
    62         print "                      : spend 10 sec?", abs((tm1 - tm0) - 10.0) < 0.1, 
" " , tm1 - tm0
    65         self.robot.setJointAnglesOfGroup( 
"rarm" , av1,  5)
    67         self.robot.setJointAnglesOfGroup( 
"rarm" , av0,  5, wait=
False)
    69         pose1 = self.robot.getReferencePose(
"RARM_JOINT5")
    70         print "setJointAnglesOfGroup(wait=False)", numpy.linalg.norm(numpy.array(pose1)-numpy.array(pose0)) > 5.0e-3
    71         print "                      : spend 10 sec?", abs((tm1 - tm0) - 0.0) < 0.1, 
" " , tm1 - tm0
    74         self.robot.waitInterpolationOfGroup(
"rarm")
    76         pose1 = self.robot.getReferencePose(
"RARM_JOINT5")
    77         print "waitInterpolationOfGroup", numpy.linalg.norm(numpy.array(pose1)-numpy.array(pose0)) < 5.0e-3
    78         print "                      : spend 10 sec?", abs((tm1 - tm0) - 5.0) < 0.1, 
" " , tm1 - tm0
    88             current_time = float(line.split(
' ')[0])
    89             current_value = float(line.split(
' ')[7])
    91                 start_time = current_time
    92             data.append([current_time, current_value*180/math.pi])
    95         self.filenames.append(name)
   105             data.append([float(i)*180/math.pi 
for i 
in line.split(
' ')[1:-1]])
   108         self.filenames.append(name)
   111     def check_log_data(self, data, idx, tm_data, min_data, max_data, acc_thre=0.06, tm_thre=0.1): 
   112         _tm_data = len(data)/200.0
   113         _min_data = 
min([d[idx] 
for d 
in data])
   114         _max_data = max([d[idx] 
for d 
in data])
   117         if isinstance(min_data, (int, float)):
   118             min_data = [min_data, 5]
   119         if isinstance(max_data, (int, float)):
   120             max_data = [max_data, 5]
   122         print "time (= ", _tm_data, 
") == ", tm_data, 
" -> ", abs(_tm_data - tm_data) < tm_data*_tm_thre
   123         print " min (= ", _min_data, 
") == ", min_data, 
" -> ", abs(_min_data - min_data[0]) < min_data[1]
   124         print " max (= ", _max_data, 
") == ", max_data, 
" -> ", abs(_max_data - max_data[0]) < max_data[1]
   125         self.
assertTrue(abs(_tm_data - tm_data) < tm_data*_tm_thre)
   126         self.
assertTrue(abs(_min_data - min_data[0]) < min_data[1])
   127         self.
assertTrue(abs(_max_data - max_data[0]) < max_data[1])
   131         for i 
in range(1, len(data)-1):
   132             for j 
in range(len(data[i])):
   138                 if abs(v1 - v0) > acc_thre:
   140                     print(
"Acceleration vaiorated! : n = %d, idx %d, p0 %f, p1 %f, p2 %f, v1 %f, v2 %f, acc %f (%f)" % (i, j, p0, p1, p2, v0, v1, v1-v0, (v1-v0)/180.0*math.pi))
   144         name_d = os.path.splitext(name)[0]+
".dq"   145         name_dd = os.path.splitext(name)[0]+
".ddq"   147         f_d = open(name_d, 
'w')
   148         f_dd = open(name_dd, 
'w')
   153             if line_2 
and line_1 :
   154                 tm = float(line_1.split(
' ')[0])
   157                 for i 
in range(1,len(line_0.split(
' '))-1):
   158                     p0 = float(line_0.split(
' ')[i])
   159                     p1 = float(line_1.split(
' ')[i])
   160                     p2 = float(line_2.split(
' ')[i])
   163                     f_d.write(
" %.10f"%v0)
   164                     f_dd.write(
" %.10f"%(v1 - v0))
   172         print "[%s] write %s"%(__file__, name_d)
   173         print "[%s] write %s"%(__file__, name_dd)
   176         print "[%s] write pdf %s from log data %s"%(__file__, pdf_name, name)
   179         for _name 
in [name, os.path.splitext(name)[0]+
".dq", os.path.splitext(name)[0]+
".ddq"]:
   180             _pdf_names.append(_name+
"_"+pdf_name)
   181             cmd = 
"gnuplot -p -e \"set terminal pdf; set output '"+_pdf_names[-1]+
"'; plot "   183             l = f.readline().split(
' ')[:-1]
   185             for i 
in range(1,len(l)):
   186                 cmd += 
"'"+_name+
"' using 1:"+str(i+1)+
" title 'joint "+str(i)+
"' with lines"   191         cmd_str = 
'pdfunite '+
' '.join(_pdf_names) + 
' ' + pdf_name
   192         cmd_str = cmd_str.replace(
'(', 
'\(')
   193         cmd_str = cmd_str.replace(
')', 
'\)')
   201         f2 = open(name2, 
'w')
   206             if line_2 
and line_1 :
   207                 tm = float(line_1.split(
' ')[0])
   209                 for i 
in range(1,len(line_0.split(
' '))-1):
   210                     p0 = float(line_0.split(
' ')[i])
   211                     p1 = float(line_1.split(
' ')[i])
   212                     p2 = float(line_2.split(
' ')[i])
   215                     if abs(v1 - v0) > 0.0001:
   216                         print(
"%s Acceleration vaiorated! : p0 %f, p1 %f, p2 %f, v1 %f, v2 %f, acc %f" % (name, p0, p1, p2, v0, v1, v1-v0))
   218                     f2.write(
' ' + str(v1 - v0))
   230         print ";; write log data to "+name
   233         cmd = 
"gnuplot -p -e \"set terminal pdf; set output '"+name+
"'; plot "   234         for name 
in self.filenames:
   235             cmd += 
"'"+name+
"' using 0:8 title '"+name+
"' with lines"   236             if name != self.filenames[-1]:
   246 if __name__ == 
'__main__':
   248     rostest.rosrun(PKG, 
'test_hronx', TestHiro) 
 def write_output_to_pdf(self, name)
def check_log_data(self, data, idx, tm_data, min_data, max_data, acc_thre=0.06, tm_thre=0.1)
def check_q_data(self, name)
def set_joint_angles_no_wait_test(self)
def write_all_joint_pdf(self, name, pdf_name)
def load_log_data(self, name)
def write_d_dd_data(self, name)
def check_acceleration(self, name)