|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# |
| 3 | +# Copyright (c) 2025, United States Government, as represented by the |
| 4 | +# Administrator of the National Aeronautics and Space Administration. |
| 5 | +# |
| 6 | +# All rights reserved. |
| 7 | +# |
| 8 | +# This software is licensed under the Apache License, Version 2.0 |
| 9 | +# (the "License"); you may not use this file except in compliance with the |
| 10 | +# License. You may obtain a copy of the License at |
| 11 | +# |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | +# |
| 14 | +# Unless required by applicable law or agreed to in writing, software |
| 15 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | +# License for the specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | + |
| 20 | +from launch import LaunchDescription |
| 21 | +from launch.actions import DeclareLaunchArgument |
| 22 | +from launch.substitutions import LaunchConfiguration |
| 23 | +from launch_ros.actions import Node |
| 24 | + |
| 25 | + |
| 26 | +def generate_launch_description(): |
| 27 | + |
| 28 | + # Declare arguments |
| 29 | + declared_arguments = [] |
| 30 | + declared_arguments.append( |
| 31 | + DeclareLaunchArgument( |
| 32 | + "namespace", |
| 33 | + default_value="", |
| 34 | + description="Namespace for the robot.", |
| 35 | + ) |
| 36 | + ) |
| 37 | + declared_arguments.append( |
| 38 | + DeclareLaunchArgument( |
| 39 | + "headless_mode", |
| 40 | + default_value="true", |
| 41 | + description="Enable headless mode for robot control", |
| 42 | + ) |
| 43 | + ) |
| 44 | + declared_arguments.append( |
| 45 | + DeclareLaunchArgument( |
| 46 | + "robot_ip", |
| 47 | + default_value="192.168.1.102", |
| 48 | + description="IP address by which the robot can be reached.", |
| 49 | + ) |
| 50 | + ) |
| 51 | + declared_arguments.append( |
| 52 | + DeclareLaunchArgument( |
| 53 | + "hande_dev_name", |
| 54 | + default_value="/tmp/ttyUR", |
| 55 | + description="File descriptor that will be generated for the tool communication device. " |
| 56 | + "The user has be be allowed to write to this location. ", |
| 57 | + ) |
| 58 | + ) |
| 59 | + declared_arguments.append( |
| 60 | + DeclareLaunchArgument( |
| 61 | + "tool_tcp_port", |
| 62 | + default_value="54321", |
| 63 | + description="Remote port that will be used for bridging the tool's serial device.", |
| 64 | + ) |
| 65 | + ) |
| 66 | + |
| 67 | + # Initialize Arguments |
| 68 | + namespace = LaunchConfiguration("namespace") |
| 69 | + headless_mode = LaunchConfiguration("headless_mode") |
| 70 | + robot_ip = LaunchConfiguration("robot_ip") |
| 71 | + hande_dev_name = LaunchConfiguration("hande_dev_name") |
| 72 | + tool_tcp_port = LaunchConfiguration("tool_tcp_port") |
| 73 | + |
| 74 | + robot_state_helper_node = Node( |
| 75 | + package="ur_robot_driver", |
| 76 | + executable="robot_state_helper", |
| 77 | + name="ur_robot_state_helper", |
| 78 | + output="both", |
| 79 | + parameters=[ |
| 80 | + {"headless_mode": headless_mode}, |
| 81 | + {"robot_ip": robot_ip}, |
| 82 | + ], |
| 83 | + ) |
| 84 | + |
| 85 | + ur_dashboard_client = Node( |
| 86 | + package="ur_robot_driver", |
| 87 | + executable="dashboard_client", |
| 88 | + name="dashboard_client", |
| 89 | + output="both", |
| 90 | + parameters=[{"robot_ip": robot_ip}], |
| 91 | + ) |
| 92 | + |
| 93 | + hande_comm_node = Node( |
| 94 | + name="ur_tool_communication_hande", |
| 95 | + package="ur_robot_driver", |
| 96 | + executable="tool_communication.py", |
| 97 | + namespace=namespace, |
| 98 | + output="both", |
| 99 | + parameters=[ |
| 100 | + { |
| 101 | + "robot_ip": robot_ip, |
| 102 | + "tcp_port": tool_tcp_port, |
| 103 | + "device_name": hande_dev_name, |
| 104 | + } |
| 105 | + ], |
| 106 | + ) |
| 107 | + |
| 108 | + nodes = [robot_state_helper_node, ur_dashboard_client, hande_comm_node] |
| 109 | + |
| 110 | + return LaunchDescription(declared_arguments + nodes) |
0 commit comments