Skip to content

Commit 2d7c56b

Browse files
authored
Add Noetic and Python 3 support
Add support for ROS Noetic and Python 3 while still being backwards compatible. Tested ROS versions: Noetic (Python 3); Melodic & Kinetic (Pyhton 2). Closes Pull Request (#159)
1 parent 67f5b5f commit 2d7c56b

File tree

64 files changed

+225
-221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+225
-221
lines changed

intera_examples/CMakeLists.txt

+31
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,37 @@ catkin_package(
3636
intera_interface
3737
)
3838

39+
catkin_install_python(PROGRAMS
40+
scripts/ik_service_client.py
41+
scripts/go_to_joint_angles.py
42+
scripts/joint_position_waypoints.py
43+
scripts/joint_torque_springs.py
44+
scripts/gripper_cuff_control.py
45+
scripts/head_wobbler.py
46+
scripts/joint_recorder.py
47+
scripts/fk_service_client.py
48+
scripts/joint_velocity_wobbler.py
49+
scripts/navigator_io.py
50+
scripts/joint_position_joystick.py
51+
scripts/joint_position_keyboard.py
52+
scripts/gripper_keyboard.py
53+
scripts/stop_motion_trajectory.py
54+
scripts/go_to_joint_angles_in_contact.py
55+
scripts/joint_position_file_playback.py
56+
scripts/go_to_cartesian_pose.py
57+
scripts/head_display_image.py
58+
scripts/joint_trajectory_client.py
59+
scripts/joint_trajectory_file_playback.py
60+
scripts/set_interaction_options.py
61+
scripts/constrained_zeroG.py
62+
scripts/gripper_joystick.py
63+
scripts/lights_blink.py
64+
scripts/camera_display.py
65+
scripts/send_random_trajectory.py
66+
scripts/send_traj_from_file.py
67+
68+
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
69+
3970
install(
4071
DIRECTORY scripts/
4172
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}

intera_examples/cfg/SawyerJointSpringsExample.cfg

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

intera_examples/package.xml

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<package>
2+
<package format="3">
33
<name>intera_examples</name>
44
<version>5.3.0</version>
55
<description>
@@ -21,6 +21,8 @@
2121

2222
<buildtool_depend>catkin</buildtool_depend>
2323

24+
<buildtool_depend condition="$ROS_PYTHON_VERSION == 2">python-setuptools</buildtool_depend>
25+
<buildtool_depend condition="$ROS_PYTHON_VERSION == 3">python3-setuptools</buildtool_depend>
2426
<build_depend>rospy</build_depend>
2527
<build_depend>actionlib</build_depend>
2628
<build_depend>sensor_msgs</build_depend>
@@ -32,16 +34,16 @@
3234
<build_depend>intera_motion_msgs</build_depend>
3335
<build_depend>intera_interface</build_depend>
3436

35-
<run_depend>rospy</run_depend>
36-
<run_depend>actionlib</run_depend>
37-
<run_depend>sensor_msgs</run_depend>
38-
<run_depend>control_msgs</run_depend>
39-
<run_depend>trajectory_msgs</run_depend>
40-
<run_depend>cv_bridge</run_depend>
41-
<run_depend>dynamic_reconfigure</run_depend>
42-
<run_depend>intera_core_msgs</run_depend>
43-
<run_depend>intera_motion_msgs</run_depend>
44-
<run_depend>intera_interface</run_depend>
45-
<run_depend>joystick_drivers</run_depend>
37+
<exec_depend>rospy</exec_depend>
38+
<exec_depend>actionlib</exec_depend>
39+
<exec_depend>sensor_msgs</exec_depend>
40+
<exec_depend>control_msgs</exec_depend>
41+
<exec_depend>trajectory_msgs</exec_depend>
42+
<exec_depend>cv_bridge</exec_depend>
43+
<exec_depend>dynamic_reconfigure</exec_depend>
44+
<exec_depend>intera_core_msgs</exec_depend>
45+
<exec_depend>intera_motion_msgs</exec_depend>
46+
<exec_depend>intera_interface</exec_depend>
47+
<exec_depend>joystick_drivers</exec_depend>
4648

4749
</package>

intera_examples/scripts/camera_display.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,13 +22,14 @@
2322
import rospy
2423
import intera_interface
2524

26-
def show_image_callback(img_data, (edge_detection, window_name)):
25+
def show_image_callback(img_data, xxx_todo_changeme):
2726
"""The callback function to show image by using CvBridge and cv
2827
"""
28+
(edge_detection, window_name) = xxx_todo_changeme
2929
bridge = CvBridge()
3030
try:
3131
cv_image = bridge.imgmsg_to_cv2(img_data, "bgr8")
32-
except CvBridgeError, err:
32+
except CvBridgeError as err:
3333
rospy.logerr(err)
3434
return
3535
if edge_detection == True:

intera_examples/scripts/constrained_zeroG.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env python
2-
32
# Copyright (c) 2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

intera_examples/scripts/fk_service_client.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,7 +48,7 @@ def fk_service_client(limb = "right"):
4948
try:
5049
rospy.wait_for_service(ns, 5.0)
5150
resp = fksvc(fkreq)
52-
except (rospy.ServiceException, rospy.ROSException), e:
51+
except (rospy.ServiceException, rospy.ROSException) as e:
5352
rospy.logerr("Service call failed: %s" % (e,))
5453
return False
5554

intera_examples/scripts/go_to_cartesian_pose.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env python
2-
32
# Copyright (c) 2016-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

intera_examples/scripts/go_to_joint_angles.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env python
2-
32
# Copyright (c) 2016-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

intera_examples/scripts/go_to_joint_angles_in_contact.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env python
2-
32
# Copyright (c) 2016-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

intera_examples/scripts/gripper_cuff_control.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

intera_examples/scripts/gripper_joystick.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -61,17 +60,17 @@ def print_help(bindings_list):
6160
for (test, _cmd, doc) in bindings:
6261
if callable(doc):
6362
doc = doc()
64-
print("%s: %s" % (str(test[1]), doc))
63+
print(("%s: %s" % (str(test[1]), doc)))
6564

6665
def offset_position(offset_pos):
6766
cmd_pos = max(min(gripper.get_position() + offset_pos, gripper.MAX_POSITION), gripper.MIN_POSITION)
6867
gripper.set_position(cmd_pos)
69-
print("commanded position set to {0} m".format(cmd_pos))
68+
print(("commanded position set to {0} m".format(cmd_pos)))
7069

7170
def update_velocity(offset_vel):
7271
cmd_speed = max(min(gripper.get_cmd_velocity() + offset_vel, gripper.MAX_VELOCITY), gripper.MIN_VELOCITY)
7372
gripper.set_cmd_velocity(cmd_speed)
74-
print("commanded velocity set to {0} m/s".format(cmd_speed))
73+
print(("commanded velocity set to {0} m/s".format(cmd_speed)))
7574

7675

7776
# decrease position dead_zone

intera_examples/scripts/gripper_keyboard.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -47,12 +46,12 @@ def clean_shutdown():
4746
def offset_position(offset_pos):
4847
cmd_pos = max(min(gripper.get_position() + offset_pos, gripper.MAX_POSITION), gripper.MIN_POSITION)
4948
gripper.set_position(cmd_pos)
50-
print("commanded position set to {0} m".format(cmd_pos))
49+
print(("commanded position set to {0} m".format(cmd_pos)))
5150

5251
def update_velocity(offset_vel):
5352
cmd_speed = max(min(gripper.get_cmd_velocity() + offset_vel, gripper.MAX_VELOCITY), gripper.MIN_VELOCITY)
5453
gripper.set_cmd_velocity(cmd_speed)
55-
print("commanded velocity set to {0} m/s".format(cmd_speed))
54+
print(("commanded velocity set to {0} m/s".format(cmd_speed)))
5655

5756

5857
original_deadzone = gripper.get_dead_zone()
@@ -89,15 +88,15 @@ def update_velocity(offset_vel):
8988
done = True
9089
elif c in bindings:
9190
cmd = bindings[c]
92-
print("command: {0}".format(cmd[2]))
91+
print(("command: {0}".format(cmd[2])))
9392
cmd[0](*cmd[1])
9493
else:
9594
print("key bindings: ")
9695
print(" Esc: Quit")
9796
print(" ?: Help")
98-
for key, val in sorted(bindings.items(),
97+
for key, val in sorted(list(bindings.items()),
9998
key=lambda x: x[1][2]):
100-
print(" %s: %s" % (key, val[2]))
99+
print((" %s: %s" % (key, val[2])))
101100
# force shutdown call if caught by key handler
102101
rospy.signal_shutdown("Example finished.")
103102

intera_examples/scripts/head_display_image.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

intera_examples/scripts/head_wobbler.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

intera_examples/scripts/ik_service_client.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -90,7 +89,7 @@ def ik_service_client(limb = "right", use_advanced_options = False):
9089
try:
9190
rospy.wait_for_service(ns, 5.0)
9291
resp = iksvc(ikreq)
93-
except (rospy.ServiceException, rospy.ROSException), e:
92+
except (rospy.ServiceException, rospy.ROSException) as e:
9493
rospy.logerr("Service call failed: %s" % (e,))
9594
return False
9695

@@ -104,7 +103,7 @@ def ik_service_client(limb = "right", use_advanced_options = False):
104103
rospy.loginfo("SUCCESS - Valid Joint Solution Found from Seed Type: %s" %
105104
(seed_str,))
106105
# Format solution into Limb API-compatible dictionary
107-
limb_joints = dict(zip(resp.joints[0].name, resp.joints[0].position))
106+
limb_joints = dict(list(zip(resp.joints[0].name, resp.joints[0].position)))
108107
rospy.loginfo("\nIK Joint Solution:\n%s", limb_joints)
109108
rospy.loginfo("------------------")
110109
rospy.loginfo("Response Message:\n%s", resp)

intera_examples/scripts/joint_position_file_playback.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,12 +39,12 @@ def clean_line(line, names):
4039
#convert the line of strings to a float or None
4140
line = [try_float(x) for x in line.rstrip().split(',')]
4241
#zip the values with the joint names
43-
combined = zip(names[1:], line[1:])
42+
combined = list(zip(names[1:], line[1:]))
4443
#take out any tuples that have a none value
4544
cleaned = [x for x in combined if x[1] is not None]
4645
#convert it to a dictionary with only valid commands
4746
command = dict(cleaned)
48-
right_command = dict((key, command[key]) for key in command.keys()
47+
right_command = dict((key, command[key]) for key in list(command.keys())
4948
if key[:-2] == 'right_')
5049
return (command, right_command, line)
5150

@@ -64,10 +63,10 @@ def map_file(filename, limb, loops=1):
6463
first column is the time stamp
6564
"""
6665
limb_interface = intera_interface.Limb(limb)
67-
has_gripper = True
66+
has_gripper = False
6867
try:
6968
gripper = intera_interface.Gripper(limb + '_gripper')
70-
except ValueError:
69+
except:
7170
has_gripper = False
7271
rospy.loginfo("Could not detect a gripper attached to the robot")
7372

@@ -78,7 +77,7 @@ def map_file(filename, limb, loops=1):
7877
if not gripper.is_calibrated():
7978
gripper.calibrate()
8079

81-
print("Playing back: %s" % (filename,))
80+
print(("Playing back: %s" % (filename,)))
8281
with open(filename, 'r') as f:
8382
lines = f.readlines()
8483
keys = lines[0].rstrip().split(',')
@@ -109,7 +108,7 @@ def map_file(filename, limb, loops=1):
109108
if has_gripper and gripper.name in cmd:
110109
gripper.set_position(cmd[gripper.name])
111110
rate.sleep()
112-
print
111+
print()
113112
return True
114113

115114
def main():

intera_examples/scripts/joint_position_joystick.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -92,7 +91,7 @@ def print_help(bindings_list):
9291
for (test, _cmd, doc) in bindings:
9392
if callable(doc):
9493
doc = doc()
95-
print("%s: %s" % (str(test[1][0]), doc))
94+
print(("%s: %s" % (str(test[1][0]), doc)))
9695

9796
bindings_list = []
9897
bindings = [
@@ -132,7 +131,7 @@ def print_help(bindings_list):
132131
if test[0](*test[1]):
133132
cmd[0](*cmd[1])
134133
if callable(doc):
135-
print(doc())
134+
print((doc()))
136135
else:
137136
print(doc)
138137
if len(limb_cmd):

intera_examples/scripts/joint_position_keyboard.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -89,18 +88,18 @@ def set_g(action):
8988
cmd = bindings[c]
9089
if c == '8' or c == 'i' or c == '9':
9190
cmd[0](cmd[1])
92-
print("command: %s" % (cmd[2],))
91+
print(("command: %s" % (cmd[2],)))
9392
else:
9493
#expand binding to something like "set_j(right, 'j0', 0.1)"
9594
cmd[0](*cmd[1])
96-
print("command: %s" % (cmd[2],))
95+
print(("command: %s" % (cmd[2],)))
9796
else:
9897
print("key bindings: ")
9998
print(" Esc: Quit")
10099
print(" ?: Help")
101-
for key, val in sorted(bindings.items(),
100+
for key, val in sorted(list(bindings.items()),
102101
key=lambda x: x[1][2]):
103-
print(" %s: %s" % (key, val[2]))
102+
print((" %s: %s" % (key, val[2])))
104103

105104
def main():
106105
"""RSDK Joint Position Example: Keyboard Control

intera_examples/scripts/joint_position_waypoints.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -116,7 +115,7 @@ def playback(self):
116115
loop = 0
117116
while not rospy.is_shutdown():
118117
loop += 1
119-
print("Waypoint playback loop #%d " % (loop,))
118+
print(("Waypoint playback loop #%d " % (loop,)))
120119
for waypoint in self._waypoints:
121120
if rospy.is_shutdown():
122121
break

intera_examples/scripts/joint_recorder.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python
2-
1+
#! /usr/bin/env python
32
# Copyright (c) 2013-2018, Rethink Robotics Inc.
43
#
54
# Licensed under the Apache License, Version 2.0 (the "License");

0 commit comments

Comments
 (0)