def __init__(self, sim, iktype=openravepy.IkParameterization.Type.Transform6D): Manipulator.__init__(self) self.simulated = sim self.iktype = iktype robot = self.GetRobot() env = robot.GetEnv() with env: dof_indices = self.GetIndices() accel_limits = robot.GetDOFAccelerationLimits() accel_limits[dof_indices[0:3]] = 1.2 accel_limits[dof_indices[3:6]] = 1.0 robot.SetDOFAccelerationLimits(accel_limits) # Load or_nlopt_ik as the IK solver. Unfortunately, IKFast doesn't work # on the Mico. if iktype is not None: self.iksolver = openravepy.RaveCreateIkSolver(env, 'NloptIK') self.SetIKSolver(self.iksolver) # Load simulation controllers. if sim: from prpy.simulation import ServoSimulator self.controller = robot.AttachController( self.GetName(), '', self.GetArmIndices(), 0, True) self.servo_simulator = ServoSimulator(self, rate=20, watchdog_timeout=0.1)
def __init__(self, sim, owd_namespace, iktype=openravepy.IkParameterization.Type.Transform6D): Manipulator.__init__(self) self.simulated = sim self._iktype = iktype if iktype is not None: self._SetupIK(iktype) # Enable servo motions in simulation mode. self.controller = self.GetRobot().AttachController(name=self.GetName(), args='OWDController {0:s} {1:s}'.format('prpy', owd_namespace), dof_indices=self.GetArmIndices(), affine_dofs=0, simulated=sim ) if sim: from prpy.simulation import ServoSimulator self.servo_simulator = ServoSimulator( self, rate=20, watchdog_timeout=0.1)
def __init__(self, name, buffers, clusters, representative_buffers=None, colors=None, vol_shape=None, representatives_line_width=5.0, streamlines_line_width=2.0, representatives_alpha=1.0, streamlines_alpha=1.0, affine=None, verbose=False, clustering_parameter=None, clustering_parameter_max=None, full_dissimilarity_matrix=None): """StreamlineLabeler is meant to explore and select subsets of the streamlines. The exploration occurs through clustering in order to simplify the scene. """ # super(StreamlineLabeler, self).__init__(name) Actor.__init__(self, name) # direct call of the __init__ seems better in case of multiple inheritance if affine is None: self.affine = np.eye(4, dtype = np.float32) else: self.affine = affine if vol_shape is not None: I, J, K = vol_shape centershift = img_to_ras_coords(np.array([[I/2., J/2., K/2.]]), affine) centeraffine = from_matvec(np.eye(3), centershift.squeeze()) affine[:3,3] = affine[:3, 3] - centeraffine[:3, 3] self.glaffine = (GLfloat * 16)(*tuple(affine.T.ravel())) self.glaff = affine self.mouse_x=None self.mouse_y=None self.buffers = buffers self.clusters = clusters self.save_init_set = True # MBKM: Manipulator.__init__(self, initial_clusters=clusters, clustering_function=mbkm_wrapper) # We keep the representative_ids as list to preserve order, # which is necessary for presentation purposes: self.representative_ids_ordered = sorted(self.clusters.keys()) self.representatives_alpha = representatives_alpha # representative buffers: if representative_buffers is None: representative_buffers = compute_buffers_representatives(buffers, self.representative_ids_ordered) self.representatives_buffer = representative_buffers['buffer'] self.representatives_colors = representative_buffers['colors'] self.representatives_first = representative_buffers['first'] self.representatives_count = representative_buffers['count'] self.representatives = buffer2coordinates(self.representatives_buffer, self.representatives_first, self.representatives_count) # full tractography buffers: self.streamlines_buffer = buffers['buffer'] self.streamlines_colors = buffers['colors'] self.streamlines_first = buffers['first'] self.streamlines_count = buffers['count'] print('MBytes %f' % (self.streamlines_buffer.nbytes/2.**20,)) self.hide_representatives = False self.expand = False self.knnreset = False self.representatives_line_width = representatives_line_width self.streamlines_line_width = streamlines_line_width self.vertices = self.streamlines_buffer # this is apparently requested by Actor self.color_storage = {} # This is the color of a selected representative. self.color_selected = np.array([1.0, 1.0, 1.0, 1.0], dtype='f4') # This are the visualized streamlines. # (Note: maybe a copy is not strictly necessary here) self.streamlines_visualized_first = self.streamlines_first.copy() self.streamlines_visualized_count = self.streamlines_count.copy() # Clustering: self.clustering_parameter = clustering_parameter self.clustering_parameter_max = clustering_parameter_max self.full_dissimilarity_matrix = full_dissimilarity_matrix self.cantroi = 0