Skip to content

Commit

Permalink
Clean up launchfile minorly
Browse files Browse the repository at this point in the history
  • Loading branch information
Katie Hughes committed Dec 18, 2024
1 parent c749537 commit 86806e3
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions spot_driver/launch/spot_driver.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import os

import launch
import launch_ros
from launch import LaunchContext, LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, OpaqueFunction
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution, TextSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare

from spot_driver.launch.spot_launch_helpers import IMAGE_PUBLISHER_ARGS, declare_image_publisher_args, spot_has_arm
Expand Down Expand Up @@ -50,7 +49,7 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
# Merge the two dicts
spot_driver_params = {**spot_driver_params, **mock_spot_driver_params}

spot_driver_node = launch_ros.actions.Node(
spot_driver_node = Node(
package="spot_driver",
executable="spot_ros2",
name="spot_ros2",
Expand All @@ -63,21 +62,22 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
if not tf_prefix and spot_name:
tf_prefix = PathJoinSubstitution([spot_name, ""])

kinematc_node_params = {"spot_name": spot_name}
kinematic_node = launch_ros.actions.Node(
spot_name_param = {"spot_name": spot_name}

kinematic_node = Node(
package="spot_driver",
executable="spot_inverse_kinematics_node",
output="screen",
parameters=[config_file, kinematc_node_params],
parameters=[config_file, spot_name_param],
namespace=spot_name,
)
ld.add_action(kinematic_node)

object_sync_node = launch_ros.actions.Node(
object_sync_node = Node(
package="spot_driver",
executable="object_synchronizer_node",
output="screen",
parameters=[config_file, {"spot_name": spot_name}],
parameters=[config_file, spot_name_param],
namespace=spot_name,
)
ld.add_action(object_sync_node)
Expand All @@ -97,7 +97,7 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
]
)
robot_description_params = {"robot_description": robot_description}
robot_state_publisher = launch_ros.actions.Node(
robot_state_publisher = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="screen",
Expand All @@ -106,17 +106,16 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
)
ld.add_action(robot_state_publisher)

spot_robot_state_publisher_params = {"spot_name": spot_name}
spot_robot_state_publisher = launch_ros.actions.Node(
spot_robot_state_publisher = Node(
package="spot_driver",
executable="state_publisher_node",
output="screen",
parameters=[config_file, spot_robot_state_publisher_params],
parameters=[config_file, spot_name_param],
namespace=spot_name,
)
ld.add_action(spot_robot_state_publisher)

spot_alert_node = launch_ros.actions.Node(
spot_alert_node = Node(
package="spot_driver",
executable="spot_alerts",
name="spot_alerts",
Expand All @@ -126,7 +125,9 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
ld.add_action(spot_alert_node)

rviz = IncludeLaunchDescription(
PythonLaunchDescriptionSource([FindPackageShare(THIS_PACKAGE), "/launch", "/rviz.launch.py"]),
PythonLaunchDescriptionSource(
PathJoinSubstitution([FindPackageShare(THIS_PACKAGE), "launch", "rviz.launch.py"])
),
launch_arguments={
"spot_name": spot_name,
"rviz_config_file": rviz_config_file,
Expand All @@ -136,7 +137,9 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
ld.add_action(rviz)

spot_image_publishers = IncludeLaunchDescription(
PythonLaunchDescriptionSource([FindPackageShare(THIS_PACKAGE), "/launch", "/spot_image_publishers.launch.py"]),
PythonLaunchDescriptionSource(
PathJoinSubstitution([FindPackageShare(THIS_PACKAGE), "launch", "spot_image_publishers.launch.py"])
),
launch_arguments={
key: LaunchConfiguration(key) for key in ["config_file", "spot_name"] + IMAGE_PUBLISHER_ARGS
}.items(),
Expand All @@ -145,7 +148,7 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
ld.add_action(spot_image_publishers)


def generate_launch_description() -> launch.LaunchDescription:
def generate_launch_description() -> LaunchDescription:
launch_args = []

launch_args.append(
Expand Down Expand Up @@ -195,7 +198,7 @@ def generate_launch_description() -> launch.LaunchDescription:
launch_args += declare_image_publisher_args()
launch_args.append(DeclareLaunchArgument("spot_name", default_value="", description="Name of Spot"))

ld = launch.LaunchDescription(launch_args)
ld = LaunchDescription(launch_args)

ld.add_action(OpaqueFunction(function=launch_setup, args=[ld]))

Expand Down

0 comments on commit 86806e3

Please # to comment.