 # RoboQualityController Main controller of the Robo Quality project. This should controll all the services via the clients of the sumodules. Also all common conversions from ROS2 interfaces to Python and Disk are included. # Example: Workflow In this example all service nodes are started as `echo´s` (dummies). The workflow class connects to the standard services and calls them. The main idea is to replaces the service calls with "real" implemenataions / functionalities but keep the client calls for the workflow the same to keep testing and integrating easy independet of the systems. ## Start Service nodes Start the service nodes in a first console. ```powershell C:\dev\ros2_humble\setup.ps1 C:\dev\rq_workflow\install\setup.ps1 ros2 launch C:\dev\rq_workflow\launch\echo_launch.py ``` ## Run script The following script can be found [here](https://mygit.th-deg.de/roboct/robo_quality/rq_controller/-/blob/main/rq_controller/rq_workflow.py?ref_type=heads#L80). Source ROS 2 in a second console: ```powershell C:\dev\ros2_humble\setup.ps1 C:\dev\rq_workflow\install\setup.ps1 ``` Run script / file from the second console: ```python # Initialize workflow from rq_controller.rq_workflow import WorkflowNode workflow = WorkflowNode() # Aquire some scout views projection_list = list() for i in range(5): print(f' - At projection {i}') scan_pose = PyProjection.dummy() scan_pose.focal_spot_mm += i projection_list.append(workflow.aquire_projection(scan_pose)) # Detect errors in scout views roi = workflow.defect_detection(projection_list) # Init traj opt workflow.trajectory_initialize(roi) # Get next scan pose from traj opt next_scan_pose, finished = workflow.trajectory_update(projection_list[-1]) # Aquire scan pose projection_list.append(workflow.aquire_projection(next_scan_pose)) # Resconstruct projections volume = workflow.get_volume(projection_list, roi[0]) ``` # Example: Reconstruction All individual nodes can be used alone and must not be used as the workflow is intended. In the following example the service node are started in the following configuration: | Service Node | Mode | | --- | --- | | `rq_reonstruction` | tigre_service | | `rq_hardware` | artist_service | | `rq_trajectory` | echo_service | | `rq_ddetection` | echo_service | Therefore the following launch script is used: ```powershell C:\dev\ros2_humble\setup.ps1 C:\dev\rq_workflow\install\setup.ps1 ros2 launch C:\dev\rq_workflow\launch\tigre_artist_launch.py ``` With the following minimal [script](https://mygit.th-deg.de/roboct/robo_quality/rq_controller/-/blob/main/example/tigre_example.py?ref_type=heads#L19) projcetion get simulated and reconstructed: ```python from rq_controller.rq_workflow import WorkflowNode workflow = WorkflowNode() projection_stack = list() projection = PyProjection.dummy() projection.voltage_kv = 200. projection.current_ua = 10. projection.detector_heigth_mm = 200. projection.detector_width_mm = 200. source = np.array([FOD_MM, 0, 0]) detector = np.array([FOD_MM - FDD_MM, 0, 0]) angles = np.linspace(-np.pi, np.pi, NUMBER_OF_PROJECTION, endpoint=False) for i in range(NUMBER_OF_PROJECTION): rotation = Rotation.from_euler('Z', angles[i], False) scan_pose = projection.look_at(rotation.apply(source), rotation.apply(detector), np.array([0, 0, -1])) projection_stack.append(workflow.aquire_projection(scan_pose)) roi = PyRegionOfIntrest(np.zeros((1, 3)), np.ones((1, 3)) * 120., resolution_mm=np.array([0.2, 0.2, 0.2])) volume = workflow.get_volume(projection_stack, roi) ```