From cf0c090e24b79100c276d856ea24388c9d868ebe Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Mon, 6 May 2024 17:30:34 +0200 Subject: [PATCH 1/9] Pkg rename, FindPackageShare and isort --- .gitignore | 2 +- .pre-commit-config.yaml | 11 +++++++--- README.md | 1 - ROS_API.md | 2 +- rosbot_xl/rosbot_xl_simulation.repos | 4 ++-- rosbot_xl_bringup/launch/bringup.launch.py | 12 +++++------ rosbot_xl_bringup/launch/combined.launch.py | 11 +++++----- rosbot_xl_bringup/package.xml | 1 - rosbot_xl_bringup/setup.py | 1 + rosbot_xl_bringup/test/test_copyright.py | 2 +- .../test/test_diff_drive_ekf_and_scan.py | 10 ++++----- rosbot_xl_bringup/test/test_flake8.py | 5 +++-- .../test/test_mecanum_ekf_and_scan.py | 10 ++++----- .../test/test_multirobot_ekf_and_scan.py | 11 +++++----- ...test_namespaced_diff_drive_ekf_and_scan.py | 10 ++++----- .../test_namespaced_mecanum_ekf_and_scan.py | 10 ++++----- rosbot_xl_bringup/test/test_pep257.py | 2 +- rosbot_xl_bringup/test/test_utils.py | 6 +++--- .../launch/controller.launch.py | 13 ++++-------- rosbot_xl_controller/package.xml | 1 - rosbot_xl_controller/setup.py | 1 + rosbot_xl_controller/test/test_copyright.py | 2 +- .../test/test_diff_drive_controllers.py | 10 ++++----- rosbot_xl_controller/test/test_flake8.py | 5 +++-- .../test/test_mecanum_controllers.py | 11 +++++----- .../test/test_multirobot_controllers.py | 11 +++++----- .../test_namespaced_diff_drive_controllers.py | 11 +++++----- .../test_namespaced_mecanum_controllers.py | 11 +++++----- rosbot_xl_controller/test/test_pep257.py | 2 +- rosbot_xl_controller/test/test_utils.py | 5 +++-- rosbot_xl_controller/test/test_xacro.py | 7 ++++--- rosbot_xl_gazebo/launch/simulation.launch.py | 21 ++++++++----------- rosbot_xl_gazebo/launch/spawn.launch.py | 21 +++++++++---------- rosbot_xl_gazebo/package.xml | 4 +--- rosbot_xl_gazebo/setup.py | 1 + rosbot_xl_gazebo/test/test_copyright.py | 2 +- .../test/test_diff_drive_simulation.py | 15 +++++++------ rosbot_xl_gazebo/test/test_flake8.py | 2 +- rosbot_xl_gazebo/test/test_ign_kill_utils.py | 3 ++- .../test/test_mecanum_simulation.py | 15 +++++++------ .../test_multirobot_diff_drive_simulation.py | 13 +++++------- .../test_multirobot_mecanum_simulation.py | 13 +++++------- .../test_namespaced_diff_drive_simulation.py | 15 +++++++------ .../test_namespaced_mecanum_simulation.py | 14 ++++++------- rosbot_xl_gazebo/test/test_pep257.py | 2 +- rosbot_xl_gazebo/test/test_utils.py | 5 ++--- rosbot_xl_utils/package.xml | 2 ++ .../rosbot_xl_utils/flash-firmware.py | 7 ++++--- .../rosbot_xl_utils/flash_firmware.py | 15 +++++++------ rosbot_xl_utils/setup.py | 1 + rosbot_xl_utils/test/test_copyright.py | 2 +- rosbot_xl_utils/test/test_flake8.py | 2 +- rosbot_xl_utils/test/test_pep257.py | 2 +- 53 files changed, 182 insertions(+), 196 deletions(-) diff --git a/.gitignore b/.gitignore index 4d56f66a..0b3d8fbd 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ __pycache__/ rosbot_hardware_interfaces/ ros_components_description/ rosbot_controllers/ -husarion/husarion_office_gz +husarion/husarion_gz_worlds micro-ROS-Agent/ micro_ros_msgs/ industrial_ci/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 325294f8..40977956 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,12 +32,11 @@ repos: files: ^(?!.*compose)(?!.*ekf\.yaml$).*$ args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '100'] - # Please keep this version until --experimental-string-processing come back or will be available by default - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 24.4.0 hooks: - id: black - args: [--line-length=99, --experimental-string-processing] + args: [--line-length=99] - repo: https://github.com/PyCQA/flake8 rev: 7.0.0 @@ -46,6 +45,12 @@ repos: args: ['--ignore=E501,W503'] # ignore too long line and line break before binary operator, # black checks it + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + args: [--profile, black] + - repo: local hooks: - id: ament_lint_cmake diff --git a/README.md b/README.md index 3a9763b2..e9a24fff 100644 --- a/README.md +++ b/README.md @@ -109,4 +109,3 @@ For further usage examples check out our other repositories: * [`rosbot-xl-autonomy`](https://github.com/husarion/rosbot-xl-autonomy) - autonomous navigation & mapping based on Nav2 * [`rosbot-xl-telepresence`](https://github.com/husarion/rosbot-xl-telepresence) - control and receive signals in real time from any device across the Internet using Husarnet VPN * [`rosbot-xl-manipulation`](https://github.com/husarion/rosbot-xl-manipulation) - integration of ROSbot XL with OpenManipulatorX - diff --git a/ROS_API.md b/ROS_API.md index 3e39038c..0dc25beb 100644 --- a/ROS_API.md +++ b/ROS_API.md @@ -61,7 +61,7 @@ Launch files for Ignition Gazebo working with ROS2 control. | **include_camera_mount** | Whether to include camera mount to the robot URDF | **False** | | **mecanum** | Whether to use mecanum drive controller, otherwise use diff drive | **False** | | **namespace** | Namespace for all topics and tfs | **""** | -| **world** | Path to SDF world file | **`husarion_office_gz/`
`worlds/husarion_world.sdf`** | +| **world** | Path to SDF world file | **`husarion_gz_worlds/`
`worlds/husarion_world.sdf`** | | **headless** | Run Gazebo Ignition in the headless mode | **False** | | **robots** | List of robots that will be spawn in the simulation | **[]**\*\* | diff --git a/rosbot_xl/rosbot_xl_simulation.repos b/rosbot_xl/rosbot_xl_simulation.repos index e4d80df2..8bdcbbae 100644 --- a/rosbot_xl/rosbot_xl_simulation.repos +++ b/rosbot_xl/rosbot_xl_simulation.repos @@ -1,5 +1,5 @@ repositories: - husarion/husarion_office_gz: + husarion/husarion_gz_worlds: type: git - url: https://github.com/husarion/husarion_office_gz + url: https://github.com/husarion/husarion_gz_worlds version: main diff --git a/rosbot_xl_bringup/launch/bringup.launch.py b/rosbot_xl_bringup/launch/bringup.launch.py index b494e31c..2fd498a4 100644 --- a/rosbot_xl_bringup/launch/bringup.launch.py +++ b/rosbot_xl_bringup/launch/bringup.launch.py @@ -13,13 +13,11 @@ # limitations under the License. from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument -from launch.substitutions import PathJoinSubstitution, LaunchConfiguration +from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource - +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution from launch_ros.actions import Node, SetParameter - -from ament_index_python.packages import get_package_share_directory +from launch_ros.substitutions import FindPackageShare def generate_launch_description(): @@ -92,8 +90,8 @@ def generate_launch_description(): description="Which simulation engine will be used", ) - rosbot_xl_controller = get_package_share_directory("rosbot_xl_controller") - rosbot_xl_bringup = get_package_share_directory("rosbot_xl_bringup") + rosbot_xl_controller = FindPackageShare("rosbot_xl_controller") + rosbot_xl_bringup = FindPackageShare("rosbot_xl_bringup") controller_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( diff --git a/rosbot_xl_bringup/launch/combined.launch.py b/rosbot_xl_bringup/launch/combined.launch.py index 45754ff4..f41dbcea 100644 --- a/rosbot_xl_bringup/launch/combined.launch.py +++ b/rosbot_xl_bringup/launch/combined.launch.py @@ -12,19 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os + from launch import LaunchDescription -from launch_ros.substitutions import FindPackageShare from launch.actions import ( - IncludeLaunchDescription, DeclareLaunchArgument, + IncludeLaunchDescription, LogInfo, - SetEnvironmentVariable, OpaqueFunction, + SetEnvironmentVariable, ) from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import ThisLaunchFileDir, LaunchConfiguration +from launch.substitutions import LaunchConfiguration, ThisLaunchFileDir from launch_ros.actions import Node -import os +from launch_ros.substitutions import FindPackageShare def generate_microros_agent_node(context, *args, **kwargs): diff --git a/rosbot_xl_bringup/package.xml b/rosbot_xl_bringup/package.xml index 3adbf5d3..5cb411ac 100644 --- a/rosbot_xl_bringup/package.xml +++ b/rosbot_xl_bringup/package.xml @@ -21,7 +21,6 @@ ros2launch launch launch_ros - ament_index_python rosbot_xl_controller diff --git a/rosbot_xl_bringup/setup.py b/rosbot_xl_bringup/setup.py index 8533fd30..c6b6b6e8 100644 --- a/rosbot_xl_bringup/setup.py +++ b/rosbot_xl_bringup/setup.py @@ -14,6 +14,7 @@ import os from glob import glob + from setuptools import find_packages, setup package_name = "rosbot_xl_bringup" diff --git a/rosbot_xl_bringup/test/test_copyright.py b/rosbot_xl_bringup/test/test_copyright.py index f46f861d..9167f3d7 100644 --- a/rosbot_xl_bringup/test/test_copyright.py +++ b/rosbot_xl_bringup/test/test_copyright.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_copyright.main import main import pytest +from ament_copyright.main import main @pytest.mark.copyright diff --git a/rosbot_xl_bringup/test/test_diff_drive_ekf_and_scan.py b/rosbot_xl_bringup/test/test_diff_drive_ekf_and_scan.py index 8507b9fa..d2398f08 100644 --- a/rosbot_xl_bringup/test/test_diff_drive_ekf_and_scan.py +++ b/rosbot_xl_bringup/test/test_diff_drive_ekf_and_scan.py @@ -14,22 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import BringupTestNode, ekf_and_scan_test -from threading import Thread @launch_pytest.fixture def generate_test_description(): - rosbot_xl_bringup = get_package_share_directory("rosbot_xl_bringup") + rosbot_xl_bringup = FindPackageShare("rosbot_xl_bringup") bringup_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( diff --git a/rosbot_xl_bringup/test/test_flake8.py b/rosbot_xl_bringup/test/test_flake8.py index 40602d8a..db52225b 100644 --- a/rosbot_xl_bringup/test/test_flake8.py +++ b/rosbot_xl_bringup/test/test_flake8.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_flake8.main import main_with_errors -from os.path import join, dirname +from os.path import dirname, join + import pytest +from ament_flake8.main import main_with_errors @pytest.mark.flake8 diff --git a/rosbot_xl_bringup/test/test_mecanum_ekf_and_scan.py b/rosbot_xl_bringup/test/test_mecanum_ekf_and_scan.py index 817be79d..4d4a4406 100644 --- a/rosbot_xl_bringup/test/test_mecanum_ekf_and_scan.py +++ b/rosbot_xl_bringup/test/test_mecanum_ekf_and_scan.py @@ -14,22 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import BringupTestNode, ekf_and_scan_test -from threading import Thread @launch_pytest.fixture def generate_test_description(): - rosbot_xl_bringup = get_package_share_directory("rosbot_xl_bringup") + rosbot_xl_bringup = FindPackageShare("rosbot_xl_bringup") bringup_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( diff --git a/rosbot_xl_bringup/test/test_multirobot_ekf_and_scan.py b/rosbot_xl_bringup/test/test_multirobot_ekf_and_scan.py index 446c569e..ae605a42 100644 --- a/rosbot_xl_bringup/test/test_multirobot_ekf_and_scan.py +++ b/rosbot_xl_bringup/test/test_multirobot_ekf_and_scan.py @@ -14,26 +14,25 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from rclpy.executors import SingleThreadedExecutor from test_utils import BringupTestNode, ekf_and_scan_test -from threading import Thread - robot_names = ["rosbot1", "rosbot2", "rosbot3"] @launch_pytest.fixture def generate_test_description(): - rosbot_xl_bringup = get_package_share_directory("rosbot_xl_bringup") + rosbot_xl_bringup = FindPackageShare("rosbot_xl_bringup") actions = [] for i in range(len(robot_names)): bringup_launch = IncludeLaunchDescription( diff --git a/rosbot_xl_bringup/test/test_namespaced_diff_drive_ekf_and_scan.py b/rosbot_xl_bringup/test/test_namespaced_diff_drive_ekf_and_scan.py index 34f69717..3ed55ba6 100644 --- a/rosbot_xl_bringup/test/test_namespaced_diff_drive_ekf_and_scan.py +++ b/rosbot_xl_bringup/test/test_namespaced_diff_drive_ekf_and_scan.py @@ -14,22 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import BringupTestNode, ekf_and_scan_test -from threading import Thread @launch_pytest.fixture def generate_test_description(): - rosbot_xl_bringup = get_package_share_directory("rosbot_xl_bringup") + rosbot_xl_bringup = FindPackageShare("rosbot_xl_bringup") bringup_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( diff --git a/rosbot_xl_bringup/test/test_namespaced_mecanum_ekf_and_scan.py b/rosbot_xl_bringup/test/test_namespaced_mecanum_ekf_and_scan.py index 4b4b17e5..06d6054a 100644 --- a/rosbot_xl_bringup/test/test_namespaced_mecanum_ekf_and_scan.py +++ b/rosbot_xl_bringup/test/test_namespaced_mecanum_ekf_and_scan.py @@ -14,22 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import BringupTestNode, ekf_and_scan_test -from threading import Thread @launch_pytest.fixture def generate_test_description(): - rosbot_xl_bringup = get_package_share_directory("rosbot_xl_bringup") + rosbot_xl_bringup = FindPackageShare("rosbot_xl_bringup") bringup_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( diff --git a/rosbot_xl_bringup/test/test_pep257.py b/rosbot_xl_bringup/test/test_pep257.py index a2c3deb8..4eddb46e 100644 --- a/rosbot_xl_bringup/test/test_pep257.py +++ b/rosbot_xl_bringup/test/test_pep257.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_pep257.main import main import pytest +from ament_pep257.main import main @pytest.mark.linter diff --git a/rosbot_xl_bringup/test/test_utils.py b/rosbot_xl_bringup/test/test_utils.py index 527b7257..0211a0dc 100644 --- a/rosbot_xl_bringup/test/test_utils.py +++ b/rosbot_xl_bringup/test/test_utils.py @@ -13,13 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import rclpy import math import random - from threading import Event + +import rclpy from rclpy.node import Node -from sensor_msgs.msg import JointState, Imu, LaserScan +from sensor_msgs.msg import Imu, JointState, LaserScan from tf2_ros import TransformException from tf2_ros.buffer import Buffer from tf2_ros.transform_listener import TransformListener diff --git a/rosbot_xl_controller/launch/controller.launch.py b/rosbot_xl_controller/launch/controller.launch.py index 8cd15108..afc3256b 100644 --- a/rosbot_xl_controller/launch/controller.launch.py +++ b/rosbot_xl_controller/launch/controller.launch.py @@ -15,22 +15,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -from launch.event_handlers import OnProcessExit from launch import LaunchDescription -from launch.actions import ( - DeclareLaunchArgument, - RegisterEventHandler, - OpaqueFunction, -) +from launch.actions import DeclareLaunchArgument, OpaqueFunction, RegisterEventHandler from launch.conditions import UnlessCondition +from launch.event_handlers import OnProcessExit from launch.substitutions import ( Command, - PythonExpression, FindExecutable, - PathJoinSubstitution, LaunchConfiguration, + PathJoinSubstitution, + PythonExpression, ) - from launch_ros.actions import Node, SetParameter from launch_ros.substitutions import FindPackageShare diff --git a/rosbot_xl_controller/package.xml b/rosbot_xl_controller/package.xml index c3b3b7cd..fee112cd 100644 --- a/rosbot_xl_controller/package.xml +++ b/rosbot_xl_controller/package.xml @@ -22,7 +22,6 @@ ros2launch launch launch_ros - ament_index_python rosbot_xl_description ros_components_description diff --git a/rosbot_xl_controller/setup.py b/rosbot_xl_controller/setup.py index 1bb857ba..d4d5c9c0 100644 --- a/rosbot_xl_controller/setup.py +++ b/rosbot_xl_controller/setup.py @@ -14,6 +14,7 @@ import os from glob import glob + from setuptools import find_packages, setup package_name = "rosbot_xl_controller" diff --git a/rosbot_xl_controller/test/test_copyright.py b/rosbot_xl_controller/test/test_copyright.py index f46f861d..9167f3d7 100644 --- a/rosbot_xl_controller/test/test_copyright.py +++ b/rosbot_xl_controller/test/test_copyright.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_copyright.main import main import pytest +from ament_copyright.main import main @pytest.mark.copyright diff --git a/rosbot_xl_controller/test/test_diff_drive_controllers.py b/rosbot_xl_controller/test/test_diff_drive_controllers.py index c7d1ee86..90b7dc43 100644 --- a/rosbot_xl_controller/test/test_diff_drive_controllers.py +++ b/rosbot_xl_controller/test/test_diff_drive_controllers.py @@ -14,22 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import ControllersTestNode, controller_test -from threading import Thread @launch_pytest.fixture def generate_test_description(): - rosbot_xl_controller = get_package_share_directory("rosbot_xl_controller") + rosbot_xl_controller = FindPackageShare("rosbot_xl_controller") bringup_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( diff --git a/rosbot_xl_controller/test/test_flake8.py b/rosbot_xl_controller/test/test_flake8.py index 40602d8a..db52225b 100644 --- a/rosbot_xl_controller/test/test_flake8.py +++ b/rosbot_xl_controller/test/test_flake8.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_flake8.main import main_with_errors -from os.path import join, dirname +from os.path import dirname, join + import pytest +from ament_flake8.main import main_with_errors @pytest.mark.flake8 diff --git a/rosbot_xl_controller/test/test_mecanum_controllers.py b/rosbot_xl_controller/test/test_mecanum_controllers.py index 12530dab..7e0288b2 100644 --- a/rosbot_xl_controller/test/test_mecanum_controllers.py +++ b/rosbot_xl_controller/test/test_mecanum_controllers.py @@ -14,23 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import ControllersTestNode, controller_test -from threading import Thread @launch_pytest.fixture def generate_test_description(): - rosbot_xl_controller = get_package_share_directory("rosbot_xl_controller") + rosbot_xl_controller = FindPackageShare("rosbot_xl_controller") bringup_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( diff --git a/rosbot_xl_controller/test/test_multirobot_controllers.py b/rosbot_xl_controller/test/test_multirobot_controllers.py index 6c699f8a..83b4c23a 100644 --- a/rosbot_xl_controller/test/test_multirobot_controllers.py +++ b/rosbot_xl_controller/test/test_multirobot_controllers.py @@ -14,25 +14,24 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription, TimerAction -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import ControllersTestNode, controller_test -from threading import Thread robot_names = ["rosbot_xl1", "rosbot_xl2", "rosbot_xl3"] @launch_pytest.fixture def generate_test_description(): - rosbot_controller = get_package_share_directory("rosbot_xl_controller") + rosbot_controller = FindPackageShare("rosbot_xl_controller") actions = [] for i in range(len(robot_names)): controller_launch = IncludeLaunchDescription( diff --git a/rosbot_xl_controller/test/test_namespaced_diff_drive_controllers.py b/rosbot_xl_controller/test/test_namespaced_diff_drive_controllers.py index a9b6b056..1ac0b7e5 100644 --- a/rosbot_xl_controller/test/test_namespaced_diff_drive_controllers.py +++ b/rosbot_xl_controller/test/test_namespaced_diff_drive_controllers.py @@ -14,23 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import ControllersTestNode, controller_test -from threading import Thread @launch_pytest.fixture def generate_test_description(): - rosbot_xl_controller = get_package_share_directory("rosbot_xl_controller") + rosbot_xl_controller = FindPackageShare("rosbot_xl_controller") bringup_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( diff --git a/rosbot_xl_controller/test/test_namespaced_mecanum_controllers.py b/rosbot_xl_controller/test/test_namespaced_mecanum_controllers.py index b3a2beed..2c51fcbf 100644 --- a/rosbot_xl_controller/test/test_namespaced_mecanum_controllers.py +++ b/rosbot_xl_controller/test/test_namespaced_mecanum_controllers.py @@ -14,23 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from test_utils import ControllersTestNode, controller_test -from threading import Thread @launch_pytest.fixture def generate_test_description(): - rosbot_xl_controller = get_package_share_directory("rosbot_xl_controller") + rosbot_xl_controller = FindPackageShare("rosbot_xl_controller") bringup_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( diff --git a/rosbot_xl_controller/test/test_pep257.py b/rosbot_xl_controller/test/test_pep257.py index a2c3deb8..4eddb46e 100644 --- a/rosbot_xl_controller/test/test_pep257.py +++ b/rosbot_xl_controller/test/test_pep257.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_pep257.main import main import pytest +from ament_pep257.main import main @pytest.mark.linter diff --git a/rosbot_xl_controller/test/test_utils.py b/rosbot_xl_controller/test/test_utils.py index a6a386c9..bfd6b46a 100644 --- a/rosbot_xl_controller/test/test_utils.py +++ b/rosbot_xl_controller/test/test_utils.py @@ -15,9 +15,10 @@ from threading import Event -from rclpy.node import Node -from sensor_msgs.msg import JointState, Imu + from nav_msgs.msg import Odometry +from rclpy.node import Node +from sensor_msgs.msg import Imu, JointState class ControllersTestNode(Node): diff --git a/rosbot_xl_controller/test/test_xacro.py b/rosbot_xl_controller/test/test_xacro.py index 0ef5dfa7..ec6a8fd4 100644 --- a/rosbot_xl_controller/test/test_xacro.py +++ b/rosbot_xl_controller/test/test_xacro.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import itertools import os + import xacro -import itertools -from ament_index_python.packages import get_package_share_directory +from launch_ros.substitutions import FindPackageShare def test_rosbot_description_parsing(): @@ -68,7 +69,7 @@ def test_rosbot_description_parsing(): "lidar_model": lidar_model, "camera_model": camera_model, } - rosbot_xl_description = get_package_share_directory("rosbot_xl_description") + rosbot_xl_description = FindPackageShare("rosbot_xl_description") xacro_path = os.path.join(rosbot_xl_description, "urdf/rosbot_xl.urdf.xacro") try: xacro.process_file(xacro_path, mappings=mappings) diff --git a/rosbot_xl_gazebo/launch/simulation.launch.py b/rosbot_xl_gazebo/launch/simulation.launch.py index 2d5bbf67..05c1a458 100644 --- a/rosbot_xl_gazebo/launch/simulation.launch.py +++ b/rosbot_xl_gazebo/launch/simulation.launch.py @@ -14,24 +14,21 @@ from launch import LaunchDescription from launch.actions import ( - IncludeLaunchDescription, DeclareLaunchArgument, - OpaqueFunction, - LogInfo, GroupAction, + IncludeLaunchDescription, + LogInfo, + OpaqueFunction, ) +from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import ( EnvironmentVariable, - PathJoinSubstitution, LaunchConfiguration, + PathJoinSubstitution, TextSubstitution, ) -from launch.launch_description_sources import PythonLaunchDescriptionSource - from launch_ros.actions import SetParameter - -from ament_index_python.packages import get_package_share_directory - +from launch_ros.substitutions import FindPackageShare from nav2_common.launch import ParseMultiRobotPose @@ -55,7 +52,7 @@ def launch_setup(context, *args, **kwargs): PythonLaunchDescriptionSource( PathJoinSubstitution( [ - get_package_share_directory("ros_gz_sim"), + FindPackageShare("husarion_gz_worlds"), "launch", "gz_sim.launch.py", ] @@ -93,7 +90,7 @@ def launch_setup(context, *args, **kwargs): PythonLaunchDescriptionSource( PathJoinSubstitution( [ - get_package_share_directory("rosbot_xl_gazebo"), + FindPackageShare("rosbot_xl_gazebo"), "launch", "spawn.launch.py", ] @@ -177,7 +174,7 @@ def generate_launch_description(): description="Whether to include camera mount to the robot URDF", ) - world_package = get_package_share_directory("husarion_office_gz") + world_package = FindPackageShare("husarion_gz_worlds") world_file = PathJoinSubstitution([world_package, "worlds", "husarion_world.sdf"]) declare_world_arg = DeclareLaunchArgument( "world", default_value=world_file, description="Path to SDF world file" diff --git a/rosbot_xl_gazebo/launch/spawn.launch.py b/rosbot_xl_gazebo/launch/spawn.launch.py index e235a61a..e80ceb7c 100644 --- a/rosbot_xl_gazebo/launch/spawn.launch.py +++ b/rosbot_xl_gazebo/launch/spawn.launch.py @@ -12,23 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -from launch import LaunchDescription, LaunchContext +from launch import LaunchContext, LaunchDescription from launch.actions import ( - IncludeLaunchDescription, DeclareLaunchArgument, + IncludeLaunchDescription, OpaqueFunction, ) +from launch.conditions import LaunchConfigurationNotEquals +from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import ( - PathJoinSubstitution, LaunchConfiguration, + PathJoinSubstitution, PythonExpression, ) -from launch.conditions import LaunchConfigurationNotEquals -from launch.launch_description_sources import PythonLaunchDescriptionSource -from nav2_common.launch import ReplaceString from launch_ros.actions import Node, SetParameter - -from ament_index_python.packages import get_package_share_directory +from launch_ros.substitutions import FindPackageShare +from nav2_common.launch import ReplaceString def launch_gz_bridge(context: LaunchContext, *args, **kwargs): @@ -59,7 +58,7 @@ def launch_gz_bridge(context: LaunchContext, *args, **kwargs): if lidar_model != "None": gz_lidar_remappings_file = PathJoinSubstitution( [ - get_package_share_directory("rosbot_xl_gazebo"), + FindPackageShare("rosbot_xl_gazebo"), "config", LaunchConfiguration( "gz_lidar_remappings_file", @@ -100,7 +99,7 @@ def launch_gz_bridge(context: LaunchContext, *args, **kwargs): gz_camera_remappings_file = PathJoinSubstitution( [ - get_package_share_directory("rosbot_xl_gazebo"), + FindPackageShare("rosbot_xl_gazebo"), "config", LaunchConfiguration( "gz_camera_remappings_file", @@ -269,7 +268,7 @@ def generate_launch_description(): PythonLaunchDescriptionSource( PathJoinSubstitution( [ - get_package_share_directory("rosbot_xl_bringup"), + FindPackageShare("rosbot_xl_bringup"), "launch", "bringup.launch.py", ] diff --git a/rosbot_xl_gazebo/package.xml b/rosbot_xl_gazebo/package.xml index 6eb3d7cc..2b3c05bb 100644 --- a/rosbot_xl_gazebo/package.xml +++ b/rosbot_xl_gazebo/package.xml @@ -22,12 +22,10 @@ ros2launch launch launch_ros - ament_index_python rosbot_xl_bringup - husarion_office_gz + husarion_gz_worlds - ros_gz_sim diff --git a/rosbot_xl_gazebo/setup.py b/rosbot_xl_gazebo/setup.py index 9e5bccdd..fdc69b89 100644 --- a/rosbot_xl_gazebo/setup.py +++ b/rosbot_xl_gazebo/setup.py @@ -14,6 +14,7 @@ import os from glob import glob + from setuptools import find_packages, setup package_name = "rosbot_xl_gazebo" diff --git a/rosbot_xl_gazebo/test/test_copyright.py b/rosbot_xl_gazebo/test/test_copyright.py index f46f861d..9167f3d7 100644 --- a/rosbot_xl_gazebo/test/test_copyright.py +++ b/rosbot_xl_gazebo/test/test_copyright.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_copyright.main import main import pytest +from ament_copyright.main import main @pytest.mark.copyright diff --git a/rosbot_xl_gazebo/test/test_diff_drive_simulation.py b/rosbot_xl_gazebo/test/test_diff_drive_simulation.py index 2eac511d..306f1157 100644 --- a/rosbot_xl_gazebo/test/test_diff_drive_simulation.py +++ b/rosbot_xl_gazebo/test/test_diff_drive_simulation.py @@ -14,26 +14,25 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc -from test_utils import SimulationTestNode, diff_test from test_ign_kill_utils import kill_ign_linux_processes -from threading import Thread +from test_utils import SimulationTestNode, diff_test @launch_pytest.fixture def generate_test_description(): - rosbot_xl_gazebo = get_package_share_directory("rosbot_xl_gazebo") + rosbot_xl_gazebo = FindPackageShare("rosbot_xl_gazebo") simulation_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( @@ -48,7 +47,7 @@ def generate_test_description(): "headless": "True", "world": PathJoinSubstitution( [ - get_package_share_directory("husarion_office_gz"), + FindPackageShare("husarion_gz_worlds"), "worlds", "empty_with_plugins.sdf", ] diff --git a/rosbot_xl_gazebo/test/test_flake8.py b/rosbot_xl_gazebo/test/test_flake8.py index 49c1644f..22fffcb8 100644 --- a/rosbot_xl_gazebo/test/test_flake8.py +++ b/rosbot_xl_gazebo/test/test_flake8.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_flake8.main import main_with_errors import pytest +from ament_flake8.main import main_with_errors @pytest.mark.flake8 diff --git a/rosbot_xl_gazebo/test/test_ign_kill_utils.py b/rosbot_xl_gazebo/test/test_ign_kill_utils.py index 4f857a1f..901997e1 100644 --- a/rosbot_xl_gazebo/test/test_ign_kill_utils.py +++ b/rosbot_xl_gazebo/test/test_ign_kill_utils.py @@ -13,9 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import psutil from time import sleep +import psutil + # The pytest cannot kill properly the Gazebo Ignition's tasks what blocks launching # several tests in a row. # https://github.com/ros-controls/gz_ros2_control/blob/master/gz_ros2_control_tests/tests/position_test.py diff --git a/rosbot_xl_gazebo/test/test_mecanum_simulation.py b/rosbot_xl_gazebo/test/test_mecanum_simulation.py index c605d25f..3f2994f0 100644 --- a/rosbot_xl_gazebo/test/test_mecanum_simulation.py +++ b/rosbot_xl_gazebo/test/test_mecanum_simulation.py @@ -14,26 +14,25 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc -from test_utils import SimulationTestNode, mecanum_test from test_ign_kill_utils import kill_ign_linux_processes -from threading import Thread +from test_utils import SimulationTestNode, mecanum_test @launch_pytest.fixture def generate_test_description(): - rosbot_xl_gazebo = get_package_share_directory("rosbot_xl_gazebo") + rosbot_xl_gazebo = FindPackageShare("rosbot_xl_gazebo") simulation_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( @@ -49,7 +48,7 @@ def generate_test_description(): "headless": "True", "world": PathJoinSubstitution( [ - get_package_share_directory("husarion_office_gz"), + FindPackageShare("husarion_gz_worlds"), "worlds", "empty_with_plugins.sdf", ] diff --git a/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py b/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py index 9d2a9f94..b9cc26c4 100644 --- a/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py +++ b/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py @@ -14,19 +14,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import ExecuteProcess +from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc from rclpy.executors import SingleThreadedExecutor -from test_utils import SimulationTestNode, diff_test from test_ign_kill_utils import kill_ign_linux_processes -from threading import Thread +from test_utils import SimulationTestNode, diff_test @launch_pytest.fixture @@ -38,10 +38,7 @@ def generate_test_description(): "launch", "rosbot_xl_gazebo", "simulation.launch.py", - ( - f'world:={get_package_share_directory("husarion_office_gz")}' - "/worlds/empty_with_plugins.sdf" - ), + f'world:={FindPackageShare("husarion_gz_worlds")}/worlds/empty_with_plugins.sdf', "robots:=robot1={y: -4.0}; robot2={y: 0.0};", "headless:=True", ], diff --git a/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py b/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py index 8f092d7a..0b6756a2 100644 --- a/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py +++ b/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py @@ -14,19 +14,19 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import ExecuteProcess +from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc from rclpy.executors import SingleThreadedExecutor -from test_utils import SimulationTestNode, mecanum_test from test_ign_kill_utils import kill_ign_linux_processes -from threading import Thread +from test_utils import SimulationTestNode, mecanum_test @launch_pytest.fixture @@ -38,10 +38,7 @@ def generate_test_description(): "launch", "rosbot_xl_gazebo", "simulation.launch.py", - ( - f'world:={get_package_share_directory("husarion_office_gz")}' - "/worlds/empty_with_plugins.sdf" - ), + f'world:={FindPackageShare("husarion_gz_worlds")}/worlds/empty_with_plugins.sdf', "robots:=robot1={y: -4.0}; robot2={y: 0.0};", "mecanum:=True", "headless:=True", diff --git a/rosbot_xl_gazebo/test/test_namespaced_diff_drive_simulation.py b/rosbot_xl_gazebo/test/test_namespaced_diff_drive_simulation.py index f47cd768..a2c3035b 100644 --- a/rosbot_xl_gazebo/test/test_namespaced_diff_drive_simulation.py +++ b/rosbot_xl_gazebo/test/test_namespaced_diff_drive_simulation.py @@ -14,26 +14,25 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc -from test_utils import SimulationTestNode, diff_test from test_ign_kill_utils import kill_ign_linux_processes -from threading import Thread +from test_utils import SimulationTestNode, diff_test @launch_pytest.fixture def generate_test_description(): - rosbot_xl_gazebo = get_package_share_directory("rosbot_xl_gazebo") + rosbot_xl_gazebo = FindPackageShare("rosbot_xl_gazebo") simulation_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( @@ -48,7 +47,7 @@ def generate_test_description(): "headless": "True", "world": PathJoinSubstitution( [ - get_package_share_directory("husarion_office_gz"), + FindPackageShare("husarion_gz_worlds"), "worlds", "empty_with_plugins.sdf", ] diff --git a/rosbot_xl_gazebo/test/test_namespaced_mecanum_simulation.py b/rosbot_xl_gazebo/test/test_namespaced_mecanum_simulation.py index ef81010f..fad1cc40 100644 --- a/rosbot_xl_gazebo/test/test_namespaced_mecanum_simulation.py +++ b/rosbot_xl_gazebo/test/test_namespaced_mecanum_simulation.py @@ -14,25 +14,25 @@ # See the License for the specific language governing permissions and # limitations under the License. +from threading import Thread + import launch_pytest import pytest import rclpy - -from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription -from launch.substitutions import PathJoinSubstitution from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import PathJoinSubstitution +from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc -from test_utils import SimulationTestNode, mecanum_test from test_ign_kill_utils import kill_ign_linux_processes -from threading import Thread +from test_utils import SimulationTestNode, mecanum_test @launch_pytest.fixture def generate_test_description(): - rosbot_xl_gazebo = get_package_share_directory("rosbot_xl_gazebo") + rosbot_xl_gazebo = FindPackageShare("rosbot_xl_gazebo") simulation_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( @@ -47,7 +47,7 @@ def generate_test_description(): "mecanum": "True", "world": PathJoinSubstitution( [ - get_package_share_directory("husarion_office_gz"), + FindPackageShare("husarion_gz_worlds"), "worlds", "empty_with_plugins.sdf", ] diff --git a/rosbot_xl_gazebo/test/test_pep257.py b/rosbot_xl_gazebo/test/test_pep257.py index a2c3deb8..4eddb46e 100644 --- a/rosbot_xl_gazebo/test/test_pep257.py +++ b/rosbot_xl_gazebo/test/test_pep257.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_pep257.main import main import pytest +from ament_pep257.main import main @pytest.mark.linter diff --git a/rosbot_xl_gazebo/test/test_utils.py b/rosbot_xl_gazebo/test/test_utils.py index bda96ded..69ebc635 100644 --- a/rosbot_xl_gazebo/test/test_utils.py +++ b/rosbot_xl_gazebo/test/test_utils.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import rclpy -from rclpy.node import Node - from threading import Event +import rclpy from geometry_msgs.msg import Twist from nav_msgs.msg import Odometry +from rclpy.node import Node from sensor_msgs.msg import Imu, JointState diff --git a/rosbot_xl_utils/package.xml b/rosbot_xl_utils/package.xml index c3b38280..18b9cd06 100644 --- a/rosbot_xl_utils/package.xml +++ b/rosbot_xl_utils/package.xml @@ -15,6 +15,8 @@ Jakub Delicat + launch_ros + python3-sh python-periphery-pip python3-pyftdi-pip diff --git a/rosbot_xl_utils/rosbot_xl_utils/flash-firmware.py b/rosbot_xl_utils/rosbot_xl_utils/flash-firmware.py index fa2255a3..2bd30814 100644 --- a/rosbot_xl_utils/rosbot_xl_utils/flash-firmware.py +++ b/rosbot_xl_utils/rosbot_xl_utils/flash-firmware.py @@ -14,10 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sh -import time -import sys import argparse +import sys +import time + +import sh from pyftdi.ftdi import Ftdi # CBUS0 - BOOT0 diff --git a/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py b/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py index ab736fcb..01bb447f 100644 --- a/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py +++ b/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py @@ -14,14 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import subprocess -import os -import sys import argparse -import signal import glob +import os +import signal +import subprocess +import sys + import requests -import ament_index_python.packages +from launch_ros.substitutions import FindPackageShare # Global variable to hold the subprocess reference subproc = None @@ -48,9 +49,7 @@ def download_firmware(firmware_url, firmware_path): def find_firmware_file(): # Find the install directory of 'rosbot_utils' package - package_install_directory = ament_index_python.packages.get_package_share_directory( - "rosbot_xl_utils" - ) + package_install_directory = FindPackageShare("rosbot_xl_utils") # Construct the path to the firmware directory firmware_dir = os.path.join(package_install_directory, "firmware") diff --git a/rosbot_xl_utils/setup.py b/rosbot_xl_utils/setup.py index 19226e38..8cc01d7e 100644 --- a/rosbot_xl_utils/setup.py +++ b/rosbot_xl_utils/setup.py @@ -14,6 +14,7 @@ import os from glob import glob + from setuptools import find_packages, setup package_name = "rosbot_xl_utils" diff --git a/rosbot_xl_utils/test/test_copyright.py b/rosbot_xl_utils/test/test_copyright.py index 95f03810..60c2d1e6 100644 --- a/rosbot_xl_utils/test/test_copyright.py +++ b/rosbot_xl_utils/test/test_copyright.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_copyright.main import main import pytest +from ament_copyright.main import main # Remove the `skip` decorator once the source file(s) have a copyright header diff --git a/rosbot_xl_utils/test/test_flake8.py b/rosbot_xl_utils/test/test_flake8.py index 49c1644f..22fffcb8 100644 --- a/rosbot_xl_utils/test/test_flake8.py +++ b/rosbot_xl_utils/test/test_flake8.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_flake8.main import main_with_errors import pytest +from ament_flake8.main import main_with_errors @pytest.mark.flake8 diff --git a/rosbot_xl_utils/test/test_pep257.py b/rosbot_xl_utils/test/test_pep257.py index a2c3deb8..4eddb46e 100644 --- a/rosbot_xl_utils/test/test_pep257.py +++ b/rosbot_xl_utils/test/test_pep257.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_pep257.main import main import pytest +from ament_pep257.main import main @pytest.mark.linter From e1597acc884564c267bb450eb0f84ba45156bc3c Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Mon, 6 May 2024 17:37:36 +0200 Subject: [PATCH 2/9] fix depend --- rosbot_xl_gazebo/package.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/rosbot_xl_gazebo/package.xml b/rosbot_xl_gazebo/package.xml index 2b3c05bb..12ca19ee 100644 --- a/rosbot_xl_gazebo/package.xml +++ b/rosbot_xl_gazebo/package.xml @@ -26,6 +26,7 @@ rosbot_xl_bringup husarion_gz_worlds + ros_gz_sim From 5e9196ebf6586d31a3610420a7399c3ca2cb4702 Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Mon, 6 May 2024 17:57:31 +0200 Subject: [PATCH 3/9] typo --- rosbot_xl_gazebo/launch/simulation.launch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rosbot_xl_gazebo/launch/simulation.launch.py b/rosbot_xl_gazebo/launch/simulation.launch.py index 05c1a458..7cc0ac61 100644 --- a/rosbot_xl_gazebo/launch/simulation.launch.py +++ b/rosbot_xl_gazebo/launch/simulation.launch.py @@ -52,7 +52,7 @@ def launch_setup(context, *args, **kwargs): PythonLaunchDescriptionSource( PathJoinSubstitution( [ - FindPackageShare("husarion_gz_worlds"), + FindPackageShare("ros_gz_sim"), "launch", "gz_sim.launch.py", ] From 01623368bc278b1a707d8b4d3547962615099da1 Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Mon, 6 May 2024 19:40:37 +0200 Subject: [PATCH 4/9] flatten dir --- .gitignore | 2 +- rosbot_xl/rosbot_xl_simulation.repos | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0b3d8fbd..d2a34100 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ __pycache__/ rosbot_hardware_interfaces/ ros_components_description/ rosbot_controllers/ -husarion/husarion_gz_worlds +husarion_gz_worlds micro-ROS-Agent/ micro_ros_msgs/ industrial_ci/ diff --git a/rosbot_xl/rosbot_xl_simulation.repos b/rosbot_xl/rosbot_xl_simulation.repos index 8bdcbbae..bded3899 100644 --- a/rosbot_xl/rosbot_xl_simulation.repos +++ b/rosbot_xl/rosbot_xl_simulation.repos @@ -1,5 +1,5 @@ repositories: - husarion/husarion_gz_worlds: + husarion_gz_worlds: type: git url: https://github.com/husarion/husarion_gz_worlds version: main From e645eac574593f41b53d62453c01267ab6d038ed Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Wed, 8 May 2024 13:42:29 +0200 Subject: [PATCH 5/9] fix --- rosbot_xl_bringup/launch/combined.launch.py | 10 ++++++++-- rosbot_xl_controller/test/test_xacro.py | 7 ++++--- rosbot_xl_gazebo/package.xml | 1 + rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py | 6 ++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/rosbot_xl_bringup/launch/combined.launch.py b/rosbot_xl_bringup/launch/combined.launch.py index f41dbcea..ce39e541 100644 --- a/rosbot_xl_bringup/launch/combined.launch.py +++ b/rosbot_xl_bringup/launch/combined.launch.py @@ -23,7 +23,11 @@ SetEnvironmentVariable, ) from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration, ThisLaunchFileDir +from launch.substitutions import ( + LaunchConfiguration, + PathJoinSubstitution, + ThisLaunchFileDir, +) from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare @@ -130,7 +134,9 @@ def generate_launch_description(): package_dir = FindPackageShare("rosbot_xl_bringup").find("rosbot_xl_bringup") # Construct the path to the XML file within the package - fastrtps_profiles_file = os.path.join(package_dir, "config", "microros_localhost_only.xml") + fastrtps_profiles_file = PathJoinSubstitution( + [package_dir, "config", "microros_localhost_only.xml"] + ) declare_localhost_only_fastrtps_profiles_file_arg = DeclareLaunchArgument( "localhost_only_fastrtps_profiles_file", diff --git a/rosbot_xl_controller/test/test_xacro.py b/rosbot_xl_controller/test/test_xacro.py index ec6a8fd4..afa9485b 100644 --- a/rosbot_xl_controller/test/test_xacro.py +++ b/rosbot_xl_controller/test/test_xacro.py @@ -13,9 +13,9 @@ # limitations under the License. import itertools -import os import xacro +from launch.substitutions import PathJoinSubstitution from launch_ros.substitutions import FindPackageShare @@ -69,8 +69,9 @@ def test_rosbot_description_parsing(): "lidar_model": lidar_model, "camera_model": camera_model, } - rosbot_xl_description = FindPackageShare("rosbot_xl_description") - xacro_path = os.path.join(rosbot_xl_description, "urdf/rosbot_xl.urdf.xacro") + xacro_path = PathJoinSubstitution( + [FindPackageShare("rosbot_xl_description"), "urdf", "rosbot_xl.urdf.xacro"] + ) try: xacro.process_file(xacro_path, mappings=mappings) except xacro.XacroException as e: diff --git a/rosbot_xl_gazebo/package.xml b/rosbot_xl_gazebo/package.xml index 12ca19ee..cde7d192 100644 --- a/rosbot_xl_gazebo/package.xml +++ b/rosbot_xl_gazebo/package.xml @@ -22,6 +22,7 @@ ros2launch launch launch_ros + ament_index_python rosbot_xl_bringup husarion_gz_worlds diff --git a/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py b/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py index 01bb447f..5ce127a3 100644 --- a/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py +++ b/rosbot_xl_utils/rosbot_xl_utils/flash_firmware.py @@ -21,8 +21,8 @@ import subprocess import sys +import ament_index_python.packages import requests -from launch_ros.substitutions import FindPackageShare # Global variable to hold the subprocess reference subproc = None @@ -49,7 +49,9 @@ def download_firmware(firmware_url, firmware_path): def find_firmware_file(): # Find the install directory of 'rosbot_utils' package - package_install_directory = FindPackageShare("rosbot_xl_utils") + package_install_directory = ament_index_python.packages.get_package_share_directory( + "rosbot_xl_utils" + ) # Construct the path to the firmware directory firmware_dir = os.path.join(package_install_directory, "firmware") From 0b9dd52eac49fbca6fcb2f9038b3e9d5eb7ce5dd Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Wed, 8 May 2024 14:00:55 +0200 Subject: [PATCH 6/9] test_xacro --- rosbot_xl_controller/test/test_xacro.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rosbot_xl_controller/test/test_xacro.py b/rosbot_xl_controller/test/test_xacro.py index afa9485b..465265c5 100644 --- a/rosbot_xl_controller/test/test_xacro.py +++ b/rosbot_xl_controller/test/test_xacro.py @@ -13,10 +13,10 @@ # limitations under the License. import itertools +import os import xacro -from launch.substitutions import PathJoinSubstitution -from launch_ros.substitutions import FindPackageShare +from ament_index_python.packages import get_package_share_directory def test_rosbot_description_parsing(): @@ -69,9 +69,8 @@ def test_rosbot_description_parsing(): "lidar_model": lidar_model, "camera_model": camera_model, } - xacro_path = PathJoinSubstitution( - [FindPackageShare("rosbot_xl_description"), "urdf", "rosbot_xl.urdf.xacro"] - ) + rosbot_xl_description = get_package_share_directory("rosbot_xl_description") + xacro_path = os.path.join(rosbot_xl_description, "urdf/rosbot_xl.urdf.xacro") try: xacro.process_file(xacro_path, mappings=mappings) except xacro.XacroException as e: From 44c72aa25d02e880e1a9582fd356b7794d446492 Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Wed, 8 May 2024 14:13:01 +0200 Subject: [PATCH 7/9] Fix tests --- .../test/test_multirobot_diff_drive_simulation.py | 6 +++--- rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py b/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py index b9cc26c4..2cf1792d 100644 --- a/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py +++ b/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py @@ -19,9 +19,9 @@ import launch_pytest import pytest import rclpy +from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import ExecuteProcess -from launch_ros.substitutions import FindPackageShare from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc from rclpy.executors import SingleThreadedExecutor @@ -38,9 +38,9 @@ def generate_test_description(): "launch", "rosbot_xl_gazebo", "simulation.launch.py", - f'world:={FindPackageShare("husarion_gz_worlds")}/worlds/empty_with_plugins.sdf', + f'world:={get_package_share_directory("husarion_gz_worlds")}/worlds/empty_with_plugins.sdf', "robots:=robot1={y: -4.0}; robot2={y: 0.0};", - "headless:=True", + "headless:=False", ], output="screen", ) diff --git a/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py b/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py index 0b6756a2..4ef32e17 100644 --- a/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py +++ b/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py @@ -21,7 +21,7 @@ import rclpy from launch import LaunchDescription from launch.actions import ExecuteProcess -from launch_ros.substitutions import FindPackageShare +from ament_index_python.packages import get_package_share_directory from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc from rclpy.executors import SingleThreadedExecutor @@ -38,7 +38,7 @@ def generate_test_description(): "launch", "rosbot_xl_gazebo", "simulation.launch.py", - f'world:={FindPackageShare("husarion_gz_worlds")}/worlds/empty_with_plugins.sdf', + f'world:={get_package_share_directory("husarion_gz_worlds")}/worlds/empty_with_plugins.sdf', "robots:=robot1={y: -4.0}; robot2={y: 0.0};", "mecanum:=True", "headless:=True", From 7a1090920ab620efb52ea54f1b2e8499472655c2 Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Wed, 8 May 2024 14:28:15 +0200 Subject: [PATCH 8/9] fix --- .../test/test_multirobot_diff_drive_simulation.py | 7 +++++-- .../test/test_multirobot_mecanum_simulation.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py b/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py index 2cf1792d..c5e00ba2 100644 --- a/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py +++ b/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py @@ -38,9 +38,12 @@ def generate_test_description(): "launch", "rosbot_xl_gazebo", "simulation.launch.py", - f'world:={get_package_share_directory("husarion_gz_worlds")}/worlds/empty_with_plugins.sdf', + ( + f'world:={get_package_share_directory("husarion_office_gz")}' + "/worlds/empty_with_plugins.sdf" + ), "robots:=robot1={y: -4.0}; robot2={y: 0.0};", - "headless:=False", + "headless:=True", ], output="screen", ) diff --git a/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py b/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py index 4ef32e17..620fed5e 100644 --- a/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py +++ b/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py @@ -19,9 +19,9 @@ import launch_pytest import pytest import rclpy +from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import ExecuteProcess -from ament_index_python.packages import get_package_share_directory from launch_testing.actions import ReadyToTest from launch_testing.util import KeepAliveProc from rclpy.executors import SingleThreadedExecutor @@ -38,7 +38,10 @@ def generate_test_description(): "launch", "rosbot_xl_gazebo", "simulation.launch.py", - f'world:={get_package_share_directory("husarion_gz_worlds")}/worlds/empty_with_plugins.sdf', + ( + f'world:={get_package_share_directory("husarion_office_gz")}' + "/worlds/empty_with_plugins.sdf" + ), "robots:=robot1={y: -4.0}; robot2={y: 0.0};", "mecanum:=True", "headless:=True", From 3497dccb7fa39c83138298955591fd2e88924b42 Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Wed, 8 May 2024 15:06:30 +0200 Subject: [PATCH 9/9] fix --- rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py | 2 +- rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py b/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py index c5e00ba2..a80176d4 100644 --- a/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py +++ b/rosbot_xl_gazebo/test/test_multirobot_diff_drive_simulation.py @@ -39,7 +39,7 @@ def generate_test_description(): "rosbot_xl_gazebo", "simulation.launch.py", ( - f'world:={get_package_share_directory("husarion_office_gz")}' + f'world:={get_package_share_directory("husarion_gz_worlds")}' "/worlds/empty_with_plugins.sdf" ), "robots:=robot1={y: -4.0}; robot2={y: 0.0};", diff --git a/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py b/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py index 620fed5e..1c73d30c 100644 --- a/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py +++ b/rosbot_xl_gazebo/test/test_multirobot_mecanum_simulation.py @@ -39,7 +39,7 @@ def generate_test_description(): "rosbot_xl_gazebo", "simulation.launch.py", ( - f'world:={get_package_share_directory("husarion_office_gz")}' + f'world:={get_package_share_directory("husarion_gz_worlds")}' "/worlds/empty_with_plugins.sdf" ), "robots:=robot1={y: -4.0}; robot2={y: 0.0};",