|
| 1 | +# SPDX-FileCopyrightText: Alliander N. V. |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +from launch import LaunchContext, LaunchDescription |
| 6 | +from launch.actions import OpaqueFunction |
| 7 | +from launch_ros.actions import Node |
| 8 | +from rcdt_utilities.launch_utils import LaunchArgument |
| 9 | +from rcdt_utilities.register import Register |
| 10 | + |
| 11 | +namespace_arm_arg = LaunchArgument("namespace_arm", "") |
| 12 | +namespace_camera_arg = LaunchArgument("namespace_camera", "") |
| 13 | + |
| 14 | + |
| 15 | +def launch_setup(context: LaunchContext) -> list: |
| 16 | + """Setup the launch description for the grasping node. |
| 17 | +
|
| 18 | + Args: |
| 19 | + context (LaunchContext): The launch context. |
| 20 | +
|
| 21 | + Returns: |
| 22 | + list: A list of actions to be executed in the launch description. |
| 23 | + """ |
| 24 | + namespace_arm = namespace_arm_arg.string_value(context) |
| 25 | + namespace_camera = namespace_camera_arg.string_value(context) |
| 26 | + |
| 27 | + graspnet_node = Node( |
| 28 | + package="rcdt_grasping", |
| 29 | + executable="generate_grasp.py", |
| 30 | + ) |
| 31 | + |
| 32 | + grasping_logic = Node( |
| 33 | + package="rcdt_grasping", |
| 34 | + executable="grasp_logic.py", |
| 35 | + parameters=[ |
| 36 | + {"namespace_arm": namespace_arm, "namespace_camera": namespace_camera} |
| 37 | + ], |
| 38 | + ) |
| 39 | + |
| 40 | + return [ |
| 41 | + Register.on_log( |
| 42 | + graspnet_node, "GraspNet model initialized and weights loaded", context |
| 43 | + ), |
| 44 | + Register.on_log(grasping_logic, "GraspLogicNode initialized!", context), |
| 45 | + ] |
| 46 | + |
| 47 | + |
| 48 | +def generate_launch_description() -> LaunchDescription: |
| 49 | + """Generate the launch description for the grasping node. |
| 50 | +
|
| 51 | + Returns: |
| 52 | + LaunchDescription: The launch description containing the grasping node. |
| 53 | + """ |
| 54 | + return LaunchDescription( |
| 55 | + [ |
| 56 | + namespace_arm_arg.declaration, |
| 57 | + namespace_camera_arg.declaration, |
| 58 | + OpaqueFunction(function=launch_setup), |
| 59 | + ] |
| 60 | + ) |
0 commit comments