From effdee5810a8fd43b2412ad902509b63df0a4abc Mon Sep 17 00:00:00 2001 From: Jakub Delicat <109142865+delihus@users.noreply.github.com> Date: Wed, 7 Aug 2024 11:19:11 +0200 Subject: [PATCH] Jazzy devel (#113) * Check jazzy Signed-off-by: Jakub Delicat * changed ign to gz | skipped mecanum controller Signed-off-by: Jakub Delicat * skip python-transforms3d-pip Signed-off-by: Jakub Delicat * rosbot_hardware_interfaces jazzy devel version Signed-off-by: Jakub Delicat * build rosbot_utils only when is hardware build Signed-off-by: Jakub Delicat * commit to branch Signed-off-by: Jakub Delicat * hardware jazzy with namespaces Signed-off-by: Jakub Delicat * revert tools Signed-off-by: Jakub Delicat * fix package.xml | jazzy dockerfiles Signed-off-by: Jakub Delicat * Fixed workflow Signed-off-by: Jakub Delicat * Applied precommit Signed-off-by: Jakub Delicat * added mecanum to test_depend Signed-off-by: Jakub Delicat * changed workflow to 24.04 Signed-off-by: Jakub Delicat * fix pip Signed-off-by: Jakub Delicat * detect if running on RPi4 or RPi5 in flashing script --------- Signed-off-by: Jakub Delicat Co-authored-by: dominikn --- .github/workflows/tests.yaml | 18 ++++++------ rosbot/package.xml | 3 +- rosbot/rosbot_hardware.repos | 16 ++++------ .../config/diff_drive_controller.yaml | 3 +- .../config/mecanum_drive_controller.yaml | 3 +- rosbot_controller/launch/controller.launch.py | 12 ++++++-- rosbot_controller/package.xml | 1 + .../urdf/rosbot_macro.urdf.xacro | 6 ++-- rosbot_description/urdf/wheel.urdf.xacro | 28 +++++++++--------- rosbot_gazebo/package.xml | 4 +-- rosbot_utils/rosbot_utils/flash-firmware.py | 29 ++++++++++++++++--- rosbot_utils/rosbot_utils/flash_firmware.py | 11 +++---- tools/Dockerfile | 2 +- tools/Dockerfile.dev | 2 +- 14 files changed, 81 insertions(+), 57 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e8803988..9e565b73 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,7 +8,7 @@ on: jobs: black: name: Black - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@v3 @@ -19,7 +19,7 @@ jobs: spellcheck: name: Spellcheck - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@v3 @@ -28,12 +28,12 @@ jobs: industrial_ci: name: Industrial CI - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 timeout-minutes: 30 strategy: fail-fast: false matrix: - ROS_DISTRO: [humble] + ROS_DISTRO: [jazzy] steps: - name: Checkout uses: actions/checkout@v3 @@ -49,19 +49,19 @@ jobs: python3 -m pip install -U vcstool vcs import src < src/rosbot/rosbot_hardware.repos vcs import src < src/rosbot/rosbot_simulation.repos - cp -r src/ros2_controllers/diff_drive_controller src/ - cp -r src/ros2_controllers/imu_sensor_broadcaster src/ - rm -rf src/ros2_controllers # Package micro_ros_msgs does not have industrial ci and tests does not pass. # For more information see https://github.com/micro-ROS/micro_ros_msgs/issues/7 - name: Leave only ROSbot tests shell: bash run: | - sed '/if(BUILD_TESTING)/,/endif()/d' src/diff_drive_controller/CMakeLists.txt -i - sed '/if(BUILD_TESTING)/,/endif()/d' src/imu_sensor_broadcaster/CMakeLists.txt -i sed '/if(BUILD_TESTING)/,/endif()/d' src/micro_ros_msgs/CMakeLists.txt -i + - name: Fix pip + shell: bash + run: | + echo -e "[global]\nbreak-system-packages = true" >> ~/.config/pip/pip.conf + - name: Running ROS Industrial CI uses: ros-industrial/industrial_ci@master env: diff --git a/rosbot/package.xml b/rosbot/package.xml index 6533fef6..2a0ee6ef 100644 --- a/rosbot/package.xml +++ b/rosbot/package.xml @@ -18,7 +18,8 @@ rosbot_bringup rosbot_controller rosbot_description - rosbot_utils + + rosbot_utils rosbot_gazebo diff --git a/rosbot/rosbot_hardware.repos b/rosbot/rosbot_hardware.repos index 374a0c6d..1033c438 100644 --- a/rosbot/rosbot_hardware.repos +++ b/rosbot/rosbot_hardware.repos @@ -1,8 +1,9 @@ repositories: + # jazzy-devel rosbot_hardware_interfaces: type: git url: https://github.com/husarion/rosbot_hardware_interfaces.git - version: main + version: jazzy-devel ros_components_description: type: git url: https://github.com/husarion/ros_components_description.git @@ -10,19 +11,12 @@ repositories: husarion_controllers: type: git url: https://github.com/husarion/husarion_controllers - version: 217b09830f5f42930098b9992eda41710702b625 - # Waiting for backporting to the humble version - # https://github.com/ros-controls/ros2_controllers/pull/726 and - # https://github.com/ros-controls/ros2_controllers/pull/831 - ros2_controllers: - type: git - url: https://github.com/delihus/ros2_controllers - version: humble + version: jazzy micro_ros_msgs: type: git url: https://github.com/micro-ROS/micro_ros_msgs.git - version: humble + version: jazzy micro-ROS-Agent: type: git url: https://github.com/micro-ROS/micro-ROS-Agent.git - version: humble + version: jazzy diff --git a/rosbot_controller/config/diff_drive_controller.yaml b/rosbot_controller/config/diff_drive_controller.yaml index cd723b26..236a394d 100644 --- a/rosbot_controller/config/diff_drive_controller.yaml +++ b/rosbot_controller/config/diff_drive_controller.yaml @@ -15,7 +15,7 @@ tf_frame_prefix_enable: false use_namespace_as_sensor_name_prefix: true - sensor_name: imu + sensor_name: /imu frame_id: imu_link static_covariance_orientation: [1.9e-3, 0.0, 0.0, 0.0, 1.9e-3, 0.0, 0.0, 0.0, 1.9e-3] # Values taken from datasheet static_covariance_angular_velocity: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0e-3] # Values measured experimentally @@ -60,7 +60,6 @@ cmd_vel_timeout: 0.5 #publish_limited_velocity: true - use_stamped_vel: false # Velocity and acceleration limits # Whenever a min_* is unspecified, default to -max_* diff --git a/rosbot_controller/config/mecanum_drive_controller.yaml b/rosbot_controller/config/mecanum_drive_controller.yaml index 4dc3691b..766a80dd 100644 --- a/rosbot_controller/config/mecanum_drive_controller.yaml +++ b/rosbot_controller/config/mecanum_drive_controller.yaml @@ -15,7 +15,7 @@ tf_frame_prefix_enable: false use_namespace_as_sensor_name_prefix: true - sensor_name: imu + sensor_name: /imu frame_id: imu_link static_covariance_orientation: [1.9e-3, 0.0, 0.0, 0.0, 1.9e-3, 0.0, 0.0, 0.0, 1.9e-3] # Values taken from datasheet static_covariance_angular_velocity: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0e-3] # Values based on diff_drive @@ -59,7 +59,6 @@ cmd_vel_timeout: 0.5 #publish_limited_velocity: true - use_stamped_vel: false # Velocity and acceleration limits # Whenever a min_* is unspecified, default to -max_* diff --git a/rosbot_controller/launch/controller.launch.py b/rosbot_controller/launch/controller.launch.py index 8351d695..6693d2c8 100644 --- a/rosbot_controller/launch/controller.launch.py +++ b/rosbot_controller/launch/controller.launch.py @@ -25,6 +25,7 @@ ) from launch_ros.actions import Node, SetParameter from launch_ros.substitutions import FindPackageShare +from nav2_common.launch import ReplaceString def generate_launch_description(): @@ -109,7 +110,7 @@ def generate_launch_description(): ) robot_description = {"robot_description": robot_description_content} - robot_controllers = PathJoinSubstitution( + robot_controllers_config = PathJoinSubstitution( [ FindPackageShare("rosbot_controller"), "config", @@ -117,18 +118,23 @@ def generate_launch_description(): ] ) + namespaced_robot_controllers_config = ReplaceString( + source_file=robot_controllers_config, + replacements={"": namespace, "//": "/"}, + ) + control_node = Node( package="controller_manager", executable="ros2_control_node", parameters=[ robot_description, - robot_controllers, + namespaced_robot_controllers_config, ], remappings=[ ("imu_sensor_node/imu", "/_imu/data_raw"), ("~/motors_cmd", "/_motors_cmd"), ("~/motors_response", "/_motors_response"), - ("rosbot_base_controller/cmd_vel_unstamped", "cmd_vel"), + ("rosbot_base_controller/cmd_vel", "cmd_vel"), ("/tf", "tf"), ("/tf_static", "tf_static"), ], diff --git a/rosbot_controller/package.xml b/rosbot_controller/package.xml index 608a0348..d8f8cd81 100644 --- a/rosbot_controller/package.xml +++ b/rosbot_controller/package.xml @@ -17,6 +17,7 @@ launch launch_ros + nav2_common xacro controller_manager diff --git a/rosbot_description/urdf/rosbot_macro.urdf.xacro b/rosbot_description/urdf/rosbot_macro.urdf.xacro index 48b30f2c..cc891462 100644 --- a/rosbot_description/urdf/rosbot_macro.urdf.xacro +++ b/rosbot_description/urdf/rosbot_macro.urdf.xacro @@ -70,7 +70,7 @@ - ign_ros2_control/IgnitionSystem + gz_ros2_control/GazeboSimSystem webots_ros2_control::Ros2ControlSystem @@ -121,7 +121,7 @@ - + $(find rosbot_controller)/config/mecanum_drive_controller.yaml @@ -134,7 +134,7 @@ ${namespace} - rosbot_base_controller/cmd_vel_unstamped:=cmd_vel + rosbot_base_controller/cmd_vel:=cmd_vel /tf:=tf diff --git a/rosbot_description/urdf/wheel.urdf.xacro b/rosbot_description/urdf/wheel.urdf.xacro index e9d5057e..6f88e481 100644 --- a/rosbot_description/urdf/wheel.urdf.xacro +++ b/rosbot_description/urdf/wheel.urdf.xacro @@ -90,19 +90,21 @@ - - - - - - 1.0 - 0.0 - ${fdir} - - - - - + + + + + + + 1.0 + 0.0 + ${fdir} + + + + + + diff --git a/rosbot_gazebo/package.xml b/rosbot_gazebo/package.xml index e45d4845..aa9952ed 100644 --- a/rosbot_gazebo/package.xml +++ b/rosbot_gazebo/package.xml @@ -26,7 +26,7 @@ version can chosen using GZ_VERSION (or IGNITION_VERSION) env variable, for details refer to the ros_gz_sim package --> ros_gz_bridge - ign_ros2_control + gz_ros2_control nav2_common python3-pytest @@ -35,7 +35,7 @@ launch_pytest tf_transformations - python-transforms3d-pip + nav_msgs geometry_msgs diff --git a/rosbot_utils/rosbot_utils/flash-firmware.py b/rosbot_utils/rosbot_utils/flash-firmware.py index 9257ecd9..10f0901f 100755 --- a/rosbot_utils/rosbot_utils/flash-firmware.py +++ b/rosbot_utils/rosbot_utils/flash-firmware.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # Copyright 2024 Husarion sp. z o.o. # @@ -25,6 +25,20 @@ import gpiod import sh +def get_raspberry_pi_model(): + try: + with open("/proc/cpuinfo", "r") as f: + for line in f: + if "Model" in line: + model_info = line.split(":")[1].strip() + if "Raspberry Pi 4" in model_info: + return "Raspberry Pi 4" + elif "Raspberry Pi 5" in model_info: + return "Raspberry Pi 5" + else: + return "Unknown Raspberry Pi Model" + except FileNotFoundError: + return "Not a Raspberry Pi" class FirmwareFlasher: def __init__(self, sys_arch, binary_file): @@ -53,12 +67,19 @@ def __init__(self, sys_arch, binary_file): elif self.sys_arch == "aarch64": # Setups RPi pins - print("Device: RPi\n") + model = get_raspberry_pi_model() + print(f"Device: {model}\n") self.serial_port = "/dev/ttyAMA0" - gpio_chip = "/dev/gpiochip0" + + if model == "Raspberry Pi 4": + gpio_chip = "/dev/gpiochip0" + elif model == "Raspberry Pi 5": + gpio_chip = "/dev/gpiochip4" + else: + gpio_chip = "/dev/gpiochip0" # Default or error handling + boot0_pin_no = 17 reset_pin_no = 18 - else: print("Unknown device...") diff --git a/rosbot_utils/rosbot_utils/flash_firmware.py b/rosbot_utils/rosbot_utils/flash_firmware.py index 078f6922..cbaeaa77 100755 --- a/rosbot_utils/rosbot_utils/flash_firmware.py +++ b/rosbot_utils/rosbot_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 requests +import os +import signal +import subprocess +import sys + import ament_index_python.packages +import requests # Global variable to hold the subprocess reference subproc = None diff --git a/tools/Dockerfile b/tools/Dockerfile index b10f8516..ebbecb14 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -1,4 +1,4 @@ -ARG ROS_DISTRO=humble +ARG ROS_DISTRO=jazzy ARG PREFIX= ARG ROSBOT_FW_RELEASE=0.8.0 diff --git a/tools/Dockerfile.dev b/tools/Dockerfile.dev index 76ff00e0..b69bfd27 100644 --- a/tools/Dockerfile.dev +++ b/tools/Dockerfile.dev @@ -1,4 +1,4 @@ -ARG ROS_DISTRO=humble +ARG ROS_DISTRO=jazzy ARG PREFIX= ARG HUSARION_ROS_BUILD_TYPE=hardware