runtime/rbs_bringup/launch/control.launch.py
Bill Finger ea4ae0ed69 feat(rbs): refactor controller paths and launch configuration
- Rename default controllers file `rbs_arm0_controllers.yaml` to `controllers.yaml` across all launch files
- Enhance `runtime.launch.py` by adding imports (`URDF_parser`, `ControllerManager`, `yaml`) and new arguments (`scene_config_file`, `ee_link_name`, `base_link_name`)
  - Implement xacro argument loading via YAML
  - Configure `robot_builder` to save controllers to `controllers.yaml` based on URDF parsing
- Add `control.launch.py` in `rbs_bringup` for dynamic controller spawning based on strategies/configurations
- Add `rbs_bringup.launch.py` as a unified entry point for single robot setup, initializing core settings like gripper, robot type, and controllers
- Remove `launch_env.launch.py`
- Remove `multi_robot.launch.py`
- Enhance `rbs_robot.launch.py` with `ee_link_name` and `base_link_name` arguments for end-effector and base link customization
- Add `ee_link_name` and `base_link_name` to `skills.launch.py` for flexible robot setup in skills
- Update `mtp_jtc_cart.cpp` with `base_link` and `robot_ee_link` parameters for KDL chain retrieval
- Remove `single_robot.launch.py` for simplified single robot deployment
2024-11-12 22:23:12 +03:00

87 lines
3.1 KiB
Python

from launch_ros.actions import Node
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
# from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import LaunchConfiguration
def create_spawner(controller_name, namespace, condition=None, inactive=False):
args = [controller_name, "-c", f"{namespace}/controller_manager"]
if inactive:
args.append("--inactive")
return Node(
package="controller_manager",
executable="spawner",
namespace=namespace,
arguments=args,
condition=condition,
)
def launch_setup(context, *args, **kwargs):
namespace = LaunchConfiguration("namespace").perform(context)
control_strategy = LaunchConfiguration("control_strategy").perform(context)
control_space = LaunchConfiguration("control_space").perform(context)
has_gripper = LaunchConfiguration("has_gripper").perform(context)
interactive_control = LaunchConfiguration("interactive_control").perform(context)
controllers_config = {
"joint_state_broadcaster": True,
"gripper_controller": has_gripper == "true",
"joint_trajectory_controller": control_strategy == "position"
and control_space == "joint",
"cartesian_motion_controller": control_strategy == "position"
and control_space == "task",
"cartesian_force_controller": control_strategy == "effort"
and control_space == "task",
"joint_effort_controller": control_strategy == "effort"
and control_space == "joint",
"force_torque_sensor_broadcaster": control_strategy == "effort"
and control_space == "task",
"motion_control_handle": interactive_control == "true"
and control_space == "task"
and control_strategy == "position",
}
nodes_to_start = []
for controller_name, should_start in controllers_config.items():
if should_start:
nodes_to_start.append(create_spawner(controller_name, namespace))
return nodes_to_start
def generate_launch_description():
declared_arguments = [
DeclareLaunchArgument(
"namespace", default_value="", description="A robot's namespace"
),
DeclareLaunchArgument(
"control_space",
default_value="task",
choices=["task", "joint"],
description="Control type: 'task' for Cartesian, 'joint' for joint space control.",
),
DeclareLaunchArgument(
"control_strategy",
default_value="position",
choices=["position", "velocity", "effort"],
description="Control strategy: 'position', 'velocity', or 'effort'.",
),
DeclareLaunchArgument(
"has_gripper",
default_value="true",
description="Whether to activate the gripper_controller.",
),
DeclareLaunchArgument(
"interactive_control",
default_value="true",
description="Whether to activate the gripper_controller.",
),
]
return LaunchDescription(
declared_arguments + [OpaqueFunction(function=launch_setup)]
)