2025-05-22 07:22:55 +00:00
|
|
|
# Copyright 2025 Reazon Holdings, Inc.
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
2025-04-10 09:31:15 +00:00
|
|
|
import launch
|
2025-04-25 08:57:10 +00:00
|
|
|
from launch.actions import (
|
|
|
|
|
DeclareLaunchArgument,
|
|
|
|
|
IncludeLaunchDescription,
|
|
|
|
|
TimerAction,
|
|
|
|
|
RegisterEventHandler,
|
|
|
|
|
)
|
2025-04-10 09:31:15 +00:00
|
|
|
from launch.event_handlers import OnProcessStart
|
|
|
|
|
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, Command
|
|
|
|
|
from launch_ros.actions import Node
|
|
|
|
|
from launch_ros.substitutions import FindPackageShare
|
|
|
|
|
from launch_ros.parameter_descriptions import ParameterValue
|
|
|
|
|
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
|
|
|
2025-04-25 08:57:10 +00:00
|
|
|
def generate_launch_description():
|
2025-04-10 09:31:15 +00:00
|
|
|
pkg_share = FindPackageShare(package="openarm_bimanual_description")
|
|
|
|
|
|
2025-04-25 08:57:10 +00:00
|
|
|
xacro_path = (
|
|
|
|
|
pathlib.Path(pkg_share.find("openarm_bimanual_description"))
|
|
|
|
|
/ "urdf/openarm_bimanual.urdf.xacro"
|
|
|
|
|
)
|
2025-04-10 09:31:15 +00:00
|
|
|
|
|
|
|
|
use_sim_time = LaunchConfiguration("use_sim_time")
|
2025-06-02 08:00:35 +00:00
|
|
|
use_sim_time_launch_arg = DeclareLaunchArgument(
|
2025-07-04 04:43:08 +00:00
|
|
|
name="use_sim_time", default_value="false"
|
|
|
|
|
)
|
2025-04-10 09:31:15 +00:00
|
|
|
|
|
|
|
|
robot_state_publisher_node = IncludeLaunchDescription(
|
|
|
|
|
PythonLaunchDescriptionSource(
|
|
|
|
|
[
|
|
|
|
|
PathJoinSubstitution(
|
|
|
|
|
[
|
|
|
|
|
pkg_share,
|
|
|
|
|
"launch",
|
|
|
|
|
"description.launch.py",
|
|
|
|
|
]
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
),
|
|
|
|
|
launch_arguments=dict(use_sim_time=use_sim_time).items(),
|
|
|
|
|
)
|
|
|
|
|
|
2025-06-02 08:00:35 +00:00
|
|
|
robot_description_content = Command(
|
|
|
|
|
["xacro ", LaunchConfiguration("model")])
|
2025-04-10 09:31:15 +00:00
|
|
|
|
2025-04-25 08:57:10 +00:00
|
|
|
robot_description_param = {
|
|
|
|
|
"robot_description": ParameterValue(robot_description_content, value_type=str)
|
|
|
|
|
}
|
2025-04-10 09:31:15 +00:00
|
|
|
|
2025-04-25 08:57:10 +00:00
|
|
|
controller_params = PathJoinSubstitution(
|
2025-07-04 04:43:08 +00:00
|
|
|
[
|
|
|
|
|
FindPackageShare(package="openarm_bimanual_bringup"),
|
|
|
|
|
"config",
|
|
|
|
|
"controllers.yaml",
|
|
|
|
|
]
|
2025-04-25 08:57:10 +00:00
|
|
|
)
|
2025-04-10 09:31:15 +00:00
|
|
|
|
|
|
|
|
controller_manager = Node(
|
2025-04-25 08:57:10 +00:00
|
|
|
package="controller_manager",
|
|
|
|
|
executable="ros2_control_node",
|
|
|
|
|
parameters=[controller_params, robot_description_param],
|
|
|
|
|
)
|
2025-04-10 09:31:15 +00:00
|
|
|
|
2025-06-02 08:00:35 +00:00
|
|
|
delayed_controller_manager = TimerAction(
|
|
|
|
|
period=3.0, actions=[controller_manager])
|
2025-04-10 09:31:15 +00:00
|
|
|
|
|
|
|
|
joint_broadcaster_spawner = Node(
|
2025-04-25 08:57:10 +00:00
|
|
|
package="controller_manager",
|
|
|
|
|
executable="spawner",
|
|
|
|
|
arguments=["joint_state_broad"],
|
2025-04-10 09:31:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
delayed_joint_broadcaster_spawner = RegisterEventHandler(
|
|
|
|
|
event_handler=OnProcessStart(
|
|
|
|
|
target_action=controller_manager,
|
|
|
|
|
on_start=[joint_broadcaster_spawner],
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return launch.LaunchDescription(
|
|
|
|
|
[
|
|
|
|
|
DeclareLaunchArgument(
|
|
|
|
|
name="model",
|
|
|
|
|
default_value=str(xacro_path),
|
2025-04-25 08:57:10 +00:00
|
|
|
description="Absolute path to the robot URDF or xacro file",
|
2025-04-10 09:31:15 +00:00
|
|
|
),
|
|
|
|
|
use_sim_time_launch_arg,
|
|
|
|
|
robot_state_publisher_node,
|
|
|
|
|
delayed_controller_manager,
|
2025-04-25 08:57:10 +00:00
|
|
|
delayed_joint_broadcaster_spawner,
|
2025-04-10 09:31:15 +00:00
|
|
|
]
|
|
|
|
|
)
|