|
7 | 7 |
|
8 | 8 | import compas |
9 | 9 | from compas.datastructures import Mesh |
10 | | -from compas.geometry import Frame |
11 | 10 | from compas.geometry import Transformation |
12 | 11 | from compas_ghpython.geometry import xform_from_transformation |
13 | 12 | from compas_rhino.helpers import mesh_from_guid |
14 | 13 |
|
15 | | -from compas_fab.backends.vrep.coordinator import SimulationCoordinator |
16 | 14 | from compas_fab.robots import Configuration |
17 | 15 |
|
18 | 16 | try: |
19 | 17 | import clr |
20 | | - import ghpythonlib.components as ghcomp |
21 | 18 | import rhinoscriptsyntax as rs |
22 | 19 | from Rhino.Geometry import Transform |
23 | 20 | from Rhino.Geometry import Mesh as RhinoMesh |
@@ -190,81 +187,6 @@ def _get_building_member_info(self, gripping_config): |
190 | 187 | 'relative_transform': relative_transform} |
191 | 188 |
|
192 | 189 |
|
193 | | -class PathPlanner(object): |
194 | | - """Provides a simple/compact API to call the path planner from Grasshopper.""" |
195 | | - |
196 | | - @classmethod |
197 | | - def find_path(cls, host='127.0.0.1', port=19997, mode='local', **kwargs): |
198 | | - """Finds a path for the specified scene description. There is a large number |
199 | | - of parameters that can be passed as `kwargs`. It can run in two modes: *remote* or |
200 | | - *local*. In remote mode, the `host` and `port` parameters correspond to a |
201 | | - simulation coordinator, and in local mode, `host` and `port` correspond to |
202 | | - a V-REP instance. |
203 | | -
|
204 | | - Args: |
205 | | - host (:obj:`str`): IP address of the service (simulation coordinator in `remote`, V-REP in `local` mode) |
206 | | - port (:obj:`int`): Port of the service. |
207 | | - mode (:obj:`str`): Execution mode, either ``local`` or ``remote``. |
208 | | - kwargs: Keyword arguments. |
209 | | -
|
210 | | - Returns: |
211 | | - list: list of configurations representing a path. |
212 | | - """ |
213 | | - parser = InputParameterParser() |
214 | | - options = {'robots': []} |
215 | | - active_robot = None |
216 | | - |
217 | | - if 'robots' in kwargs: |
218 | | - for i, settings in enumerate(kwargs['robots']): |
219 | | - if 'robot' not in settings: |
220 | | - raise KeyError("'robot' not found at kwargs['robots'][%d]" % i) |
221 | | - |
222 | | - robot = {'robot': settings['robot']} |
223 | | - |
224 | | - if 'start' in settings: |
225 | | - start = parser.get_config_or_pose(settings['start']) |
226 | | - if start: |
227 | | - robot['start'] = start.to_data() |
228 | | - |
229 | | - if 'goal' in settings: |
230 | | - if not active_robot: |
231 | | - active_robot = robot |
232 | | - goal = parser.get_config_or_pose(settings['goal']) |
233 | | - if goal: |
234 | | - robot['goal'] = goal.to_data() |
235 | | - else: |
236 | | - raise ValueError('Multi-move is not (yet) supported. Only one goal can be specified.') |
237 | | - |
238 | | - if 'building_member' in settings: |
239 | | - robot['building_member'] = mesh_from_guid(Mesh, settings['building_member']).to_data() |
240 | | - |
241 | | - if 'metric_values' in settings: |
242 | | - robot['metric_values'] = map(float, settings['metric_values'].split(',')) |
243 | | - |
244 | | - if 'joint_limits' in settings: |
245 | | - robot['joint_limits'] = settings['joint_limits'] |
246 | | - |
247 | | - options['robots'].append(robot) |
248 | | - |
249 | | - if 'collision_meshes' in kwargs: |
250 | | - mesh_guids = parser.compact_list(kwargs['collision_meshes']) |
251 | | - options['collision_meshes'] = [mesh_from_guid(Mesh, m).to_data() for m in mesh_guids] |
252 | | - |
253 | | - options['debug'] = kwargs.get('debug') |
254 | | - options['trials'] = kwargs.get('trials') |
255 | | - options['shallow_state_search'] = kwargs.get('shallow_state_search') |
256 | | - options['optimize_path_length'] = kwargs.get('optimize_path_length') |
257 | | - options['planner_id'] = kwargs.get('planner_id') |
258 | | - options['resolution'] = kwargs.get('resolution') |
259 | | - |
260 | | - if mode == 'remote': |
261 | | - LOG.debug('Running remote path planner executor. Host=%s:%d', host, port) |
262 | | - return SimulationCoordinator.remote_executor(options, host, port) |
263 | | - else: |
264 | | - LOG.debug('Running local path planner executor. Host=%s:%d', host, port) |
265 | | - return SimulationCoordinator.local_executor(options, host, port) |
266 | | - |
267 | | - |
268 | 190 | class InputParameterParser(object): |
269 | 191 | """Simplifies some tasks related to parsing Grasshopper input parameters |
270 | 192 | for path planning.""" |
|
0 commit comments