Skip to content

Commit 45609c7

Browse files
committed
Fix Python print methods
1 parent ddfecc7 commit 45609c7

13 files changed

+38
-38
lines changed

ambf_ros_modules/ambf_client/python/test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
c = Client()
55
c.connect()
66
time.sleep(1.0)
7-
# print c.get_obj_names()
7+
# print(c.get_obj_names())
88
time.sleep(1.0)
99
b = c.get_obj_handle('baselink')
10-
print b.get_name()
10+
print(b.get_name())

ambf_ros_modules/ambf_client/python/tests/duplex_com_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def cb(data):
1515
step = data.sim_step
1616
cb_ctr +=1
1717
if cb_ctr % 1000 == 0:
18-
print step
18+
print(step)
1919

2020

2121
def main():
@@ -35,7 +35,7 @@ def main():
3535
cmd.step_clock = not cmd.step_clock
3636
pre_step = step
3737
if dstep > cmd.n_skip_steps:
38-
print 'Jumped {} steps, default is {}'.format(dstep, cmd.n_skip_steps)
38+
print('Jumped {} steps, default is {}'.format(dstep, cmd.n_skip_steps))
3939
pub.publish(cmd)
4040
rate.sleep()
4141

ambf_ros_modules/ambf_client/python/tests/dynamo_haptic_response_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ def w_cb(msg):
105105
g1D.reset()
106106
g2D.reset()
107107
collection_enabled = False
108-
print 'Setting Rate to {} Hz and testing'.format(r)
108+
print('Setting Rate to {} Hz and testing'.format(r))
109109
time_offset = rospy.Time.now().to_sec() + 4.0
110110
while not g1D.is_done() or not g2D.is_done():
111111
wCmd.step_clock = not wCmd.step_clock
112112
w_pub.publish(wCmd)
113113
rate.sleep()
114114
if not collection_enabled and rospy.Time.now().to_sec() > time_offset:
115115
collection_enabled = True
116-
print 'Enabling Data Collection'
116+
print('Enabling Data Collection')
117117
g1D.enable_collectoin()
118118
g2D.enable_collectoin()
119119
g1D.compute_data_metrics()

ambf_ros_modules/ambf_client/python/tests/haptic_response_test.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self, name):
5959
self.data_lim = 1000
6060
if len(sys.argv) > 1:
6161
self.data_lim = int(sys.argv[1])
62-
print 'Taking {} data points'.format(sys.argv[1])
62+
print('Taking {} data points'.format(sys.argv[1]))
6363
self.data = np.zeros(self.data_lim)
6464
self.ctr = 0
6565
self.name = name
@@ -73,11 +73,11 @@ def compute_data_metrics(self):
7373
mean = np.mean(self.data)
7474
std_dev = np.std(self.data)
7575

76-
print '----------------------------------'
77-
print 'Data Metrics for {}'.format(self.name)
78-
print 'Mean = {}'.format(mean)
79-
print 'Std Deviation = {}'.format(std_dev)
80-
print '----------------------------------'
76+
print('----------------------------------')
77+
print('Data Metrics for {}'.format(self.name))
78+
print('Mean = {}'.format(mean))
79+
print('Std Deviation = {}'.format(std_dev))
80+
print('----------------------------------')
8181

8282
def is_done(self):
8383
if self.ctr < self.data_lim:

ambf_ros_modules/ambf_client/python/tests/message_latency.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def capture_window_times(self, time):
8585
if not self.window_times_captured:
8686
self.time_window_lims[0] = time + 1.0
8787
self.time_window_lims[1] += self.time_window_lims[0]
88-
print 'Capturing Time from {} to {}'.format(self.time_window_lims[0], self.time_window_lims[1])
88+
print('Capturing Time from {} to {}'.format(self.time_window_lims[0], self.time_window_lims[1]))
8989
self.window_times_captured = True
9090

9191
def obj_state_cb(self, data):
@@ -97,9 +97,9 @@ def obj_state_cb(self, data):
9797
if self.is_first_run:
9898
self.capture_window_times(data.wall_time)
9999
self.initial_time_offset = ambf_sim_wall_time - data.wall_time
100-
print 'ROS & AMBF Clock Offset in C++ Server: ', self.initial_time_offset
101-
print 'AMBF Wall Time after offset : ', ambf_sim_wall_time - self.initial_time_offset
102-
print 'Cur Process Wall Time after offset : ', process_wall_time - self.initial_time_offset
100+
print('ROS & AMBF Clock Offset in C++ Server: ', self.initial_time_offset)
101+
print('AMBF Wall Time after offset : ', ambf_sim_wall_time - self.initial_time_offset)
102+
print('Cur Process Wall Time after offset : ', process_wall_time - self.initial_time_offset)
103103
self.is_first_run = False
104104

