cps_loki_bringup/launch/robot_joy_teleop.launch.py

143 lines
4.4 KiB
Python
Raw Permalink Normal View History

2023-06-07 09:44:38 +00:00
# Copyright 2022 Factor Robotics
#
# 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.
import os
from launch import LaunchDescription
2023-11-16 12:56:18 +00:00
from launch.substitutions import Command, FindExecutable, PathJoinSubstitution, LaunchConfiguration
2023-06-07 09:44:38 +00:00
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from ament_index_python.packages import get_package_share_directory
from launch_ros.actions import LifecycleNode
from launch_ros.descriptions import ParameterValue
def generate_launch_description():
2023-11-16 12:57:29 +00:00
#use_sim_time = LaunchConfiguration('use_sim_time')
use_sim_time = True
2023-11-16 12:56:18 +00:00
2023-06-07 09:44:38 +00:00
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[
2023-11-20 09:49:14 +00:00
FindPackageShare("cps_loki_description"),
2023-06-07 09:44:38 +00:00
"urdf",
"odrive_diffbot.urdf.xacro"
]
),
]
)
robot_description = {"robot_description": ParameterValue(robot_description_content, value_type=str)}
robot_controllers = PathJoinSubstitution(
[
2023-11-20 09:49:14 +00:00
FindPackageShare("cps_loki_bringup"),
2023-06-07 09:44:38 +00:00
"config",
"diffbot_controllers.yaml",
]
)
control_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_description, robot_controllers],
output="both",
)
robot_state_pub_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
)
joint_state_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["joint_state_broadcaster", "-c", "/controller_manager"],
)
robot_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["diffbot_base_controller", "-c", "/controller_manager"],
)
joystick_spawner = Node(
package="joy",
executable="joy_node"
)
teleop_spawner = Node(
package="rmp220_teleop",
2023-06-14 06:59:22 +00:00
executable="rmp220_teleop",
2023-11-16 10:25:45 +00:00
remappings=[('cmd_vel', 'cmd_vel_joy')],
2023-06-07 09:44:38 +00:00
)
cam_node = Node(
package="ros2_cam_openCV",
executable="cam_node"
)
lidar_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params', 'lsx10.yaml')
lidar_node = LifecycleNode(
package='lslidar_driver',
executable='lslidar_driver_node',
name='lslidar_driver_node',
output='screen',
emulate_tty=True,
namespace='',
parameters=[lidar_dir],
)
2023-11-20 09:49:14 +00:00
twist_mux_params = os.path.join(get_package_share_directory('cps_loki_bringup'),'config','twist_mux.yaml')
2023-06-14 06:59:22 +00:00
twist_mux = Node(
package="twist_mux",
executable="twist_mux",
parameters=[twist_mux_params, {'use_sim_time': False}],
2023-11-16 10:37:24 +00:00
remappings=[('/cmd_vel_out','/diffbot_base_controller/cmd_vel_unstamped')]
2023-06-14 06:59:22 +00:00
)
2023-11-20 09:49:14 +00:00
joy_params = os.path.join(get_package_share_directory('cps_loki_bringup'),'config','joystick.yaml')
2023-11-16 12:50:04 +00:00
joy_node = Node(
package='joy',
executable='joy_node',
parameters=[joy_params, {'use_sim_time': use_sim_time}],
#namespace = namespace
)
teleop_node = Node(
package='teleop_twist_joy',
executable='teleop_node',
name='teleop_node',
parameters=[joy_params, {'use_sim_time': use_sim_time}],
remappings=[('cmd_vel', 'cmd_vel_joy')],
#namespace = namespace
)
2023-06-07 09:44:38 +00:00
return LaunchDescription([
#control_node,
#robot_state_pub_node,
#joint_state_broadcaster_spawner,
#robot_controller_spawner,
2023-11-16 12:50:04 +00:00
#joystick_spawner,
#teleop_spawner,
2023-06-07 09:44:38 +00:00
#cam_node,
2023-06-14 06:59:22 +00:00
#lidar_node,
2023-11-16 12:50:04 +00:00
twist_mux,
joy_node,
teleop_node
2023-10-16 14:18:52 +00:00
])