Skip to content

Commit dddb165

Browse files
author
Yuxiang Gao
committed
Readme and comments
1 parent e72371f commit dddb165

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# PATI
2+
## Introduction
3+
This is the repository accompanying the paper *PATI: A Projection-Based Augmented Table-Top Interface for Robot Programming*. In this work, we present PATI—a Projection-based Augmented Table-top Interface for robot programming—through which users are able to use sim- ple, common gestures (e.g., pinch gestures) and tools (e.g., shape tools) to specify table-top manipulation tasks (such as pick-and-place) for a robot manipulator. PATI allows users to interact with the environment directly when providing task specifications.
4+
5+
## Usage
6+
`roslaunch ropi_tangible_surface all_in_one.launch`
7+
`rosrun ropi_tangible_surface tangible_surface.py`
8+
9+
## Structure
10+
- ropi_msgs: ROS messages, services and actions
11+
- ropi_tangible_surface: main package
12+
- ropi_tangible_surface: python package for backend processing
13+
- base_class.py: base class of all detection and tracking clsses.
14+
- finger_detection.py: detect fingertip positions
15+
- fingertip_tracking.py: filter and track detections
16+
- object_detection.py: detect tabletop objects
17+
- object_tracking.py: filter and track object detections
18+
- tangible_surface.py: main script

ropi_tangible_surface/scripts/ropi_tangible_surface/fingertip_tracking.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def next_valid(self, id):
4949
class TouchTracker(TrackerBase):
5050
def __init__(self, pt, id=None):
5151
super(TouchTracker, self).__init__()
52-
# self.id = id
5352
self.position = pt
5453
self.position_prev = pt
5554
self.last_time = 0
@@ -60,6 +59,7 @@ def __init__(self, pt, id=None):
6059
self.smoothing_factor = 0
6160

6261
def elapsed_time(self):
62+
'''Calculate elapsed time'''
6363
if self.last_time != 0:
6464
elapsed = rospy.get_time() - self.time
6565
# self.last_time = rospy.get_time()
@@ -68,6 +68,8 @@ def elapsed_time(self):
6868
return 0
6969

7070
def update(self, pos):
71+
'''Make an update
72+
input: fingertip position'''
7173
if pos is not None:
7274
# clear release cnt
7375
self.release_cnt = 0
@@ -121,6 +123,8 @@ def __init__(self, screen_shape):
121123

122124

123125
def update(self, pts):
126+
'''Make an update
127+
input: list of fingertip positions'''
124128
if DEBUG: print('update', pts)
125129
if len(self.trackers) == 0:
126130
self.new_trackers(pts)
@@ -129,13 +133,15 @@ def update(self, pts):
129133
# print(self.trackers)
130134

131135
def new_trackers(self, pts):
136+
'''init new tracker'''
132137
for pt in pts:
133138
if not ma.is_masked(pt):
134139
new_cursor = TouchTracker(pt)
135140
self.trackers.append(new_cursor)
136141
if DEBUG: print('add pt', new_cursor.id.hex)
137142

138143
def match_trackers(self, pts):
144+
'''search and match existing points with incoming points'''
139145
# when only one finger, allow more tolerence
140146
if len(pts) == 1:
141147
move_threshold = 65
@@ -169,12 +175,13 @@ def match_trackers(self, pts):
169175
self.release_tracker(cur)
170176

171177
def release_tracker(self, cur):
178+
'''call release tracker service '''
172179
try:
173180
print('---------Cursor release-----------')
174181
self.delete_cursor = rospy.ServiceProxy('delete_cursor', DeleteSelection)
175182
self.delete_cursor(cur.id.hex)
176-
except rospy.ServiceException, e:
177-
print "Service call failed: %s"%e
183+
except rospy.ServiceException as e:
184+
print("Service call failed: %s"%e)
178185
cur.state = CursorState['RELEASED']
179186
self.trackers.remove(cur)
180187
# if self.id_manager.release_id(cur.id):
@@ -183,6 +190,7 @@ def release_tracker(self, cur):
183190
# if DEBUG: print('Cursor id release unsuccessful!!')
184191

