10 from time
import sleep
36 if not os.path.exists(
"./matrices.txt"):
37 print "Error - the matrices.txt file is not in gd_scripts directory" 39 matrixArray = [line.rstrip(
'\n')
for line
in open(
"matrices.txt",
'r')] 41 if len(matrixArray) != 5:
42 print "Error - The matrices.txt file is not correct" 45 for matS
in xrange(0,len(matrixArray)):
46 matSArray = matrixArray[matS].split(
',')
48 for value_mat
in matSArray:
50 f.append(float(value_mat.replace(
" ",
"")))
52 print "Error - The matrices.txt file is not correct" 55 my_array_for_publishing = Float32MultiArray(data=f)
59 print "Error - The matrices.txt file is not correct" 61 pub_matA.publish(my_array_for_publishing)
64 print "Error - The matrices.txt file is not correct" 66 pub_matB.publish(my_array_for_publishing)
69 print "Error - The matrices.txt file is not correct" 71 pub_matK.publish(my_array_for_publishing)
74 print "Error - The matrices.txt file is not correct" 76 pub_matL.publish(my_array_for_publishing)
79 print "Error - The matrices.txt file is not correct" 81 height_cm = (f[0] + f[1])/2
100 rospy.init_node(
'configure_params')
104 height_pub = rospy.Publisher(
"/cmd_height", std_msgs.msg.Float32, queue_size=10)
105 center_pub = rospy.Publisher(
"/calib_center", std_msgs.msg.Float32, queue_size=10)
107 pub_matA = rospy.Publisher(
"/matrixA", Float32MultiArray, queue_size=10)
108 pub_matB = rospy.Publisher(
"/matrixB", Float32MultiArray, queue_size=10)
109 pub_matK = rospy.Publisher(
"/matrixK", Float32MultiArray, queue_size=10)
110 pub_matL = rospy.Publisher(
"/matrixL", Float32MultiArray, queue_size=10)
115 set_input_srv = rospy.ServiceProxy(
'/set_input', gd_msgs.srv.SetInput)
116 init_balance_srv = rospy.ServiceProxy(
'/init_balance', std_srvs.srv.Empty)
122 height_pub.publish(height_cm)
124 center_pub.publish(center)
128 set_input_rsp = set_input_srv(input_cmd)
131 init_balance_rsp = init_balance_srv()
139 if __name__ ==
'__main__':
141 if len(sys.argv) == 3:
143 center = float(sys.argv[1])
144 input_cmd = float(sys.argv[2])
146 print "Error - The script needs 2 argv: <IMU-Calibration> <PC(0)/RC(1)>"