Skip to content

Commit

Permalink
Reduce number of controller_spawners to 3
Browse files Browse the repository at this point in the history
Since the controller_spawner supports a list of controllers since a while we can use this to reduce the number of total controllers.

(cherry picked from commit 31993ab)

# Conflicts:
#	ur_robot_driver/launch/ur_control.launch.py
  • Loading branch information
fmauch authored and mergify[bot] committed Feb 12, 2024
1 parent 403274a commit a14ed93
Showing 1 changed file with 53 additions and 13 deletions.
66 changes: 53 additions & 13 deletions ur_robot_driver/launch/ur_control.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch.substitutions import (
Command,
FindExecutable,
LaunchConfiguration,
PathJoinSubstitution,
)


def launch_setup(context, *args, **kwargs):
Expand Down Expand Up @@ -80,16 +85,35 @@ def launch_setup(context, *args, **kwargs):
[FindPackageShare(description_package), "config", ur_type, "joint_limits.yaml"]
)
kinematics_params = PathJoinSubstitution(
[FindPackageShare(description_package), "config", ur_type, "default_kinematics.yaml"]
[
FindPackageShare(description_package),
"config",
ur_type,
"default_kinematics.yaml",
]
)
physical_params = PathJoinSubstitution(
[FindPackageShare(description_package), "config", ur_type, "physical_parameters.yaml"]
[
FindPackageShare(description_package),
"config",
ur_type,
"physical_parameters.yaml",
]
)
visual_params = PathJoinSubstitution(
[FindPackageShare(description_package), "config", ur_type, "visual_parameters.yaml"]
[
FindPackageShare(description_package),
"config",
ur_type,
"visual_parameters.yaml",
]
)
script_filename = PathJoinSubstitution(
[FindPackageShare("ur_client_library"), "resources", "external_control.urscript"]
[
FindPackageShare("ur_client_library"),
"resources",
"external_control.urscript",
]
)
input_recipe_filename = PathJoinSubstitution(
[FindPackageShare("ur_robot_driver"), "resources", "rtde_input_recipe.txt"]
Expand Down Expand Up @@ -309,31 +333,31 @@ def launch_setup(context, *args, **kwargs):
)

# Spawn controllers
def controller_spawner(name, active=True):
def controller_spawner(controllers, active=True):
inactive_flags = ["--inactive"] if not active else []
return Node(
package="controller_manager",
executable="spawner",
arguments=[
name,
"--controller-manager",
"/controller_manager",
"--controller-manager-timeout",
controller_spawner_timeout,
]
+ inactive_flags,
+ inactive_flags
+ controllers,
)

controller_spawner_names = [
controllers_active = [
"joint_state_broadcaster",
"io_and_status_controller",
"speed_scaling_state_broadcaster",
"force_torque_sensor_broadcaster",
]
controller_spawner_inactive_names = ["forward_position_controller"]
controllers_inactive = ["forward_position_controller"]

controller_spawners = [controller_spawner(name) for name in controller_spawner_names] + [
controller_spawner(name, active=False) for name in controller_spawner_inactive_names
controller_spawners = [controller_spawner(controllers_active)] + [
controller_spawner(controllers_inactive, active=False)
]

# There may be other controllers of the joints, but this is the initially-started one
Expand Down Expand Up @@ -386,7 +410,21 @@ def generate_launch_description():
DeclareLaunchArgument(
"ur_type",
description="Type/series of used UR robot.",
<<<<<<< HEAD
choices=["ur3", "ur3e", "ur5", "ur5e", "ur10", "ur10e", "ur16e", "ur20"],
=======
choices=[
"ur3",
"ur3e",
"ur5",
"ur5e",
"ur10",
"ur10e",
"ur16e",
"ur20",
"ur30",
],
>>>>>>> 31993ab (Reduce number of controller_spawners to 3)
)
)
declared_arguments.append(
Expand Down Expand Up @@ -503,7 +541,9 @@ def generate_launch_description():
)
declared_arguments.append(
DeclareLaunchArgument(
"launch_dashboard_client", default_value="true", description="Launch Dashboard Client?"
"launch_dashboard_client",
default_value="true",
description="Launch Dashboard Client?",
)
)
declared_arguments.append(
Expand Down

0 comments on commit a14ed93

Please sign in to comment.