How to use enable_devices method in lisa

Best Python code snippet using lisa_python

tracking.py

Source:tracking.py Github

copy

Full Screen

...8from dedect_markers import find_markers_all_cams, cluster_DBSCAN, cluster_KMEANS, calculate_center_3D9from visualise import visualise_marker101112def enable_devices():1314 # Constants for different camerastreams15 resolution_depth_width = 1280 # pixels16 resolution_depth_height = 720 # pixels17 depth_frame_rate = 30 # fps1819 resolution_color_width = 1280 # pixels20 resolution_color_height = 720 # pixels21 color_frame_rate = 30 # fps2223 try:24 # enable streams25 rs_config = rs.config()26 rs_config.enable_stream(rs.stream.depth, resolution_depth_width, resolution_depth_height, rs.format.z16,27 depth_frame_rate)28 rs_config.enable_stream(rs.stream.infrared, 1, resolution_depth_width, resolution_depth_height,29 rs.format.y8, depth_frame_rate)30 rs_config.enable_stream(rs.stream.color, resolution_color_width, resolution_color_height, rs.format.bgr8,31 color_frame_rate)3233 # Use the device manager class to enable the devices and get the frames34 device_manager = DeviceManager(rs.context(), rs_config)35 device_manager.enable_all_devices()36 device_manager.enable_emitter(True)3738 assert (len(device_manager._available_devices) > 0)3940 return device_manager4142 finally:43 device_manager.disable_streams()44454647def get_intrinsics(device_manager):48 frames = device_manager.poll_frames()49 device_intrinsics = device_manager.get_device_intrinsics(frames)50 return device_intrinsics51525354def track_markers(device_manager, device_transformation):55 #Speichern der Bewegungsvectoren des Markerpunktes (in Meter)56 movement_vectors = np.zeros(3)57 center_world = np.zeros(3)58 center_image = np.zeros(3)59 #pause zwischen Trackingframes 30 = 1sec60 frames_between_tracking = 561 #Richtige Konfig zum erkennen der Marker laden62 device_manager.load_settings_json('presets/preset_settings_marker_detection.json')63 devices_intrinsics = get_intrinsics(device_manager)6465 #Extrensics wird für darstellung benutzt66 frame = device_manager.poll_frames()67 devices_extrinsics = device_manager.get_depth_to_color_extrinsics(frame)6869 # Tracking i mal durchführen ; alternativ while True70 #for i in range(0,20):71 while True:72 frames = device_manager.poll_frames()73 markers_found, points_image, points_world = find_markers_all_cams(frames, devices_intrinsics, device_transformation)74 #marker wurde nicht gefunden75 if not (markers_found):76 print("Marker nicht identifiziert")77 print("erneuter Versuch")78 #i = i-179 else:80 oldcenter = center_world81 center_world = calculate_center_3D(points_world)82 center_image = calculate_center_3D(points_image)83 movement_world = center_world - oldcenter84 movement_vectors = np.vstack((movement_vectors, movement_world))85 print("Markermittelpunkt:")86 print(center_world)8788 visualise_marker(frames, points_image, center_image, devices_extrinsics)89 #"sleeping"6990 for f in range(frames_between_tracking):91 device_manager.poll_frames()9293 return movement_vectors94959697if __name__ == "__main__":9899 device_manager = enable_devices()100101 device_transformation = calibrate_all_devices(device_manager)102 print("Kalibrierung abgeschlossen")103 #save_calibration(device_transformation)104105 #device_transformation = load_calibration()106 #print("Kalibrierung aus Datei geladen")107108 #track_markers(device_manager,device_transformation)109 ...

Full Screen

Full Screen

waffrender.py

Source:waffrender.py Github

copy

Full Screen

...18 waffcycles.preferences.get_devices()19 print(device['name'])20 device['use'] = 121 print(' - Enabled!')22def enable_devices(try_nvidia, device_type):23 waffcycles = bpy.context.preferences.addons['cycles']24 waffcycles.preferences.get_devices()25 # find and maybe filter devices for optix/cuda26 nvidia_dev_found = False27 if try_nvidia:28 for device in waffcycles.preferences.get_devices_for_type(device_type):29 if 'NVIDIA' in device['name']:30 enable_device(device)31 nvidia_dev_found = True32 elif 'Tesla' in device['name']:33 enable_device(device)34 nvidia_dev_found = True35 36 if nvidia_dev_found:37 bpy.context.scene.cycles.device = "GPU"38 # no nvidia devices found39 if not try_nvidia or not nvidia_dev_found:40 print("")41 print("No nvidia devices found or requested, enable everything else.")42 for device in waffcycles.preferences.devices:43 device['use'] = 144 print(device['name'], " - Enabled!" if device['use'] else " - Disabled!" )45def list_cameras():46 return [cam for cam in bpy.data.objects if cam.type == 'CAMERA']47def set_cam(new_camera):48 bpy.context.scene.camera = bpy.data.objects[new_camera]49def main():50 #do things51 noargs = False52 53 argv = sys.argv54 try:55 argv = argv[argv.index('--') + 1:]56 except (ValueError):57 noargs = True58 parser = argparse.ArgumentParser(description="Set options on waffrender")59 parser.add_argument('-c', '--cam', action="store", type=str, default="", dest='cam_new_name')60 parser.add_argument('-n', '--no-accel', action='store_true', default=False, dest='no_accel')61 parser.add_argument('-l', '--list', action='store_true', default=False, dest='list_accel')62 args = parser.parse_args(argv)63 if args.list_accel:64 for dev in list_devices():65 print( dev['name'] )66 67 #if we want accel:68 if not args.no_accel:69 optix_on = set_comp_device('OPTIX')70 #optix_on = False71 if optix_on:72 print("Optix Enabled!")73 if not optix_on:74 cuda_on = set_comp_device('CUDA')75 if cuda_on:76 print("CUDA Enabled!")77 # if neither, we got no special devices.78 if optix_on:79 enable_devices(True, "OPTIX")80 elif cuda_on:81 enable_devices(True, "CUDA")82 else:83 enable_devices(False)84 else:85 print("No acceleration requested, using default devices")86 # if set camera87 cam_name=args.cam_new_name88 if cam_name != "":89 blend_cams = list_cameras()90 if cam_name in [cam.name for cam in blend_cams]:91 print("New camera %s found and set!" % cam_name)92 set_cam(cam_name)93 else:94 print("Camera %s not found, using default cam from file" % cam_name)95if __name__ == '__main__':...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

1from math import radians2from config import INITIAL_VELOCITY, DISTANCE_THRESHOLD, MAX_ROTATION_SPEED3def enable_devices(devices, timestep):4 for device in devices:5 device.enable(timestep)6def initialize_devices(devices, motors, timestep):7 enable_devices(devices, timestep)8 # Disable motor PID control mode.9 for motor in motors:10 motor.setPosition(float('inf'))11 motor.setVelocity(INITIAL_VELOCITY)12def get_distance_sensors(robot):13 return {f"ps{i}": robot.getDevice(f"ps{i}") for i in range(8)}14def get_motors(robot):15 return (16 robot.getDevice("left wheel motor"),17 robot.getDevice("right wheel motor")18 )19def get_sensors_values(sensors):20 return {21 name: device.getValue()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful