|
| 1 | +# Copyright (c) 2021 Franka Emika GmbH |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +from launch import LaunchDescription |
| 17 | +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription |
| 18 | +from launch.launch_description_sources import PythonLaunchDescriptionSource |
| 19 | +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution |
| 20 | +from launch_ros.actions import Node |
| 21 | +from launch_ros.substitutions import FindPackageShare |
| 22 | + |
| 23 | + |
| 24 | +def generate_launch_description(): |
| 25 | + robot_ip_parameter_name = 'robot_ip' |
| 26 | + load_gripper_parameter_name = 'load_gripper' |
| 27 | + use_fake_hardware_parameter_name = 'use_fake_hardware' |
| 28 | + fake_sensor_commands_parameter_name = 'fake_sensor_commands' |
| 29 | + use_rviz_parameter_name = 'use_rviz' |
| 30 | + |
| 31 | + robot_ip = LaunchConfiguration(robot_ip_parameter_name) |
| 32 | + load_gripper = LaunchConfiguration(load_gripper_parameter_name) |
| 33 | + use_fake_hardware = LaunchConfiguration(use_fake_hardware_parameter_name) |
| 34 | + fake_sensor_commands = LaunchConfiguration(fake_sensor_commands_parameter_name) |
| 35 | + use_rviz = LaunchConfiguration(use_rviz_parameter_name) |
| 36 | + |
| 37 | + return LaunchDescription([ |
| 38 | + DeclareLaunchArgument( |
| 39 | + robot_ip_parameter_name, |
| 40 | + description='Hostname or IP address of the robot.'), |
| 41 | + DeclareLaunchArgument( |
| 42 | + use_rviz_parameter_name, |
| 43 | + default_value='false', |
| 44 | + description='Visualize the robot in Rviz'), |
| 45 | + DeclareLaunchArgument( |
| 46 | + use_fake_hardware_parameter_name, |
| 47 | + default_value='false', |
| 48 | + description='Use fake hardware'), |
| 49 | + DeclareLaunchArgument( |
| 50 | + fake_sensor_commands_parameter_name, |
| 51 | + default_value='false', |
| 52 | + description="Fake sensor commands. Only valid when '{}' is true".format( |
| 53 | + use_fake_hardware_parameter_name)), |
| 54 | + DeclareLaunchArgument( |
| 55 | + load_gripper_parameter_name, |
| 56 | + default_value='true', |
| 57 | + description='Use Franka Gripper as an end-effector, otherwise, the robot is loaded ' |
| 58 | + 'without an end-effector.'), |
| 59 | + |
| 60 | + IncludeLaunchDescription( |
| 61 | + PythonLaunchDescriptionSource([PathJoinSubstitution( |
| 62 | + [FindPackageShare('franka_bringup'), 'launch', 'franka.launch.py'])]), |
| 63 | + launch_arguments={robot_ip_parameter_name: robot_ip, |
| 64 | + load_gripper_parameter_name: load_gripper, |
| 65 | + use_fake_hardware_parameter_name: use_fake_hardware, |
| 66 | + fake_sensor_commands_parameter_name: fake_sensor_commands, |
| 67 | + use_rviz_parameter_name: use_rviz |
| 68 | + }.items(), |
| 69 | + ), |
| 70 | + |
| 71 | + Node( |
| 72 | + package='controller_manager', |
| 73 | + executable='spawner', |
| 74 | + arguments=['joint_position_example_controller'], |
| 75 | + output='screen', |
| 76 | + ), |
| 77 | + ]) |
0 commit comments