diff --git a/Dockerfile.hardware b/Dockerfile.hardware index 198b39f..0ef0d06 100644 --- a/Dockerfile.hardware +++ b/Dockerfile.hardware @@ -16,7 +16,7 @@ RUN apt-get update && \ ros-dev-tools && \ # Setup workspace git clone -b ${BRANCH_NAME} https://github.com/husarion/panther_ros.git src/panther_ros && \ - vcs import src < src/panther_ros/panther/panther_${HUSARION_ROS_BUILD_TYPE}.repos && \ + vcs import src < src/panther_ros/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 && \ @@ -26,9 +26,9 @@ RUN apt-get update && \ rosdep install --from-paths src -y -i && \ # Build source /opt/ros/$ROS_DISTRO/setup.bash && \ - colcon build --symlink-install --packages-up-to panther --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$BUILD_TEST && \ + 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/panther_ros/panther/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ + echo $(cat /ros2_ws/src/panther_ros/husarion_ugv/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ # Size optimalization export SUDO_FORCE_REMOVE=yes && \ apt-get remove -y \ @@ -37,5 +37,8 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +COPY update_config_directory.sh /usr/local/sbin/update_config_directory +COPY setup_environment.sh /usr/local/sbin/setup_environment + # Setup envs from eeprom -RUN sed -i "/# /i set -e -a && source /run/husarion/panther_config.env" /*_entrypoint.sh +RUN sed -i "/# /i set -e -a && source setup_environment" /*_entrypoint.sh diff --git a/Dockerfile.simulation b/Dockerfile.simulation index 222c5cc..881af7b 100644 --- a/Dockerfile.simulation +++ b/Dockerfile.simulation @@ -16,7 +16,7 @@ RUN apt-get update && \ ros-dev-tools && \ # Setup workspace git clone -b ${BRANCH_NAME} https://github.com/husarion/panther_ros.git src/panther_ros && \ - vcs import src < src/panther_ros/panther/panther_${HUSARION_ROS_BUILD_TYPE}.repos && \ + vcs import src < src/panther_ros/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 && \ @@ -26,9 +26,9 @@ RUN apt-get update && \ rosdep install --from-paths src -y -i && \ # Build source /opt/ros/$ROS_DISTRO/setup.bash && \ - colcon build --symlink-install --packages-up-to panther --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$BUILD_TEST && \ + 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/panther_ros/panther/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ + echo $(cat /ros2_ws/src/panther_ros/husarion_ugv/package.xml | grep '' | sed -r 's/.*([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \ # Size optimalization export SUDO_FORCE_REMOVE=yes && \ apt-get remove -y \ diff --git a/README.md b/README.md index 6019186..0a6c3b2 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,22 @@ cd panther-docker/demo ### 🤖 Robot -1. Activate Panther +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.minimal-setup.yaml up ``` -2. Launch Visualization on PC +3. Launch Visualization on PC ```bash xhost local:root diff --git a/demo/compose.minimal-setup.yaml b/demo/compose.minimal-setup.yaml index aa4dea9..b63399f 100644 --- a/demo/compose.minimal-setup.yaml +++ b/demo/compose.minimal-setup.yaml @@ -2,15 +2,13 @@ x-common-config: &common-config network_mode: host ipc: host restart: always - environment: - - RMW_IMPLEMENTATION=rmw_cyclonedds_cpp # Default FastDDS do not work - - ROBOT_MODEL=${ROBOT_MODEL:-panther} - - ROBOT_NAMESPACE=${ROBOT_MODEL:-panther} - - ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0} + env_file: + - /home/husarion/config/common/.env # env configuration including namespace, domain id, DDS, etc. + services: - panther_ros: - image: husarion/panther:humble-2.1.2-20241125 - container_name: panther_ros + husarion_ugv_ros: + image: husarion/panther:humble-ros2-devel + container_name: husarion_ugv_ros <<: *common-config devices: - /dev/bus/usb @@ -22,10 +20,11 @@ services: - 'c 254:0 rmw' # gpiochip0 - 'c 153:* rmw' # spiled-channel1, spiled-channel2 volumes: - - /run/husarion/panther_config.env:/run/husarion/panther_config.env - - /run/husarion/panther_config.yaml:/run/husarion/panther_config.yaml + - /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: @@ -35,17 +34,19 @@ services: soft: 102400 hard: 102400 command: > - ros2 launch panther_bringup bringup.launch.py + ros2 launch husarion_ugv_bringup bringup.launch.py gamepad_controller: image: husarion/joy2twist:humble-1.0.0-20241003-stable container_name: gamepad_controller <<: *common-config + volumes: + - /config/common/joy2twist.yaml:/joy2twist.yaml devices: - /dev/input/js0 device_cgroup_rules: - 'c 13:0 rmw' # gamepad stop_signal: SIGINT command: > - bash -c "ros2 launch joy2twist gamepad_controller.launch.py joy2twist_params_file:=$(ros2 pkg prefix joy2twist)/share/joy2twist/config/joy2twist_ugv.yaml" + ros2 launch joy2twist gamepad_controller.launch.py joy2twist_params_file:=/joy2twist.yaml diff --git a/setup_environment.sh b/setup_environment.sh new file mode 100755 index 0000000..4a2d6c2 --- /dev/null +++ b/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/update_config_directory.sh b/update_config_directory.sh new file mode 100755 index 0000000..aabd778 --- /dev/null +++ b/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