105105
self.ambf_process_wall_time.append(ambf_sim_wall_time - self.initial_time_offset)
@@ -117,15 +117,15 @@ def obj_state_cb(self, data):
117117

118118
def compute_mean_latency(self):
119119
self.mean_latency = sum(self.latency_list) / len(self.latency_list)
120-
print 'Mean Latency= ', self.mean_latency, ' | Itrs= ', len(self.latency_list), ' | Counter=', self.cb_counter
120+
print('Mean Latency= ', self.mean_latency, ' | Itrs= ', len(self.latency_list), ' | Counter=', self.cb_counter)
121121

122122
total_packets = (self.msg_counter_num[-1] + 1) - self.msg_counter_num[0]
123123
total_packets_rcvd = len(self.msg_counter_num)
124124
percent_packets_rcvd = (total_packets_rcvd * 1.0) / (total_packets * 1.0)
125125

126-
print 'Total packets sent by C++ Server: ', total_packets
127-
print 'Total packets received by Client: ', total_packets_rcvd
128-
print 'Percentage of packets received : {}%'.format(100 * percent_packets_rcvd)
126+
print('Total packets sent by C++ Server: ', total_packets)
127+
print('Total packets received by Client: ', total_packets_rcvd)
128+
print('Percentage of packets received : {}%'.format(100 * percent_packets_rcvd))
129129

130130
def calculate_packets_dt(self, list):
131131
new_list = []
@@ -137,7 +137,7 @@ def run(self):
137137
rospy.init_node('message_latency_inspector')
138138
sub = rospy.Subscriber('/ambf/env/World/State', WorldState, self.obj_state_cb, queue_size=self.queue_size)
139139

140-
print 'X Axis = ', self.x_axis_dict[self.x_axis_type][0]
140+
print('X Axis = ', self.x_axis_dict[self.x_axis_type][0])
141141
x_axis_indx = self.x_axis_dict[self.x_axis_type][1]
142142

143143
while not rospy.is_shutdown() and not self.done:

ambf_ros_modules/ambf_client/python/tests/mtm_ambf_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@
6464

6565
if len(sys.argv) > 1:
6666
tc = float(sys.argv[1])
67-
print 'Setting Time Constant to {}'.format(sys.argv[1])
67+
print('Setting Time Constant to {}'.format(sys.argv[1]))
6868
if len(sys.argv) > 2:
6969
scale = float(sys.argv[2])
70-
print 'Setting Scale to {}'.format(sys.argv[2])
70+
print('Setting Scale to {}'.format(sys.argv[2]))
7171

7272

7373
rospy.init_node('mtm_ambf_test')

ambf_ros_modules/ambf_client/python/tests/occulus_view.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def main():
117117
occulus_pub.publish(occulus_cmd)
118118
counter = counter + 1
119119
if counter % 60 == 0:
120-
print "- Publishing Occulus Pose ", format( round(rospy.get_time() - start, 3)), 's'
120+
print("- Publishing Occulus Pose ", format( round(rospy.get_time() - start, 3)), 's')
121121
rate.sleep()
122122

123123

ambf_ros_modules/ambf_client/python/tests/position_control.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def ambf_cb(msg):
126126
last_delta_pos = delta_pos
127127
delta_pos = cmd_pos - cur_pos
128128
delta_delta_pos = (delta_pos - last_delta_pos) / dt
129-
# print delta_pos, last_delta_pos
130-
# print (D_lin * delta_delta_pos) / dtp
129+
# print(delta_pos, last_delta_pos)
130+
# print(D_lin * delta_delta_pos) / dtp)
131131
force = PU.K_lin * delta_pos + PU.D_lin * delta_delta_pos
132132

133133
m_drot_prev = m_drot

ambf_ros_modules/ambf_client/python/tests/rt_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def main():
4242
start_time = rospy.get_time()
4343
cur_time = start_time
4444
end_time = cur_time + episode
45-
print cur_time
45+
print(cur_time)
4646
while not rospy.is_shutdown() and cur_time <= end_time:
4747

