diff --git a/.wordlist.txt b/.wordlist.txt index 35d0089a..e5989fd3 100644 --- a/.wordlist.txt +++ b/.wordlist.txt @@ -150,4 +150,11 @@ subprocess cbus Dockerfile unbuffered +libgpiod +REQ +gpiochip +gpiod +Rafal +Gorecki +gpiozero sp diff --git a/README.md b/README.md index 4005723d..89e66015 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,27 @@ # Rosbot ROS + ROS2 packages for ROSbot 2R and ROSbot 2 PRO. ## ROS packages + ### `rosbot` + Metapackage that contains dependencies to other repositories. ### `rosbot_bringup` + Package that contains launch, which starts all base functionalities. Also configuration for [robot_localization](https://github.com/cra-ros-pkg/robot_localization) and [ros2_controllers](https://github.com/ros-controls/ros2_controllers) are defined there. ### `rosbot_description` + URDF model used as a source of transforms on the physical robot. It was written to be compatible with ROS Industrial and preconfigured for ROS2 control. ### `rosbot_gazebo` + Launch files for Ignition Gazebo working with ROS2 control. ### `rosbot_controller` + ROS2 hardware controllers configuration for ROSbots. ## ROS API @@ -31,14 +38,16 @@ For detailed instructions refer to the [rosbot_ros2_firmware repository](https:/ ### Prerequisites -Install `colcon`, `vcs` and `rosdep`: -``` +Install all necessary tools: + +```bash sudo apt-get update -sudo apt-get install -y python3-colcon-common-extensions python3-vcstool python3-rosdep python3-pip +sudo apt-get install -y ros-dev-tools python3-pip ``` Create workspace folder and clone `rosbot_ros` repository: -``` + +```bash mkdir -p ros2_ws/src cd ros2_ws git clone https://github.com/husarion/rosbot_ros src/ @@ -47,7 +56,8 @@ git clone https://github.com/husarion/rosbot_ros src/ ### Build and run on hardware Building: -``` + +```bash export HUSARION_ROS_BUILD=hardware source /opt/ros/$ROS_DISTRO/setup.bash @@ -65,31 +75,44 @@ rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release ``` -> **Prerequisites** -> -> Before starting the software on the robot please make sure that you're using the latest firmware and run the `micro-ROS` agent (as described in the *Usage on hardware* step). +Flash firmware: -Running: +```bash +source install/setup.bash +ros2 launch rosbot_utils flash_firmware ``` + +Running: + +```bash source install/setup.bash -ros2 launch rosbot_bringup bringup.launch.py +ros2 launch rosbot_bringup combined.launch.py ``` ### Build and run Gazebo simulation + Prerequisites: -> **Warning** -> The simulation is compatible with the Gazebo Fortress LTS version. Use [this installation guide ](https://gazebosim.org/docs/fortress/install_ubuntu#binary-installation-on-ubuntu) to install the proper version and remove the another versions e. g. Gazebo Garden: -> `sudo apt remove gz-garden && sudo apt autoremove` -> Look at [the table](https://gazebosim.org/docs/garden/ros_installation#summary-of-compatible-ros-and-gazebo-combinations) to see the compatible ROS 2 and Gazebo versions. +> [!TIP] +> The default version of Gazebo Ignition will be installed with the instructions below. If you want to install a different version of the simulator, it is necessary to: +> +> - Check compatible versions of ROS 2 and Gazebo in [this table](https://gazebosim.org/docs/garden/ros_installation#summary-of-compatible-ros-and-gazebo-combinations) +> - [Install the appropriate version](https://gazebosim.org/docs/fortress/install_ubuntu#binary-installation-on-ubuntu), +> - Add the `GZ_VERSION` environment variable appropriate to your version +> +> ```bash +> export GZ_VERSION=fortress +> ``` If you have installed multiple versions of Gazebo use the global variable to select the correct one: + ```bash export GZ_VERSION=fortress ``` Building: -``` + +```bash export HUSARION_ROS_BUILD=simulation source /opt/ros/$ROS_DISTRO/setup.bash @@ -107,14 +130,16 @@ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release ``` Running: -``` + +```bash source install/setup.bash ros2 launch rosbot_gazebo simulation.launch.py ``` -## Testing package +## Developer info ### pre-commit + [pre-commit configuration](.pre-commit-config.yaml) prepares plenty of tests helping for developing and contributing. Usage: ```bash @@ -131,7 +156,8 @@ pre-commit run -a After initialization [pre-commit configuration](.pre-commit-config.yaml) will applied on every commit. ### Industrial CI -``` + +```bash colcon test ``` @@ -139,12 +165,14 @@ colcon test > Command `colcon test` does not build the code. Remember to build your code after changes. If tests finish with errors print logs: -``` + +``` bash colcon test-result --verbose ``` ### Format python code with [Black](https://github.com/psf/black) -``` + +```bash cd src/ black rosbot* ``` @@ -153,18 +181,19 @@ black rosbot* At fist install [act](https://github.com/nektos/act): -``` +```bash cd / curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash ``` And test the workflow with: -``` +```bash act -W .github/workflows/industrial_ci.yaml ``` ## Demo + Below you can find demos with ROSbots: | link | description | | - | - | diff --git a/rosbot/CHANGELOG.rst b/rosbot/CHANGELOG.rst index 40050071..4123426a 100644 --- a/rosbot/CHANGELOG.rst +++ b/rosbot/CHANGELOG.rst @@ -2,9 +2,6 @@ Changelog for package rosbot ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0.10.5 (2023-12-05) -------------------- - 0.13.0 (2024-01-15) ------------------- @@ -17,6 +14,9 @@ Changelog for package rosbot 0.11.0 (2023-12-08) ------------------- +0.10.5 (2023-12-05) +------------------- + 0.10.4 (2023-12-01) ------------------- diff --git a/rosbot/package.xml b/rosbot/package.xml index ad282059..38eeae28 100644 --- a/rosbot/package.xml +++ b/rosbot/package.xml @@ -3,27 +3,24 @@ rosbot 0.13.0 - Meta package that contains all packages of Rosbot 2 2R PRO - Apache License 2.0 - - Jakub Delicat Husarion + Apache License 2.0 https://husarion.com/ https://github.com/husarion/rosbot_ros https://github.com/husarion/rosbot_ros/issues + Jakub Delicat + ament_cmake rosbot_bringup - rosbot_description rosbot_controller + rosbot_description rosbot_utils - - rosbot_gazebo - + rosbot_gazebo ament_cmake diff --git a/rosbot_bringup/CHANGELOG.rst b/rosbot_bringup/CHANGELOG.rst index eca7786a..8942298e 100644 --- a/rosbot_bringup/CHANGELOG.rst +++ b/rosbot_bringup/CHANGELOG.rst @@ -2,9 +2,6 @@ Changelog for package rosbot_bringup ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0.10.5 (2023-12-05) -------------------- - 0.13.0 (2024-01-15) ------------------- @@ -17,6 +14,9 @@ Changelog for package rosbot_bringup 0.11.0 (2023-12-08) ------------------- +0.10.5 (2023-12-05) +------------------- + 0.10.4 (2023-12-01) ------------------- diff --git a/rosbot_bringup/package.xml b/rosbot_bringup/package.xml index b6a269ba..6b64f32b 100644 --- a/rosbot_bringup/package.xml +++ b/rosbot_bringup/package.xml @@ -4,20 +4,22 @@ rosbot_bringup 0.13.0 ROSbot 2, 2R, PRO bringup package - Apache License 2.0 - - Jakub Delicat Husarion + Apache License 2.0 https://husarion.com/ https://github.com/husarion/rosbot_ros https://github.com/husarion/rosbot_ros/issues + Jakub Delicat + Rafal Gorecki + launch launch_ros rosbot_controller robot_localization micro_ros_agent + micro_ros_msgs python3-pytest launch diff --git a/rosbot_controller/CHANGELOG.rst b/rosbot_controller/CHANGELOG.rst index 257a0b98..0410b053 100644 --- a/rosbot_controller/CHANGELOG.rst +++ b/rosbot_controller/CHANGELOG.rst @@ -2,9 +2,6 @@ Changelog for package rosbot_controller ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0.10.5 (2023-12-05) -------------------- - 0.13.0 (2024-01-15) ------------------- @@ -17,6 +14,9 @@ Changelog for package rosbot_controller 0.11.0 (2023-12-08) ------------------- +0.10.5 (2023-12-05) +------------------- + 0.10.4 (2023-12-01) ------------------- diff --git a/rosbot_controller/package.xml b/rosbot_controller/package.xml index 9d30ccdb..a3c22949 100644 --- a/rosbot_controller/package.xml +++ b/rosbot_controller/package.xml @@ -3,17 +3,16 @@ rosbot_controller 0.13.0 - Hardware configuration for ROSbot 2, 2R, PRO + Husarion Apache License 2.0 - Jakub Delicat - Husarion - https://husarion.com/ https://github.com/husarion/rosbot_ros https://github.com/husarion/rosbot_ros/issues + Jakub Delicat + ament_cmake launch diff --git a/rosbot_description/CHANGELOG.rst b/rosbot_description/CHANGELOG.rst index 08d2a258..ab24988d 100644 --- a/rosbot_description/CHANGELOG.rst +++ b/rosbot_description/CHANGELOG.rst @@ -2,9 +2,6 @@ Changelog for package rosbot_description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0.10.5 (2023-12-05) -------------------- - 0.13.0 (2024-01-15) ------------------- @@ -17,6 +14,9 @@ Changelog for package rosbot_description 0.11.0 (2023-12-08) ------------------- +0.10.5 (2023-12-05) +------------------- + 0.10.4 (2023-12-01) ------------------- diff --git a/rosbot_description/package.xml b/rosbot_description/package.xml index 3e9b0a43..449e537f 100644 --- a/rosbot_description/package.xml +++ b/rosbot_description/package.xml @@ -3,18 +3,17 @@ rosbot_description 0.13.0 - ROSbot 2, 2R, PRO description package + Husarion Apache License 2.0 - Jakub Delicat - Maciej Stepien - Husarion - https://husarion.com/ https://github.com/husarion/rosbot_ros https://github.com/husarion/rosbot_ros/issues + Jakub Delicat + Maciej Stepien + ament_cmake diff --git a/rosbot_gazebo/CHANGELOG.rst b/rosbot_gazebo/CHANGELOG.rst index c71a9853..1b99e9ee 100644 --- a/rosbot_gazebo/CHANGELOG.rst +++ b/rosbot_gazebo/CHANGELOG.rst @@ -2,9 +2,6 @@ Changelog for package rosbot_gazebo ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -0.10.5 (2023-12-05) -------------------- - 0.13.0 (2024-01-15) ------------------- @@ -20,6 +17,9 @@ Changelog for package rosbot_gazebo Test gazebo fix * Contributors: Dominik Nowak +0.10.5 (2023-12-05) +------------------- + 0.10.4 (2023-12-01) ------------------- diff --git a/rosbot_gazebo/package.xml b/rosbot_gazebo/package.xml index 00b3993c..a684dea4 100644 --- a/rosbot_gazebo/package.xml +++ b/rosbot_gazebo/package.xml @@ -3,18 +3,18 @@ rosbot_gazebo 0.13.0 - Gazebo Ignition simulation for ROSbot 2, 2R, PRO - Apache License 2.0 - - Jakub Delicat - Krzysztof Wojciechowski Husarion + Apache License 2.0 https://husarion.com/ https://github.com/husarion/rosbot_ros https://github.com/husarion/rosbot_ros/issues + Jakub Delicat + Rafal Gorecki + Krzysztof Wojciechowski + rosbot_bringup launch diff --git a/rosbot_utils/package.xml b/rosbot_utils/package.xml index a78e35ea..9dd137df 100644 --- a/rosbot_utils/package.xml +++ b/rosbot_utils/package.xml @@ -4,21 +4,23 @@ rosbot_utils 0.13.0 Utilities for ROSbot 2R and 2 PRO - Apache License 2.0 - - Dominik Nowak Husarion + Apache License 2.0 https://husarion.com/ https://github.com/husarion/rosbot_ros https://github.com/husarion/rosbot_ros/issues - python3-sh - python-periphery-pip + Dominik Nowak + Jakub Delicat + Rafal Gorecki + + python3-libgpiod python3-pyftdi-pip - usbutils - python3-serial python3-requests + python3-serial + python3-sh + usbutils ament_copyright ament_flake8 diff --git a/rosbot_utils/rosbot_utils/flash-firmware.py b/rosbot_utils/rosbot_utils/flash-firmware.py index a9ec359f..cd36c3a2 100755 --- a/rosbot_utils/rosbot_utils/flash-firmware.py +++ b/rosbot_utils/rosbot_utils/flash-firmware.py @@ -22,7 +22,7 @@ import time import sys import argparse -from periphery import GPIO +import gpiod class FirmwareFlasher: @@ -34,51 +34,58 @@ def __init__(self, sys_arch, binary_file): print(f"System architecture: {self.sys_arch}") - if self.sys_arch.stdout == b"armv7l\n": + if self.sys_arch == "armv7l": # Setups ThinkerBoard pins print("Device: ThinkerBoard\n") - self.port = "/dev/ttyS1" + self.serial_port = "/dev/ttyS1" + gpio_chip = "/dev/gpiochip0" boot0_pin_no = 164 reset_pin_no = 184 - elif self.sys_arch.stdout == b"x86_64\n": + elif self.sys_arch == "x86_64": # Setups UpBoard pins print("Device: UpBoard\n") - self.port = "/dev/ttyS4" + self.serial_port = "/dev/ttyS4" + gpio_chip = "/dev/gpiochip4" boot0_pin_no = 17 reset_pin_no = 18 - elif self.sys_arch.stdout == b"aarch64\n": + elif self.sys_arch == "aarch64": # Setups RPi pins print("Device: RPi\n") - self.port = "/dev/ttyAMA0" + self.serial_port = "/dev/ttyAMA0" + gpio_chip = "/dev/gpiochip0" boot0_pin_no = 17 reset_pin_no = 18 else: print("Unknown device...") - self.boot0_pin = GPIO(boot0_pin_no, "out") - self.reset_pin = GPIO(reset_pin_no, "out") + chip = gpiod.Chip(gpio_chip) + self.boot0_pin = chip.get_line(boot0_pin_no) + self.reset_pin = chip.get_line(reset_pin_no) + + self.boot0_pin.request("Flash", type=gpiod.LINE_REQ_DIR_OUT, default_val=False) + self.reset_pin.request("Flash", type=gpiod.LINE_REQ_DIR_OUT, default_val=False) def enter_bootloader_mode(self): - self.boot0_pin.write(True) - self.reset_pin.write(True) + self.boot0_pin.set_value(1) + self.reset_pin.set_value(1) time.sleep(0.2) - self.reset_pin.write(False) + self.reset_pin.set_value(0) time.sleep(0.2) def exit_bootloader_mode(self): - self.boot0_pin.write(False) - self.reset_pin.write(True) + self.boot0_pin.set_value(0) + self.reset_pin.set_value(1) time.sleep(0.2) - self.reset_pin.write(False) + self.reset_pin.set_value(0) time.sleep(0.2) def try_flash_operation(self, operation_name, flash_command, flash_args): for i in range(self.max_approach_no): try: - flash_command(self.port, *flash_args, _out=sys.stdout) + flash_command(self.serial_port, *flash_args, _out=sys.stdout) time.sleep(0.2) break except Exception as e: @@ -118,7 +125,7 @@ def main(): ) binary_file = parser.parse_args().file - sys_arch = sh.uname("-m") + sys_arch = sh.uname("-m").stdout.decode().strip() flasher = FirmwareFlasher(sys_arch, binary_file) flasher.flash_firmware() diff --git a/tools/Dockerfile.dev b/tools/Dockerfile.dev index 028806f4..76ff00e0 100644 --- a/tools/Dockerfile.dev +++ b/tools/Dockerfile.dev @@ -1,68 +1,36 @@ ARG ROS_DISTRO=humble ARG PREFIX= -ARG ROSBOT_FW_RELEASE=0.8.0 -## ============================ STM32FLASH ================================= -# stm32flash needs an older version of glibc (2.28), which is why ubuntu 18.04 was used -FROM ubuntu:18.04 AS stm32flash_builder - -ARG ROS_DISTRO -ARG ROSBOT_FW_RELEASE -ARG TARGETARCH - -SHELL ["/bin/bash", "-c"] - -# official releases are only for intel archs, so we need to build stm32flash from sources -RUN apt-get update && apt-get install -y \ - curl - -RUN echo ros_distro=$ROS_DISTRO firmware_release=$ROSBOT_FW_RELEASE - -# Copy firmware binaries -RUN curl -L https://github.com/husarion/stm32flash/releases/download/2023-12-05/stm32flash-$TARGETARCH -o /stm32flash && \ - chmod +x /stm32flash +ARG HUSARION_ROS_BUILD_TYPE=hardware ## =========================== ROS builder =============================== FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-base AS ros_builder ARG ROS_DISTRO ARG PREFIX +ARG HUSARION_ROS_BUILD_TYPE -SHELL ["/bin/bash", "-c"] +ENV HUSARION_ROS_BUILD_TYPE=${HUSARION_ROS_BUILD_TYPE} WORKDIR /ros2_ws RUN mkdir src -COPY rosbot src/rosbot -COPY rosbot_bringup src/rosbot_bringup -COPY rosbot_controller src/rosbot_controller -COPY rosbot_description src/rosbot_description -COPY rosbot_utils src/rosbot_utils +COPY ./ src/ RUN apt-get update && apt-get install -y \ python3-pip \ stm32flash RUN vcs import src < src/rosbot/rosbot_hardware.repos && \ - cp -r src/ros2_controllers/diff_drive_controller src/ && \ - cp -r src/ros2_controllers/imu_sensor_broadcaster src/ && \ - rm -rf src/ros2_controllers && \ - # without this line (using vulcanexus base image) rosdep init throws error: "ERROR: default sources list file already exists:" + if [ "$HUSARION_ROS_BUILD_TYPE" == "simulation" ]; then \ + vcs import src < src/rosbot/rosbot_simulation.repos; \ + else \ + rm -rf src/rosbot_gazebo; \ + fi && \ rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \ rosdep init && \ rosdep update --rosdistro $ROS_DISTRO && \ rosdep install --from-paths src --ignore-src -y -# COPY --from=stm32flash_builder /stm32flash /usr/bin/stm32flash - -# Build RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \ source /opt/$MYDISTRO/$ROS_DISTRO/setup.bash && \ - colcon build --cmake-args --symlink-install - -# copy scripts -# COPY tools/flash-firmware.py / -# COPY tools/flash-firmware.py /usr/bin/ -# COPY tools/flash-firmware-usb.py /usr/bin/ - -HEALTHCHECK --interval=7s --timeout=2s --start-period=5s --retries=5 \ - CMD ["/healthcheck.sh"] + colcon build --packages-up-to rosbot --cmake-args -DCMAKE_BUILD_TYPE=Release