Skip to content

Commit

Permalink
Fix Python print methods
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanmunawar committed Nov 12, 2024
1 parent ddfecc7 commit 45609c7
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions ambf_ros_modules/ambf_client/python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
c = Client()
c.connect()
time.sleep(1.0)
# print c.get_obj_names()
# print(c.get_obj_names())
time.sleep(1.0)
b = c.get_obj_handle('baselink')
print b.get_name()
print(b.get_name())
4 changes: 2 additions & 2 deletions ambf_ros_modules/ambf_client/python/tests/duplex_com_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def cb(data):
step = data.sim_step
cb_ctr +=1
if cb_ctr % 1000 == 0:
print step
print(step)


def main():
Expand All @@ -35,7 +35,7 @@ def main():
cmd.step_clock = not cmd.step_clock
pre_step = step
if dstep > cmd.n_skip_steps:
print 'Jumped {} steps, default is {}'.format(dstep, cmd.n_skip_steps)
print('Jumped {} steps, default is {}'.format(dstep, cmd.n_skip_steps))
pub.publish(cmd)
rate.sleep()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ def w_cb(msg):
g1D.reset()
g2D.reset()
collection_enabled = False
print 'Setting Rate to {} Hz and testing'.format(r)
print('Setting Rate to {} Hz and testing'.format(r))
time_offset = rospy.Time.now().to_sec() + 4.0
while not g1D.is_done() or not g2D.is_done():
wCmd.step_clock = not wCmd.step_clock
w_pub.publish(wCmd)
rate.sleep()
if not collection_enabled and rospy.Time.now().to_sec() > time_offset:
collection_enabled = True
print 'Enabling Data Collection'
print('Enabling Data Collection')
g1D.enable_collectoin()
g2D.enable_collectoin()
g1D.compute_data_metrics()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, name):
self.data_lim = 1000
if len(sys.argv) > 1:
self.data_lim = int(sys.argv[1])
print 'Taking {} data points'.format(sys.argv[1])
print('Taking {} data points'.format(sys.argv[1]))
self.data = np.zeros(self.data_lim)
self.ctr = 0
self.name = name
Expand All @@ -73,11 +73,11 @@ def compute_data_metrics(self):
mean = np.mean(self.data)
std_dev = np.std(self.data)

print '----------------------------------'
print 'Data Metrics for {}'.format(self.name)
print 'Mean = {}'.format(mean)
print 'Std Deviation = {}'.format(std_dev)
print '----------------------------------'
print('----------------------------------')
print('Data Metrics for {}'.format(self.name))
print('Mean = {}'.format(mean))
print('Std Deviation = {}'.format(std_dev))
print('----------------------------------')

def is_done(self):
if self.ctr < self.data_lim:
Expand Down
18 changes: 9 additions & 9 deletions ambf_ros_modules/ambf_client/python/tests/message_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def capture_window_times(self, time):
if not self.window_times_captured:
self.time_window_lims[0] = time + 1.0
self.time_window_lims[1] += self.time_window_lims[0]
print 'Capturing Time from {} to {}'.format(self.time_window_lims[0], self.time_window_lims[1])
print('Capturing Time from {} to {}'.format(self.time_window_lims[0], self.time_window_lims[1]))
self.window_times_captured = True

def obj_state_cb(self, data):
Expand All @@ -97,9 +97,9 @@ def obj_state_cb(self, data):
if self.is_first_run:
self.capture_window_times(data.wall_time)
self.initial_time_offset = ambf_sim_wall_time - data.wall_time
print 'ROS & AMBF Clock Offset in C++ Server: ', self.initial_time_offset
print 'AMBF Wall Time after offset : ', ambf_sim_wall_time - self.initial_time_offset
print 'Cur Process Wall Time after offset : ', process_wall_time - self.initial_time_offset
print('ROS & AMBF Clock Offset in C++ Server: ', self.initial_time_offset)
print('AMBF Wall Time after offset : ', ambf_sim_wall_time - self.initial_time_offset)
print('Cur Process Wall Time after offset : ', process_wall_time - self.initial_time_offset)
self.is_first_run = False

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

def compute_mean_latency(self):
self.mean_latency = sum(self.latency_list) / len(self.latency_list)
print 'Mean Latency= ', self.mean_latency, ' | Itrs= ', len(self.latency_list), ' | Counter=', self.cb_counter
print('Mean Latency= ', self.mean_latency, ' | Itrs= ', len(self.latency_list), ' | Counter=', self.cb_counter)

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

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

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

print 'X Axis = ', self.x_axis_dict[self.x_axis_type][0]
print('X Axis = ', self.x_axis_dict[self.x_axis_type][0])
x_axis_indx = self.x_axis_dict[self.x_axis_type][1]

while not rospy.is_shutdown() and not self.done:
Expand Down
4 changes: 2 additions & 2 deletions ambf_ros_modules/ambf_client/python/tests/mtm_ambf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@

