Import example code and basic prototype
This commit is contained in:
61
launch/robots/robot_panda.launch.py
Executable file
61
launch/robots/robot_panda.launch.py
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env -S ros2 launch
|
||||
"""Launch script for spawning Franka Emika Panda into Ignition Gazebo world"""
|
||||
|
||||
from typing import List
|
||||
|
||||
from launch_ros.actions import Node
|
||||
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
|
||||
|
||||
def generate_launch_description() -> LaunchDescription:
|
||||
|
||||
# Declare all launch arguments
|
||||
declared_arguments = generate_declared_arguments()
|
||||
|
||||
# Get substitution for all arguments
|
||||
model = LaunchConfiguration("model")
|
||||
use_sim_time = LaunchConfiguration("use_sim_time")
|
||||
log_level = LaunchConfiguration("log_level")
|
||||
|
||||
# List of nodes to be launched
|
||||
nodes = [
|
||||
# ros_ign_gazebo_create
|
||||
Node(
|
||||
package="ros_ign_gazebo",
|
||||
executable="create",
|
||||
output="log",
|
||||
arguments=["-file", model, "--ros-args", "--log-level", log_level],
|
||||
parameters=[{"use_sim_time": use_sim_time}],
|
||||
),
|
||||
]
|
||||
|
||||
return LaunchDescription(declared_arguments + nodes)
|
||||
|
||||
|
||||
def generate_declared_arguments() -> List[DeclareLaunchArgument]:
|
||||
"""
|
||||
Generate list of all launch arguments that are declared for this launch script.
|
||||
"""
|
||||
|
||||
return [
|
||||
# Model for Ignition Gazebo
|
||||
DeclareLaunchArgument(
|
||||
"model",
|
||||
default_value="panda",
|
||||
description="Name or filepath of model to load.",
|
||||
),
|
||||
# Miscellaneous
|
||||
DeclareLaunchArgument(
|
||||
"use_sim_time",
|
||||
default_value="true",
|
||||
description="If true, use simulated clock.",
|
||||
),
|
||||
DeclareLaunchArgument(
|
||||
"log_level",
|
||||
default_value="warn",
|
||||
description="The level of logging that is applied to all ROS 2 nodes launched by this script.",
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user