Skip to content

Commit 4708328

Browse files
committed
Merge branch 'block_sorting' of https://github.com/personalrobotics/prpy into block_sorting
2 parents 4d9371f + 44e4d73 commit 4708328

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

src/prpy/perception/apriltags.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,17 @@ def __init__(self, marker_topic, marker_data_path, kinbody_path,
5858

5959

6060
def __str__(self):
61-
return 'Apriltags'
61+
return self.__class__.__name__
6262

6363
def DetectObjects(self, env, object_names, **kw_args):
6464
"""
6565
This hack detects only the objects in object_names. Updates existing
6666
objects, but only adds objects in the object_names list.
67+
68+
@param env: The current OpenRAVE environment
69+
@param object_names: The list of names of objects to detect
6770
"""
68-
added_kinbodies, updated_kinbodies = self.DetectObjects(robot, **kw_args);
71+
added_kinbodies, updated_kinbodies = self._DetectObjects(env, **kw_args);
6972
detected = [];
7073
for body in added_kinbodies:
7174
if not (body.GetName() in object_names):
@@ -81,37 +84,38 @@ def DetectObject(self, env, object_name, **kw_args):
8184
return (self._DetectObjects( env, object_names=[object_name], **kw_args))[0][0];
8285

8386

84-
def _DetectObjects(self, env, **kw_args):
87+
def _DetectObjects(self, env, marker_topic, marker_data_path, kinbody_path,
88+
detection_frame, destination_frame,**kw_args):
8589
"""
8690
Use the apriltags service to detect objects and add them to the
87-
environment
91+
environment. Params are as in __init__.
92+
93+
@param env: The current OpenRAVE environment
94+
@param marker_topic The ROS topic to read markers from. Typically the output topic for April Tags
95+
@param marker_data_path The json file where the association between tag and object is stored
96+
@param kinbody_path The path to the folder where kinbodies are stored
97+
@param detection_frame The TF frame of the camera
98+
@param destination_frame The desired world TF frame
99+
100+
@return The list of kinbodies associated with the detected apriltags
88101
"""
89102
try:
90103
# Allow caller to override any of the initial parameters
91104
# loaded into the module
92-
if 'marker_data_path' in kw_args:
93-
marker_data_path = kw_args['marker_data_path']
94-
else:
95-
marker_data_path = self.marker_data_path
105+
if marker_topic is None:
106+
marker_topic = self.marker_topic
96107

97-
if 'kinbody_path' in kw_args:
98-
kinbody_path = kw_args['kinbody_path']
99-
else:
108+
if marker_data_path is None:
109+
marker_data_path = self.marker_data_path
110+
111+
if kinbody_path is None:
100112
kinbody_path = self.kinbody_path
101-
102-
if 'marker_topic' in kw_args:
103-
marker_topic = kw_args['marker_topic']
104-
else:
105-
marker_topic = self.marker_topic
113+
106114

107-
if 'detection_frame' in kw_args:
108-
detection_frame = kw_args['detection_frame']
109-
else:
115+
if detection_frame is None:
110116
detection_frame = self.detection_frame
111117

112-
if 'destination_frame' in kw_args:
113-
destination_frame = kw_args['destination_frame']
114-
else:
118+
if destination_frame is None:
115119
destination_frame = self.destination_frame
116120

117121
# TODO: Creating detector is not instant...might want

src/prpy/perception/block_detector.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def find_blocks(self,service_name="tools_server/find_blocks",
6363
@param segment_box: flag to discard points outside of (box_min, box_max)
6464
@param box_min: minimum coordinsates of search area in camera frame
6565
@param box_max: maximum coordinsates of search area in camera frame
66+
67+
@return list of blocks found, if any
6668
"""
6769

6870
logging.info("waiting for service...")
@@ -89,7 +91,13 @@ def find_blocks(self,service_name="tools_server/find_blocks",
8991
@PerceptionMethod
9092
def DetectBlocks(self, robot, table, blocks=None,timeout=10, **kw_args):
9193
"""
92-
Place blocks on the table
94+
Calls detector for blocks and places them on the table
95+
96+
@param robot: The robot instance using the detector
97+
@param table: The kinbody for the table on which the blocks are placed
98+
@blocks: List of blocks currently in the environment; if present, redetection not done
99+
100+
@return The list of blocks detected
93101
"""
94102
if blocks is not None and len(blocks) == 0:
95103
# Add all blocks

0 commit comments

Comments
 (0)