if len(sys.argv) > 1:
tc = float(sys.argv[1])
print 'Setting Time Constant to {}'.format(sys.argv[1])
print('Setting Time Constant to {}'.format(sys.argv[1]))
if len(sys.argv) > 2:
scale = float(sys.argv[2])
print 'Setting Scale to {}'.format(sys.argv[2])
print('Setting Scale to {}'.format(sys.argv[2]))


rospy.init_node('mtm_ambf_test')
Expand Down
2 changes: 1 addition & 1 deletion ambf_ros_modules/ambf_client/python/tests/occulus_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def main():
occulus_pub.publish(occulus_cmd)
counter = counter + 1
if counter % 60 == 0:
print "- Publishing Occulus Pose ", format( round(rospy.get_time() - start, 3)), 's'
print("- Publishing Occulus Pose ", format( round(rospy.get_time() - start, 3)), 's')
rate.sleep()


Expand Down
4 changes: 2 additions & 2 deletions ambf_ros_modules/ambf_client/python/tests/position_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def ambf_cb(msg):
last_delta_pos = delta_pos
delta_pos = cmd_pos - cur_pos
delta_delta_pos = (delta_pos - last_delta_pos) / dt
# print delta_pos, last_delta_pos
# print (D_lin * delta_delta_pos) / dtp
# print(delta_pos, last_delta_pos)
# print(D_lin * delta_delta_pos) / dtp)
force = PU.K_lin * delta_pos + PU.D_lin * delta_delta_pos

m_drot_prev = m_drot
Expand Down
2 changes: 1 addition & 1 deletion ambf_ros_modules/ambf_client/python/tests/rt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main():
start_time = rospy.get_time()
cur_time = start_time
end_time = cur_time + episode
print cur_time
print(cur_time)
while not rospy.is_shutdown() and cur_time <= end_time:

cur_time = rospy.get_time()
Expand Down
8 changes: 4 additions & 4 deletions ambf_ros_modules/ambf_client/python/tests/study_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def compute_number_of_clutches(topic_name, t_start=-1, t_end=-1):
return num_clutches, clutch_press_times


print (os.listdir('.'))
print(os.listdir('.'))
os.chdir('./user_study_data/')
print(os.listdir('.')[0])

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

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

# fig = plt.figure()
# ax = plt.axes(projection='3d')
Expand Down
4 changes: 2 additions & 2 deletions ambf_ros_modules/ambf_client/python/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

client = Client()
client.connect()
print client.get_obj_names()
print(client.get_obj_names())
obj = client.get_obj_handle(obj_name)

if obj:
Expand All @@ -63,5 +63,5 @@
time.sleep(0.01)

else:
print obj_name, 'not found'
print(obj_name, 'not found')

Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self):
def capture_window_times(self, time):
self.time_window_lims[0] = time + 1.0
self.time_window_lims[1] += self.time_window_lims[0]
print 'Capturing Time from {} to {}'.format(self.time_window_lims[0], self.time_window_lims[1])
print('Capturing Time from {} to {}'.format(self.time_window_lims[0], self.time_window_lims[1]))

def obj_state_cb(self, data):
if not self.done:
Expand All @@ -90,7 +90,7 @@ def obj_state_cb(self, data):
if self.first_run:
self.capture_window_times(ambf_wall_time)
self.initial_time_offset = rospy.Time.now().to_sec() - ambf_wall_time
print 'Adjusting Time Offset'
print('Adjusting Time Offset')
self.first_run = False
self.ambf_sim_time.append(ambf_sim_time)
self.ambf_wall_time.append(ambf_wall_time)
Expand All @@ -110,7 +110,7 @@ def run(self):
rospy.init_node('time_dilation_inspector')
sub = rospy.Subscriber('/ambf/env/World/State', WorldState, self.obj_state_cb, queue_size=10)

print 'X Axis = ', self.x_axis_dict[0][0]
print('X Axis = ', self.x_axis_dict[0][0])
x_axis_indx = self.x_axis_dict[0][1]

for i in range(1, self.x_axis_dict.__len__()):
Expand Down
4 changes: 2 additions & 2 deletions ambf_ros_modules/ambf_client/python/tests/user_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ def call(self):
date_time_str = str(datetime.now()).replace(' ', '_')
self._rosbag_filepath = './user_study_data/' + e1.get() + '_' + b1.get() + '_' + date_time_str
command = "rosbag record -O" + ' ' + self._rosbag_filepath + self._topic_names_str
print "Running Command", command
print("Running Command", command)
command = shlex.split(command)
self._rosbag_process = subprocess.Popen(command)
else:
print "Already recording a ROSBAG file, please save that first before starting a new record"
print("Already recording a ROSBAG file, please save that first before starting a new record")

def save(self):

Expand Down

0 comments on commit 45609c7

Please sign in to comment.