From 02b942e27f704d4398a57768d32be93a6625edd4 Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Wed, 15 May 2024 13:53:52 +0000 Subject: [PATCH] Add deprecated info --- rosbot_xl_bringup/launch/bringup.launch.py | 16 ++- rosbot_xl_bringup/launch/combined.launch.py | 2 + rosbot_xl_bringup/launch/microros.launch.py | 105 ++++++++++++++++++ .../rosbot_xl_utils/flash_firmware.py | 4 +- 4 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 rosbot_xl_bringup/launch/microros.launch.py diff --git a/rosbot_xl_bringup/launch/bringup.launch.py b/rosbot_xl_bringup/launch/bringup.launch.py index 2fd498a..97341e3 100644 --- a/rosbot_xl_bringup/launch/bringup.launch.py +++ b/rosbot_xl_bringup/launch/bringup.launch.py @@ -14,8 +14,9 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription +from launch.conditions import UnlessCondition from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration, PathJoinSubstitution +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, PythonExpression, ThisLaunchFileDir from launch_ros.actions import Node, SetParameter from launch_ros.substitutions import FindPackageShare @@ -89,6 +90,12 @@ def generate_launch_description(): default_value="ignition-gazebo", description="Which simulation engine will be used", ) + + combined_launch_deprecated = LaunchConfiguration("combined_launch_deprecated") + declare_combined_launch_deprecated_arg = DeclareLaunchArgument( + "combined_launch_deprecated", + default_value="False", + ) rosbot_xl_controller = FindPackageShare("rosbot_xl_controller") rosbot_xl_bringup = FindPackageShare("rosbot_xl_bringup") @@ -150,6 +157,11 @@ def generate_launch_description(): namespace=namespace, ) + microros_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([ThisLaunchFileDir(), "/microros.launch.py"]), + condition=UnlessCondition(PythonExpression([use_sim, " or ", combined_launch_deprecated])), + ) + return LaunchDescription( [ declare_namespace_arg, @@ -159,7 +171,9 @@ def generate_launch_description(): declare_include_camera_mount_arg, declare_use_sim_arg, declare_simulation_engine_arg, + declare_combined_launch_deprecated_arg, SetParameter(name="use_sim_time", value=use_sim), + microros_launch, controller_launch, robot_localization_node, laser_filter_node, diff --git a/rosbot_xl_bringup/launch/combined.launch.py b/rosbot_xl_bringup/launch/combined.launch.py index ce39e54..73697b2 100644 --- a/rosbot_xl_bringup/launch/combined.launch.py +++ b/rosbot_xl_bringup/launch/combined.launch.py @@ -154,9 +154,11 @@ def generate_launch_description(): "lidar_model": lidar_model, "camera_model": camera_model, "include_camera_mount": include_camera_mount, + "combined_launch_deprecated": LaunchConfiguration("combined_launch_deprecated", default=True), }.items(), ) + print("\033[93m[WARN] [launch]: cobined.launch.py will be is deprecated and will be removed please use bringup.launch.py instead.\033[0m") return LaunchDescription( [ declare_port_arg, diff --git a/rosbot_xl_bringup/launch/microros.launch.py b/rosbot_xl_bringup/launch/microros.launch.py new file mode 100644 index 0000000..0f25478 --- /dev/null +++ b/rosbot_xl_bringup/launch/microros.launch.py @@ -0,0 +1,105 @@ +# Copyright 2024 Husarion +# +# 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 +from launch.actions import ( + DeclareLaunchArgument, + LogInfo, + OpaqueFunction, + SetEnvironmentVariable, +) +from launch.substitutions import ( + LaunchConfiguration, + PathJoinSubstitution, +) +from launch_ros.actions import Node +from launch_ros.substitutions import FindPackageShare + + +def generate_microros_agent_node(context, *args, **kwargs): + env_setup_actions = [] + + ros_domain_id = os.environ.get("ROS_DOMAIN_ID") + if ros_domain_id: + env_setup_actions.append( + SetEnvironmentVariable(name="XRCE_DOMAIN_ID_OVERRIDE", value=ros_domain_id) + ) + + port = LaunchConfiguration("port").perform(context) + + localhost_only_fastrtps_profiles_file = LaunchConfiguration( + "localhost_only_fastrtps_profiles_file" + ).perform(context) + + if os.environ.get("ROS_LOCALHOST_ONLY") == "1": + env_setup_actions.extend( + [ + LogInfo( + msg=[ + "ROS_LOCALHOST_ONLY set to 1. Using FASTRTPS_DEFAULT_PROFILES_FILE=", + localhost_only_fastrtps_profiles_file, + ".", + ] + ), + SetEnvironmentVariable(name="RMW_IMPLEMENTATION", value="rmw_fastrtps_cpp"), + SetEnvironmentVariable( + name="FASTRTPS_DEFAULT_PROFILES_FILE", + value=localhost_only_fastrtps_profiles_file, + ), + ] + ) + + microros_agent_node = Node( + package="micro_ros_agent", + executable="micro_ros_agent", + arguments=["udp4", "--port", port], + output="screen", + ) + + return env_setup_actions + [microros_agent_node] + + +def generate_launch_description(): + declare_port_arg = DeclareLaunchArgument( + "port", + default_value="8888", + description="UDP4 port for micro-ROS agent", + ) + + # Locate the rosbot_bringup package + package_dir = FindPackageShare("rosbot_xl_bringup").find("rosbot_xl_bringup") + + # Construct the path to the XML file within the package + fastrtps_profiles_file = PathJoinSubstitution( + [package_dir, "config", "microros_localhost_only.xml"] + ) + + declare_localhost_only_fastrtps_profiles_file_arg = DeclareLaunchArgument( + "localhost_only_fastrtps_profiles_file", + default_value=fastrtps_profiles_file, + description=( + "Path to the Fast RTPS default profiles file for Micro-ROS agent for localhost only" + " setup" + ), + ) + + return LaunchDescription( + [ + declare_port_arg, + declare_localhost_only_fastrtps_profiles_file_arg, + OpaqueFunction(function=generate_microros_agent_node), + ] + ) diff --git a/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py b/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py index 5ce127a..c824142 100644 --- a/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py +++ b/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py @@ -80,8 +80,8 @@ def main(args=None): parser.add_argument( "-p", "--port", - default="/dev/ttyUSB0", - help="Specify the USB port (default: /dev/ttyUSB0)", + default="/dev/ttyUSBDB", + help="Specify the USB port (default: /dev/ttyUSBDB)", ) parser.add_argument("--file", help="Specify the firmware file")