1 from timeout
import timeout
3 import matplotlib.pyplot
as plt
4 rospy.init_node(
'tester')
18 data_sim = config[
'/simulation/joint_states/position']
19 data_real = config[
'/real/joint_states/position']
26 def plot(data, style = '-'):
28 print "single plot %d" % data.shape[1]
32 for i
in range(data.shape[1]):
34 plt.subplot(3, 2, i+1)
35 print "plottting data %d" % i
38 plt.plot(col, ls = style)
45 mserr = ((x - y) ** 2).mean(axis=axis)
62 min_err = float(
"inf")
64 for i
in range(-offset, offset+1):
65 x_new, y_new =
shift(x, y, i)
70 err =
error(x_new, y_new, axis)
76 print min_err, min_index
78 return min_err, min_index
81 def f(config, axis = 0):
85 print "the config is:" 87 sim_pos = config[
'/simulation/joint_states/position']
91 real_pos = config[
'/real/joint_states/position']
93 sim_pos = sim_pos[:,[1,3,4,5,6,8]]
94 real_pos = real_pos[:,[1,3,4,5,6,8]]
98 sim_pos, real_pos =
shift(sim_pos, real_pos, offset)
100 config[
'/simulation/joint_states/position'] = sim_pos
101 config[
'/real/joint_states/position'] = real_pos
123 from dynamic_tuner
import *
128 '/simulation/sensor_states/contact[10]',
129 '/simulation/sensor_states/contact[6]',
130 '/simulation/sensor_states/contact[1]',
131 '/simulation/sensor_states/contact[8]',
133 '/real/sensor_states/contact[3]',
134 '/real/sensor_states/contact[2]',
135 '/real/sensor_states/contact[4]',
136 '/real/sensor_states/contact[0]',
137 '/real/sensor_states/contact[1]',
139 '/simulation/sensor_states',
140 '/real/sensor_states',
144 '/simulation/haptix_deka_controller/command',
145 '/real/haptix_deka_controller/command' 153 src_topic =
'/haptix_deka_controller/command' 154 dst_topic =
'/haptix_deka_controller/command' 157 src_bag =
'exp-contacts.bag' 158 dst_bag =
'test_sim.bag' 166 print "ready to start" 178 from dynamic_tuner import * 179 start_simulation('exp-real-7.bag', 'test_sim.bag', '/follow_joint_trajectory/goal', '/arm_controller/follow_joint_trajectory/goal', {'/follow_joint_trajectory/goal':None, '/arm_controller/follow_joint_trajectory/goal':None}, {'/arm_controller/follow_joint_trajectory/result':None, '/follow_joint_trajectory/result':None}) 182 from dynamic_tuner import * 183 start_simulation('exp-real-7.bag', 'test_sim.bag', '/follow_joint_trajectory/goal', '/arm_controller/follow_joint_trajectory/goal', {'/follow_joint_trajectory/status/status_list[0]/status':1, '/arm_controller/follow_joint_trajectory/feedback/status/status':1}, {'/arm_controller/follow_joint_trajectory/result':None, '/follow_joint_trajectory/result':None}) 187 sim_bag = rosbag.Bag('test_sim.bag', 'r') 188 bag = restamp(sim_bag, output_bag_file = 'sim-restamped.bag', prefix = SIM_PREFIX, start_signal = start_signal, end_signal = end_signal)
191 dyn._optimizer.optimize()
193 dyn._optimizer.set_params_config({
'/arm_controller/gains/elbow_joint/p':100001})
194 desc = dyn.get_params_desc([
'/arm_controller/gains/elbow_joint/p',
'/arm_controller/gains/elbow_joint/i',
'/arm_controller/gains/wrist_3_joint/d'])
def start_simulation(real_bag_file, sim_bag_file, src_topic, dst_topic, values=[], start_signal={}, end_signal={})
def restamp(bag, output_bag_file='restamped.bag', values=[], prefix="", start_signal={}, end_signal={})