185192
def make_msg(self):
193+
'''compile ros msg for communication'''
186194
msg = MultiTouch()
187195
msg.width = self.width
188196
msg.height = self.height

ropi_tangible_surface/scripts/ropi_tangible_surface/object_detection.py

+14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from geometry_msgs.msg import Point
1010

1111
class GraspDataClass:
12+
'''container class for objects' information'''
1213
def __init__(self, position, diameter, angle, height):
1314
self.position = np.asarray(position)
1415
self.target_position = None
@@ -62,6 +63,11 @@ def set_debug_img(self, img):
6263
self.debug_img = img
6364

6465
def update(self, cnts, depth_img, debug_img=None):
66+
'''update objects
67+
input:
68+
cnts: list of contours
69+
depth_img: depth image for detection
70+
debug_img(optional): rgb img for visualization'''
6571
self.init()
6672
output = []
6773
if self.debug and debug_img is None:
@@ -94,6 +100,7 @@ def draw_selections(self, img, rects):
94100
return debug_img
95101

96102
class ObjectDetection:
103+
'''object detection class'''
97104
def __init__(self, debug=True):
98105
self.clear()
99106
self.debug = debug
@@ -124,6 +131,13 @@ def clear(self):
124131
self.debug_img = None
125132

126133
def update(self, cnt, depth_img, debug_img=None):
134+
'''
135+
make update
136+
inputs:
137+
cnt: contour of object
138+
depth_img: depth image for detection
139+
debug_img(optional): rgb img for visualization
140+
'''
127141
self.clear()
128142
if self.debug and debug_img is None:
129143
self.set_debug_img(depth_img)

ropi_tangible_surface/scripts/tangible_surface.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def load_data(self):
4848
self.depth_background = np.load(self.root_path + '/config/depth.npy')
4949

5050
def on_init(self):
51+
'''init all modules'''
5152
rospy.loginfo("on init")
5253
# Instances
5354
self.bridge = CvBridge()
@@ -96,7 +97,7 @@ def detect_objects_in_region(self, msg):
9697
return grasp_points
9798

9899
def move_objects_callback(self, req):
99-
# TODO: finish this
100+
'''callback from move object request'''
100101
rospy.loginfo("move objects service called.")
101102
response = MoveObjectsResponse()
102103
if not self.is_moving:
@@ -135,6 +136,7 @@ def place_position(self, pick_pos, source, target):
135136
return target.normalized_rect.get_center() + relative_pos
136137

137138
def mission_from_regions(self, source_region, target_region):
139+
'''generate mission from source and target regions'''
138140
print('Source: ', source_region)
139141
print('Target: ', target_region)
140142
grasp_points = self.detect_objects_in_region(source_region)
@@ -155,6 +157,7 @@ def mission_from_regions(self, source_region, target_region):
155157
return None
156158

157159
def delete_selection_callback(self, req):
160+
'''callback function to delete a selection service'''
158161
rospy.loginfo("Delete selection service called.")
159162
print (self.selection_manager.selections)
160163
self.selection_manager.delete([req.guid])
@@ -186,6 +189,7 @@ def region_selection_callback(self, req):
186189
return response
187190

188191
def image_callback(self, depth_in, rgb_in):
192+
'''image preprocessing'''
189193
cv_rgb = self.rgb_callback(rgb_in)
190194
cv_depth = self.depth_callback(depth_in)
191195
depth_foreground = self.depth_background - cv_depth
@@ -270,6 +274,7 @@ def make_mask(self, pts, shape):
270274
return mask
271275

272276
def detect_fingertip(self, img):
277+
'''finger tip detection and tracking pipeline'''
273278
threshed = my_threshold(img, 0, 500)
274279
mask = np.zeros(img.shape, dtype=np.uint8)
275280
mask[threshed > 0] = 255
@@ -308,6 +313,7 @@ def detect_fingertip(self, img):
308313
return p
309314

310315
def detect_object(self, img):
316+
'''object detection and tracking pipeline'''
311317
objects = []
312318
threshed = my_threshold(img, 5, 150)
313319
mask = np.zeros(img.shape, dtype=np.uint8)

ur5_gripper_control/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# ur3_gripper85
1+
# ur5_gripper145

0 commit comments

Comments
 (0)