diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..d9aa52060 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.*/ +docker/ diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml new file mode 100644 index 000000000..412b7c574 --- /dev/null +++ b/.github/workflows/build-docker.yaml @@ -0,0 +1,85 @@ +--- +name: Build Docker + +on: + workflow_call: + inputs: + build_type: + description: Is it a "development" or a "stable" release? + required: true + type: string + default: development + target_distro: + description: In case of "stable" release specify the ROS distro of the existing docker image (eg. + humble) + type: string + default: humble + target_release: + description: In case of "stable" release specify the version of the existing docker image (eg. + 1.0.12) + type: string + default: 0.0.0 + target_date: + description: In case of "stable" release specify the date of the existing docker image in format + YYYYMMDD (eg. 20220124) + type: string + default: '20131206' + workflow_dispatch: + inputs: + build_type: + description: Is it a "development" or a "stable" release? + required: true + type: choice + default: development + options: + - development + - stable + target_distro: + description: In case of "stable" release specify the ROS distro of the existing docker image (eg. + humble) + type: string + default: humble + target_release: + description: In case of "stable" release specify the version of the existing docker image (eg. + 1.0.12) + type: string + default: 0.0.0 + target_date: + description: In case of "stable" release specify the date of the existing docker image in format + YYYYMMDD (eg. 20220124) + type: string + default: '20131206' +jobs: + build: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + include: + - dockerfile: ./docker/Dockerfile.hardware + platforms: linux/arm64 + ros_distro: humble + - dockerfile: ./docker/Dockerfile.simulation + repo_name: panther-gazebo + platforms: linux/amd64 + ros_distro: humble + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build Docker Image + uses: husarion-ci/ros-docker-img-action@v0.8 + with: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} + main_branch_name: ros2 + dockerfile: ${{ matrix.dockerfile }} + repo_name: ${{ matrix.repo_name }} + build_type: ${{ inputs.build_type }} + ros_distro: ${{ matrix.ros_distro }} + platforms: ${{ matrix.platforms }} + # variables important only for stable release + target_distro: ${{ inputs.target_distro }} + target_release: ${{ inputs.target_release }} + target_date: ${{ inputs.target_date }} diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 08f7311e1..26c281bf7 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -1,5 +1,5 @@ --- -name: Pre-Commit +name: Pre-commit on: push: diff --git a/.github/workflows/protect-default-branch.yaml b/.github/workflows/protect-default-branch.yaml index 678daebe9..be86e630c 100644 --- a/.github/workflows/protect-default-branch.yaml +++ b/.github/workflows/protect-default-branch.yaml @@ -1,5 +1,5 @@ --- -name: Validate PR head branch +name: Protect Default Branch on: pull_request: branches: diff --git a/.github/workflows/release-candidate.yaml b/.github/workflows/release-candidate.yaml index b06bddd69..53f98a103 100644 --- a/.github/workflows/release-candidate.yaml +++ b/.github/workflows/release-candidate.yaml @@ -1,5 +1,5 @@ --- -name: Release candidate +name: Release Candidate on: workflow_dispatch: @@ -15,121 +15,90 @@ env: RC_BRANCH_NAME: ${{ github.event.inputs.version }}-${{ github.event.inputs.date }} jobs: - check_docs: - name: Check docs build + docs: + name: Docs runs-on: ubuntu-22.04 steps: - - name: Trigger repository build workflow - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Check docs build + uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: husarion repo: docs_new - github_token: ${{ secrets.GH_PAT }} - workflow_file_name: test-release.yml + github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }} + workflow_file_name: test-parser.yaml ref: master client_payload: '{"husarion_ugv_branch": "ros2-devel"}' - # TODO: Add unit testing for panther_ros when ready - unit_test_panther_ros: - name: Run unit tests for panther_ros + # TODO: Add unit testing when ready + unit_tests: + name: Unit tests runs-on: ubuntu-22.04 steps: - - name: Trigger repository build workflow - run: echo "Unit tests for panther_ros are not fully implemented yet -> SKIPPING!" + - name: Run unit tests + run: echo "Unit tests are not fully implemented yet -> SKIPPING!" - create_release_candidate_branches: - name: Create release candidate branches + docker: + name: Docker + needs: unit_tests runs-on: ubuntu-22.04 - needs: - - unit_test_panther_ros - strategy: - matrix: - repo: [panther_ros, panther-docker, panther-rpi-os-img] steps: - - name: Create test branch - uses: GuillaumeFalourd/create-other-repo-branch-action@v1.5 + - name: Checkout + uses: actions/checkout@v4 + + - name: Update docker image tag + run: | + sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.hardware.yaml + sed -i 's/\(husarion\/panther:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.rviz.yaml + sed -i 's/\(husarion\/panther-gazebo:humble-\)[^[:space:]]*/\1${{ env.RC_BRANCH_NAME }}/g' docker/demo/compose.simulation.yaml + + - name: Commit changes + uses: EndBug/add-and-commit@v9 with: - repository_owner: husarion - repository_name: ${{ matrix.repo }} - new_branch_name: ${{ env.RC_BRANCH_NAME }} - new_branch_ref: ros2-devel - access_token: ${{ secrets.GH_PAT}} + message: Update tags in compose files + author_name: action-bot + author_email: action-bot@action-bot.com + new_branch: ${{ env.RC_BRANCH_NAME }} - update_tags_in_compose: - name: Update Docker image tags in compose - runs-on: ubuntu-22.04 - needs: - - create_release_candidate_branches - steps: - - name: Trigger repository build workflow - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Build Docker + uses: ./.github/workflows/build-docker.yaml with: - owner: husarion - repo: panther-docker - github_token: ${{ secrets.GH_PAT }} - workflow_file_name: update-tags-in-compose.yaml - ref: ${{ env.RC_BRANCH_NAME }} - client_payload: | - { - "branch_name": "${{ env.RC_BRANCH_NAME }}", - "image_tag": "humble-${{ env.RC_BRANCH_NAME }}" - } + build_type: development - build_and_push_docker_images: - name: Build panther docker images + os_image: + name: OS image + needs: docker runs-on: ubuntu-22.04 - needs: - - update_tags_in_compose steps: - - name: Trigger repository build workflow - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Create new branch + uses: GuillaumeFalourd/create-other-repo-branch-action@v1.5 with: - owner: husarion - repo: panther-docker - github_token: ${{ secrets.GH_PAT }} - workflow_file_name: ros-docker-image.yaml - ref: ${{ env.RC_BRANCH_NAME }} - client_payload: | - { - "panther_codebase_version": "${{ env.RC_BRANCH_NAME }}", - "build_type": "development", - "target_distro": "humble" - } + repository_owner: husarion + repository_name: panther-rpi-os-img + new_branch_name: ${{ env.RC_BRANCH_NAME }} + new_branch_ref: ros2-devel + access_token: ${{ secrets.RAFAL_ACCESS_TOKEN}} - build_and_publish_rpi_image: - name: Build panther system image - needs: - - update_tags_in_compose - runs-on: ubuntu-22.04 - steps: - - name: Trigger repository build workflow - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Build OS image + uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: husarion repo: panther-rpi-os-img - github_token: ${{ secrets.GH_PAT }} + github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }} workflow_file_name: build_and_deploy_image.yaml ref: ${{ env.RC_BRANCH_NAME }} client_payload: | { "dev_image": "true", - "panther_codebase_version": "${{ env.RC_BRANCH_NAME }}", + "husarion_ugv_version": "${{ env.RC_BRANCH_NAME }}", "image_tag": "${{ github.event.inputs.version }}" } - build_and_publish_rpi_flash_os_image: - name: Build panther flash OS image - if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }} - needs: - - build_and_publish_rpi_image - runs-on: ubuntu-22.04 - steps: - - name: Trigger repository build workflow - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Build flash OS image + uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: husarion repo: panther-rpi-os-img - github_token: ${{ secrets.GH_PAT }} + github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }} workflow_file_name: build_and_deploy_flash_os_image.yaml ref: ${{ env.RC_BRANCH_NAME }} client_payload: | diff --git a/.github/workflows/release-project.yaml b/.github/workflows/release-project.yaml index cc4307e05..da6df49cb 100644 --- a/.github/workflows/release-project.yaml +++ b/.github/workflows/release-project.yaml @@ -1,5 +1,5 @@ --- -name: Release project +name: Release Project on: workflow_dispatch: @@ -31,64 +31,29 @@ env: jobs: release_project: - name: Release Husarion UGV project + name: Release project runs-on: ubuntu-22.04 steps: - - name: Release panther_ros repository - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Release repository + uses: ./.github/workflows/release-repository.yaml with: - owner: husarion - repo: panther_ros - github_token: ${{ secrets.GITHUB_TOKEN }} # Use the default GITHUB_TOKEN for local repository - workflow_file_name: release-repository.yaml - ref: ${{ env.RC_BRANCH_NAME }} - client_payload: | - { - "release_candidate": "${{ env.RC_BRANCH_NAME }}", - "version": "${{ github.event.inputs.version }}", - "release_name": "${{ github.event.inputs.release_name }}", - "automatic_mode": "${{ github.event.inputs.automatic_mode }}", - "prerelease": "${{ github.event.inputs.prerelease }}" - } + release_candidate: ${{ env.RC_BRANCH_NAME }} + version: ${{ github.event.inputs.version }} + release_name: ${{ github.event.inputs.release_name }} + automatic_mode: ${{ github.event.inputs.automatic_mode }} + prerelease: ${{ github.event.inputs.prerelease }} - - name: Rebuild panther docker images with new version - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Build Docker with new version + uses: ./.github/workflows/build-docker.yaml with: - owner: husarion - repo: panther-docker - github_token: ${{ secrets.GH_PAT }} - workflow_file_name: ros-docker-image.yaml - ref: ${{ env.RC_BRANCH_NAME }} - client_payload: | - { - "panther_codebase_version": "${{ github.event.inputs.version }}", - "build_type": "development", - "target_distro": "humble" - } - - - name: Release panther-docker repository - uses: convictional/trigger-workflow-and-wait@v1.6.1 - with: - owner: husarion - repo: panther-docker - github_token: ${{ secrets.GH_PAT }} - workflow_file_name: release-repository.yaml - ref: ${{ env.RC_BRANCH_NAME }} - client_payload: | - { - "release_candidate": "${{ env.RC_BRANCH_NAME }}", - "version": "${{ github.event.inputs.version }}", - "release_name": "${{ github.event.inputs.release_name }}", - "automatic_mode": "${{ github.event.inputs.automatic_mode }}", - "prerelease": "${{ github.event.inputs.prerelease }}" - } + build_type: development - name: Release panther-rpi-os-img repository - uses: convictional/trigger-workflow-and-wait@v1.6.1 + uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: husarion repo: panther-rpi-os-img - github_token: ${{ secrets.GH_PAT }} + github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }} workflow_file_name: release-repository.yaml ref: ${{ env.RC_BRANCH_NAME }} client_payload: | @@ -100,29 +65,29 @@ jobs: "prerelease": "${{ github.event.inputs.prerelease }}" } - - name: Build panther system image + - name: Build OS image if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }} - uses: convictional/trigger-workflow-and-wait@v1.6.1 + uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: husarion repo: panther-rpi-os-img - github_token: ${{ secrets.GH_PAT }} + github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }} workflow_file_name: build_and_deploy_image.yaml ref: ${{ env.MAIN_BRANCH }} client_payload: | { "dev_image": "false", - "panther_codebase_version": "${{ github.event.inputs.version }}", + "husarion_ugv_version": "${{ github.event.inputs.version }}", "image_tag": "${{ github.event.inputs.version }}" } - - name: Build panther flash OS image + - name: Build flash OS image if: ${{ fromJSON(github.event.inputs.automatic_mode) == true }} - uses: convictional/trigger-workflow-and-wait@v1.6.1 + uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: husarion repo: panther-rpi-os-img - github_token: ${{ secrets.GH_PAT }} + github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }} workflow_file_name: build_and_deploy_flash_os_image.yaml ref: ${{ env.MAIN_BRANCH }} client_payload: | @@ -130,11 +95,11 @@ jobs: "image_tag": "${{ github.event.inputs.version }}" } - - name: Trigger repository build workflow - uses: convictional/trigger-workflow-and-wait@v1.6.1 + - name: Rebuild documentation + uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: husarion repo: docs_new - github_token: ${{ secrets.GH_PAT }} + github_token: ${{ secrets.RAFAL_ACCESS_TOKEN }} workflow_file_name: build.yml ref: master diff --git a/.github/workflows/release-repository.yaml b/.github/workflows/release-repository.yaml index 6a58ee2b4..498a304dc 100644 --- a/.github/workflows/release-repository.yaml +++ b/.github/workflows/release-repository.yaml @@ -1,19 +1,22 @@ --- -name: Release repository +name: Release Repository on: - workflow_dispatch: + workflow_call: inputs: release_candidate: description: Branch name of the release candidate. WARNING This branch will be deleted! required: true + type: string version: description: New version (used for tag and package versioning). required: true + type: string release_name: description: Name of the release to be created. Version in the first place is recommended (e.g. `2.0.0-alpha`). required: true + type: string automatic_mode: type: boolean default: false diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/unit-tests.yaml similarity index 98% rename from .github/workflows/run-unit-tests.yaml rename to .github/workflows/unit-tests.yaml index 48c1ebf69..5cfecd9a8 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -1,5 +1,5 @@ --- -name: Run unit tests +name: Unit tests on: workflow_dispatch: @@ -25,7 +25,7 @@ jobs: touch ${{ env.COVERAGE_RESULT_FILENAME }} - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.ref }} path: ros2_ws/src/husarion_ugv diff --git a/docker/Dockerfile.hardware b/docker/Dockerfile.hardware new file mode 100644 index 000000000..bb08a8d96 --- /dev/null +++ b/docker/Dockerfile.hardware @@ -0,0 +1,43 @@ +ARG ROS_DISTRO=humble + +FROM husarnet/ros:${ROS_DISTRO}-ros-core + +ARG BUILD_TEST=OFF + +ENV HUSARION_ROS_BUILD_TYPE=hardware + +STOPSIGNAL SIGINT + +WORKDIR /ros2_ws +COPY . src/husarion_ugv + +RUN apt-get update && \ + apt-get install -y \ + ros-dev-tools && \ + # Setup workspace + vcs import src < src/husarion_ugv/husarion_ugv/${HUSARION_ROS_BUILD_TYPE}_deps.repos && \ + cp -r src/ros2_controllers/diff_drive_controller src && \ + cp -r src/ros2_controllers/imu_sensor_broadcaster src && \ + rm -rf src/ros2_controllers && \ + # Install dependencies + rosdep init && \ + rosdep update --rosdistro $ROS_DISTRO && \ + rosdep install --from-paths src -y -i && \ + # Build + source /opt/ros/$ROS_DISTRO/setup.bash && \ + colcon build --symlink-install --packages-up-to husarion_ugv --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$BUILD_TEST && \ + # Get version + echo $(cat /ros2_ws/src/husarion_ugv/husarion_ugv/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ + # Size optimization + export SUDO_FORCE_REMOVE=yes && \ + apt-get remove -y \ + ros-dev-tools && \ + apt-get autoremove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY docker/utils/update_config_directory.sh /usr/local/sbin/update_config_directory +COPY docker/utils/setup_environment.sh /usr/local/sbin/setup_environment + +# Setup envs from eeprom +RUN sed -i "/# /i set -e -a && source setup_environment" /*_entrypoint.sh diff --git a/docker/Dockerfile.simulation b/docker/Dockerfile.simulation new file mode 100644 index 000000000..eff5b5680 --- /dev/null +++ b/docker/Dockerfile.simulation @@ -0,0 +1,38 @@ +ARG ROS_DISTRO=humble + +FROM husarnet/ros:${ROS_DISTRO}-ros-core + +ARG BRANCH_NAME=ros2-devel +ARG BUILD_TEST=OFF + +ENV HUSARION_ROS_BUILD_TYPE=simulation + +STOPSIGNAL SIGINT + +WORKDIR /ros2_ws +COPY . src/husarion_ugv + +RUN apt-get update && \ + apt-get install -y \ + ros-dev-tools && \ + # Setup workspace + vcs import src < src/husarion_ugv/husarion_ugv/${HUSARION_ROS_BUILD_TYPE}_deps.repos && \ + cp -r src/ros2_controllers/diff_drive_controller src && \ + cp -r src/ros2_controllers/imu_sensor_broadcaster src && \ + rm -rf src/ros2_controllers && \ + # Install dependencies + rosdep init && \ + rosdep update --rosdistro $ROS_DISTRO && \ + rosdep install --from-paths src -y -i && \ + # Build + source /opt/ros/$ROS_DISTRO/setup.bash && \ + colcon build --symlink-install --packages-up-to husarion_ugv --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$BUILD_TEST && \ + # Get version + echo $(cat /ros2_ws/src/husarion_ugv/husarion_ugv/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ + # Size optimization + export SUDO_FORCE_REMOVE=yes && \ + apt-get remove -y \ + ros-dev-tools && \ + apt-get autoremove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..6d6cce72e --- /dev/null +++ b/docker/README.md @@ -0,0 +1,71 @@ +# Docker + +Docker images dedicated to Husarion Panther ROS system and simulation. + +## Docker Images + +Docker images are automatically deployed to Docker Hub. The image tag includes information about the ROS distribution, the version of the [panther_ros](https://github.com/husarion/panther_ros/tree/ros2) repository, and the date of release. Additionally, stable image versions are tagged with `stable` and recommended for production use. +Below, you can find a list of available Docker images. To access the latest tag, simply follow the provided links: + +- [husarion/panther](https://hub.docker.com/r/husarion/panther) - ROS packages for Panther robot, +- [husarion/panther-gazebo](https://hub.docker.com/r/husarion/panther-gazebo) - Simulation for Panther robot in Gazebo-classic. + +## Updating Panther Software + +> [!Note] +> Latest Panther Docker images are compatible with Built-in Computer OS version 2.0.0 and newer. If your operating system is older, please ensure you update it before proceeding. **[COMING SOON]** Follow [operating system reinstallation](ros2-os-instalation-link) for more info. + +Connect to Panther's Built-in Computer: + +```bash +ssh husarion@10.15.20.2 +``` + +## Quick Start + +Depending on your needs, you can run Docker to quickly launch the physical robot or run a simulation. To do this, clone this repository to your robot or computer. + +```bash +cd docker/demo +``` + +### 🤖 Robot + +1. (Optional) Updating configuration files. + + > [!NOTE] + > This may overwrite your changes made in the `config` directory. If you want to keep your configuration you should skip this step or create backup of the `config` directory. + + ```bash + docker run --rm -v /home/husarion/config:/config husarion/panther:humble- update_config_directory + ``` + +2. Activate Panther + + ```bash + docker compose -f compose.hardware.yaml up + ``` + +3. Launch Visualization on PC + + ```bash + xhost local:root + docker compose -f compose.rviz.yaml up + ``` + +> [!NOTE] +> To use the latest version of the image, run the `docker compose pull` command and rerun above commands. + +### 💻 Gazebo Simulation + +To give Docker access to your screen run: + +```bash +xhost local:docker +docker compose -f compose.simulation.yaml up +``` + +> [!NOTE] +> +> 1. You can change robot model and namespace by editing the launch command in `compose.simulation.yaml`. +> 2. If you have an NVIDIA GPU, it is worth changing the compose configuration from `cpu-config` to `gpu-config`. For this purpose, it is necessary to install [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). With NVIDIA Container Toolkit installed, modify following Docker compose file by replacing `*cpu-config` with `*gpu-config`: [compose.simulation.yaml](./demo/compose.simulation.yaml). diff --git a/docker/demo/.env.cpu b/docker/demo/.env.cpu new file mode 100644 index 000000000..08406af99 --- /dev/null +++ b/docker/demo/.env.cpu @@ -0,0 +1,3 @@ +DISPLAY=${DISPLAY:?You need to define display env} +LIBGL_ALWAYS_SOFTWARE=1 +QT_X11_NO_MITSHM=1 diff --git a/docker/demo/.env.gpu b/docker/demo/.env.gpu new file mode 100644 index 000000000..4bec972ab --- /dev/null +++ b/docker/demo/.env.gpu @@ -0,0 +1,3 @@ +DISPLAY=${DISPLAY:?You need to define display env} +NVIDIA_VISIBLE_DEVICES=all +NVIDIA_DRIVER_CAPABILITIES=all diff --git a/docker/demo/compose.hardware.yaml b/docker/demo/compose.hardware.yaml new file mode 100644 index 000000000..d0e82266b --- /dev/null +++ b/docker/demo/compose.hardware.yaml @@ -0,0 +1,53 @@ +x-common-config: &common-config + network_mode: host + ipc: host + restart: always + env_file: + - /home/husarion/config/common/.env # env configuration including namespace, domain id, DDS, etc. + +services: + husarion_ugv_ros: + image: husarion/panther:humble-2.1.2-20241125 + container_name: husarion_ugv_ros + <<: *common-config + devices: + - /dev/bus/usb + - /dev/gpiochip0 + - /dev/spiled-channel1 + - /dev/spiled-channel2 + device_cgroup_rules: + - 'c 189:* rmw' # USB devices + - 'c 254:0 rmw' # gpiochip0 + - 'c 153:* rmw' # spiled-channel1, spiled-channel2 + volumes: + - /run/husarion/robot_config.env:/run/husarion/robot_config.env + - /run/husarion/robot_config.yaml:/run/husarion/robot_config.yaml + - /sys/bus/iio/devices:/sys/bus/iio/devices:ro # Read-only access to IIO devices + - ~/.ssh/id_rsa:/root/.ssh/id_rsa + - /home/husarion/config:/config + # Realtime hardware (https://control.ros.org/master/doc/ros2_control/controller_manager/doc/userdoc.html#determinism) + ulimits: + rtprio: + soft: 99 + hard: 99 + memlock: + soft: 102400 + hard: 102400 + command: > + ros2 launch husarion_ugv_bringup bringup.launch.py + common_dir_path:=/config + + gamepad_controller: + image: husarion/joy2twist:humble-1.0.0-20241003-stable + container_name: gamepad_controller + <<: *common-config + volumes: + - /home/husarion/config/common/joy2twist.yaml:/joy2twist.yaml + devices: + - /dev/input/js0 + device_cgroup_rules: + - 'c 13:0 rmw' # gamepad + stop_signal: SIGINT + command: > + ros2 launch joy2twist gamepad_controller.launch.py + joy2twist_params_file:=/joy2twist.yaml diff --git a/docker/demo/compose.rviz.yaml b/docker/demo/compose.rviz.yaml new file mode 100644 index 000000000..efd6dce9d --- /dev/null +++ b/docker/demo/compose.rviz.yaml @@ -0,0 +1,29 @@ +x-common-config: + &common-config + network_mode: host + ipc: host + environment: + - RMW_IMPLEMENTATION=rmw_cyclonedds_cpp # Default FastDDS do not work + - ROBOT_NAMESPACE=${ROBOT_NAMESPACE:-panther} + - ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0} + +x-cpu-config: + &cpu-config + env_file: .env.cpu + +x-gpu-config: + &gpu-config + runtime: nvidia + env_file: .env.gpu + +services: + rviz: + image: husarion/panther:humble-2.1.2-20241125 + container_name: rviz + <<: + - *common-config + - *cpu-config + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + command: > + ros2 launch husarion_ugv_description rviz.launch.py diff --git a/docker/demo/compose.simulation.yaml b/docker/demo/compose.simulation.yaml new file mode 100644 index 000000000..686d86041 --- /dev/null +++ b/docker/demo/compose.simulation.yaml @@ -0,0 +1,27 @@ +x-common-config: &common-config + network_mode: host + ipc: host + environment: + - RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + - ROBOT_MODEL=${ROBOT_MODEL_NAME:-panther} + - ROBOT_NAMESPACE=${ROBOT_NAMESPACE:-panther} + - ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0} + +x-cpu-config: &cpu-config + env_file: .env.cpu + +x-gpu-config: &gpu-config + runtime: nvidia + env_file: .env.gpu + +services: + panther_gazebo: + image: husarion/panther-gazebo:humble-2.1.2-20241125 + container_name: panther_gazebo + <<: + - *common-config + - *cpu-config + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix:rw + command: > + ros2 launch panther_gazebo simulation.launch.py diff --git a/docker/utils/setup_environment.sh b/docker/utils/setup_environment.sh new file mode 100755 index 000000000..4a2d6c23c --- /dev/null +++ b/docker/utils/setup_environment.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +# source robot environment +source /run/husarion/robot_config.env + +# check if /config directory is empty except it may contain common directory inside +if [ ! "$(ls -A /config | grep -v common)" ]; then + echo "Config directory is empty, copying files." + update_config_directory +fi diff --git a/docker/utils/update_config_directory.sh b/docker/utils/update_config_directory.sh new file mode 100755 index 000000000..aabd7782b --- /dev/null +++ b/docker/utils/update_config_directory.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +# method to copy directory/file using package name +copy_package_file() { + local package_name=$1 + local file_name=$2 + local package_file_path=$(ros2 pkg prefix $package_name)/share/$package_name/$file_name + + if [ ! -d "/config/$package_name" ]; then + mkdir -p /config/$package_name + fi + + # create subdirectories for files with subdirectories + if [[ $file_name == */* ]]; then + local subdirectory=$(dirname $file_name) + if [ ! -d "/config/$package_name/$subdirectory" ]; then + mkdir -p /config/$package_name/$subdirectory + fi + fi + + if [ -d "$package_file_path" ]; then + cp -rL $package_file_path /config/$package_name || true + else + cp -L $package_file_path /config/$package_name/$file_name || true + fi +} + +copy_package_file husarion_ugv_controller config +copy_package_file husarion_ugv_lights config/user_animations.yaml +copy_package_file husarion_ugv_localization config +rm /config/husarion_ugv_localization/config/nmea_navsat.yaml || true +copy_package_file husarion_ugv_manager behavior_trees/lights.xml +copy_package_file husarion_ugv_manager behavior_trees/LightsBT.btproj +copy_package_file panther_description config/components.yaml +copy_package_file lynx_description config/components.yaml + +# Change ownership of the copied files to host user +chown -R 1000:1001 /config diff --git a/husarion_ugv/package.xml b/husarion_ugv/package.xml index 2365d2eb4..5d992db73 100644 --- a/husarion_ugv/package.xml +++ b/husarion_ugv/package.xml @@ -15,7 +15,7 @@ ament_cmake - husarion_ugv_bringup + husarion_ugv_bringup husarion_ugv_gazebo