4848
cur_time = rospy.get_time()

ambf_ros_modules/ambf_client/python/tests/study_analysis.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def compute_number_of_clutches(topic_name, t_start=-1, t_end=-1):
7373
return num_clutches, clutch_press_times
7474

7575

76-
print (os.listdir('.'))
76+
print(os.listdir('.'))
7777
os.chdir('./user_study_data/')
7878
print(os.listdir('.')[0])
7979

@@ -110,9 +110,9 @@ def compute_number_of_clutches(topic_name, t_start=-1, t_end=-1):
110110
mtmr_force_traj = get_force_trajectory('/ambf/env/simulated_device_1/MTML/State', t_end=final_time)
111111
mtml_force_traj = get_force_trajectory('/ambf/env/simulated_device_2/MTMR/State', t_end=final_time)
112112

113-
print "MTMR Path Length: ", mtmr_path_len
114-
print "MTML Path Length: ", mtml_path_len
115-
print "Number of Clutches: ", compute_number_of_clutches('/dvrk/footpedals/clutch', t_end=final_time)
113+
print("MTMR Path Length: ", mtmr_path_len)
114+
print("MTML Path Length: ", mtml_path_len)
115+
print("Number of Clutches: ", compute_number_of_clutches('/dvrk/footpedals/clutch', t_end=final_time))
116116

117117
# fig = plt.figure()
118118
# ax = plt.axes(projection='3d')

ambf_ros_modules/ambf_client/python/tests/test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
client = Client()
5353
client.connect()
54-
print client.get_obj_names()
54+
print(client.get_obj_names())
5555
obj = client.get_obj_handle(obj_name)
5656

5757
if obj:
@@ -63,5 +63,5 @@
6363
time.sleep(0.01)
6464

6565
else:
66-
print obj_name, 'not found'
66+
print(obj_name, 'not found')
6767

ambf_ros_modules/ambf_client/python/tests/time_dilation_analysis_tool.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(self):
7979
def capture_window_times(self, time):
8080
self.time_window_lims[0] = time + 1.0
8181
self.time_window_lims[1] += self.time_window_lims[0]
82-
print 'Capturing Time from {} to {}'.format(self.time_window_lims[0], self.time_window_lims[1])
82+
print('Capturing Time from {} to {}'.format(self.time_window_lims[0], self.time_window_lims[1]))
8383

8484
def obj_state_cb(self, data):
8585
if not self.done:
@@ -90,7 +90,7 @@ def obj_state_cb(self, data):
9090
if self.first_run:
9191
self.capture_window_times(ambf_wall_time)
9292
self.initial_time_offset = rospy.Time.now().to_sec() - ambf_wall_time
93-
print 'Adjusting Time Offset'
93+
print('Adjusting Time Offset')
9494
self.first_run = False
9595
self.ambf_sim_time.append(ambf_sim_time)
9696
self.ambf_wall_time.append(ambf_wall_time)
@@ -110,7 +110,7 @@ def run(self):
110110
rospy.init_node('time_dilation_inspector')
111111
sub = rospy.Subscriber('/ambf/env/World/State', WorldState, self.obj_state_cb, queue_size=10)
112112

113-
print 'X Axis = ', self.x_axis_dict[0][0]
113+
print('X Axis = ', self.x_axis_dict[0][0])
114114
x_axis_indx = self.x_axis_dict[0][1]
115115

116116
for i in range(1, self.x_axis_dict.__len__()):

ambf_ros_modules/ambf_client/python/tests/user_study.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ def call(self):
7575
date_time_str = str(datetime.now()).replace(' ', '_')
7676
self._rosbag_filepath = './user_study_data/' + e1.get() + '_' + b1.get() + '_' + date_time_str
7777
command = "rosbag record -O" + ' ' + self._rosbag_filepath + self._topic_names_str
78-
print "Running Command", command
78+
print("Running Command", command)
7979
command = shlex.split(command)
8080
self._rosbag_process = subprocess.Popen(command)
8181
else:
82-
print "Already recording a ROSBAG file, please save that first before starting a new record"
82+
print("Already recording a ROSBAG file, please save that first before starting a new record")
8383

8484
def save(self):
8585

0 commit comments

Comments
 (0)