def on_change(self): super(Logger, self).on_change() if self._changed_observables: motive_tt = motive.frame_time_stamp() tt = time.clock() for obs in self._changed_observables: line = {} line['MotiveTime'] = motive_tt line['Time'] = tt line['Name'] = obs.name line['Class'] = obs.__class__.__name__ line['Visible'] = obs.visible line['x'], line['y'], line['z'] = obs.position.xyz rot_euler = obs.rotation.to_euler(units='rad') line['rot_x'], line['rot_y'], line['rot_z'] = rot_euler.xyz rot_quat = obs.rotation.to_quaternion() line['quat_w'], line['quat_x'], line['quat_y'], line[ 'quat_z'] = rot_quat.wxyz line['glob_x'], line['glob_y'], line[ 'glob_z'] = obs.position_global line['ori_x'], line['ori_y'], line['ori_z'] = obs.orientation line['glob_ori_x'], line['glob_ori_y'], line[ 'glob_ori_z'] = obs.orientation_global self.writer.writerow(line)
def ray_scan(window): circle = window.active_scene.meshes[0] circle.visible = True # Do some non-random points to so human can change height range. pointPos, screenPos = [], [] for pos in [(0, 0), (-.5, 0), (.5, 0)]: circle.x, circle.y = pos window.draw() window.flip() for _ in timers.countdown_timer(5, stop_iteration=True): motive.update() markers = motive.get_unident_markers() old_time = motive.frame_time_stamp() if motive.frame_time_stamp() > old_time + .3 and len(markers) == 1: if markers[0][1] > 0.1: screenPos.append(circle.position[:2]) pointPos.append(markers[0]) old_time = motive.frame_time_stamp() return screenPos, pointPos
def scan(pointwidth=.06): """Project a series of points onto the arena, collect their 3d position, and save them and the associated rigid body data into a pickled file.""" # Initialize Calibration Point Grid. wavefront_reader = rc.WavefrontReader(rc.resources.obj_primitives) mesh = wavefront_reader.get_mesh('Grid', scale=1.5, drawstyle='point', point_size=12, position=(0,0,-1)) # mesh.material.diffuse.rgb = 1, 1, 1 scene = rc.Scene([mesh], bgColor=(0,0,0)) scene.camera.ortho_mode = True window = visual.Window(screen=1, fullscr=True) # Main Loop old_frame, clock, points = motive.frame_time_stamp(), utils.timers.countdown_timer(3.), [] for theta in np.linspace(0, 2*np.pi, 40)[:-1]: # Update Screen scene.camera.position = (pointwidth * np.sin(theta)), (pointwidth * np.cos(theta)), -1 scene.draw() window.flip() # Collect New Tracker Data old_frame = motive.frame_time_stamp() while motive.frame_time_stamp() == old_frame: motive.flush_camera_queues() motive.update() # Collect 3D points from Tracker markers = motive.get_unident_markers() if markers: points.extend(markers) # Housekeeping window.close() # Data quality checks and return. return np.array(points)