From 3d2dc9fd168a9da64d4124e6b624ae24071564da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Pal=C3=A9ologue?= Date: Tue, 5 Dec 2023 14:35:13 +0100 Subject: [PATCH] Rebase from 'rpm/iron/naoqi_driver' --- .github/workflows/foxy_focal.yml | 15 ---- .github/workflows/galactic_focal.yml | 15 ---- .write_tar | 0 CHANGELOG.rst | 9 ++ README.md | 55 +++++++++--- docker-compose.yaml | 18 ++-- docker/Dockerfile | 2 +- package.xml | 2 +- rpm/ros-iron-naoqi-driver.spec | 128 --------------------------- rpm/template.spec.em | 88 ++++++++++++++++++ src/converters/camera.cpp | 2 +- 11 files changed, 150 insertions(+), 184 deletions(-) delete mode 100644 .github/workflows/foxy_focal.yml delete mode 100644 .github/workflows/galactic_focal.yml delete mode 100644 .write_tar delete mode 100644 rpm/ros-iron-naoqi-driver.spec create mode 100644 rpm/template.spec.em diff --git a/.github/workflows/foxy_focal.yml b/.github/workflows/foxy_focal.yml deleted file mode 100644 index 5260a12..0000000 --- a/.github/workflows/foxy_focal.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: ros2-foxy-focal - -on: - push - -jobs: - ros2_foxy_focal_ci: - name: foxy (focal) - uses: ./.github/workflows/ros2.yml - with: - ROS_DISTRO: foxy - ROS_REPO: testing - OS_NAME: ubuntu - OS_CODE_NAME: focal - ALLOW_FAIL: false \ No newline at end of file diff --git a/.github/workflows/galactic_focal.yml b/.github/workflows/galactic_focal.yml deleted file mode 100644 index 39f6e44..0000000 --- a/.github/workflows/galactic_focal.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: ros2-galactic-focal - -on: - push - -jobs: - ros2_galactic_focal_ci: - name: galactic (focal) - uses: ./.github/workflows/ros2.yml - with: - ROS_DISTRO: galactic - ROS_REPO: testing - OS_NAME: ubuntu - OS_CODE_NAME: focal - ALLOW_FAIL: false \ No newline at end of file diff --git a/.write_tar b/.write_tar deleted file mode 100644 index e69de29..0000000 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3beb0e7..e35ffa0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,15 @@ Changelog for package naoqi_driver ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2.1.1 (2023-12-05) +------------------ +* Drop testing of `foxy` and `galactic` +* README: remove extraneous args in example +* Update code and instructions about Docker +* Fix build for humble +* Improve README about audio service +* Contributors: Victor Paléologue + 2.1.0 (2023-11-23) ------------------ * New "Listen" action diff --git a/README.md b/README.md index f06fe69..b146aeb 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,13 @@ This repo defines the __naoqi_driver__ package for ROS2. The driver is in charge The __naoqi_driver__ is a ROS node. It connects to a robot running NAOqi using libQi. -It also listens to a libQi endpoint (specified by the option `qi_listen_url`). -This endpoint should be public (*e.g.* `qi_listen_url:=0.0.0.0:0`) -to enable collecting audio buffers remotely. -It should be set to a local address (*e.g.* `qi_listen_url:=127.0.0.1:0`) -when running on the robot. -It can be disabled by setting `qi_listen_url:=` when audio is not required. +To support the audio features, __naoqi_driver__ opens a libQi endpoint. +It is set by default to `127.0.0.1:0` (random port on local host), +so it should be set with the option `qi_listen_url`, +*e.g.* `qi_listen_url:=0.0.0.0:0` to allow collecting audio buffers remotely. -> Audio can be disabled in [boot_config.json](src/naoqi_driver2/share/boot_config.json). +Audio features are enabled by default and can be disabled in +[boot_config.json](src/naoqi_driver2/share/boot_config.json). ## Installation @@ -88,6 +87,8 @@ assuming the author of the job has agreed to the license terms. ## Launch +### Avoid interference with autonomous life + To have full control of the robot with ROS, you may want to disable autonomous behaviors first: @@ -97,20 +98,48 @@ qicli call ALAutonomousLife.setState disabled qicli call ALMotion.wakeUp ``` -The driver can be launched using the following command: + +### NAOqi 2.8 and lower + +The driver can be launched from a remote machine this way: ```sh source /opt/ros//setup.bash # or source /install/setup.bash if built from source -ros2 launch naoqi_driver naoqi_driver.launch.py nao_ip:= +ros2 launch naoqi_driver naoqi_driver.launch.py nao_ip:= qi_listen_url:=0.0.0.0:0 ``` + +### NAOqi 2.9 and higher + Username and password arguments are required for robots running NAOqi 2.9 or greater: ```sh -ros2 launch naoqi_driver naoqi_driver.launch.py nao_ip:= nao_username:=nao nao_password:= +ros2 launch naoqi_driver naoqi_driver.launch.py nao_ip:= nao_username:=nao nao_password:= qi_listen_url:=0.0.0.0:0 +``` + + +### From a Docker container + +If you run __naoqi_driver__ from a Docker container with audio features enabled, +you must specify the libQi endpoint with, *e.g.* for port 56000: + +```sh +source /opt/ros//setup.bash # or source /install/setup.bash if built from source +ros2 launch naoqi_driver naoqi_driver.launch.py nao_ip:= qi_listen_url:=0.0.0.0:56000 ``` +Then you must [expose](https://docs.docker.com/engine/reference/commandline/run/#publish) it from the container. + + +### On the robot or on the same machine + +If you run the driver directly from the robot (or your machine running a virtual robot), +you can omit the options: + +```sh +ros2 launch naoqi_driver naoqi_driver.launch.py +``` ## Check that the node is running correctly @@ -181,10 +210,10 @@ angular: ## Development Check how to [install the driver from source](#installing-from-source), -or use the [`Dockerfile`](Dockerfile) to get setup a reproducible dev environment: +or use `docker compose` to get a more reproducible dev environment: ```sh -docker build -t ros2-naoqi-driver . +ROS_DISTRO=iron docker compose up dev --build ``` > To get all logs in live and build debuggable binaries, @@ -197,7 +226,7 @@ docker build -t ros2-naoqi-driver . > It works also when running tests: > > ```sh -> colcon test --packages-skip nao_meshes pepper_meshes --event-handlers console_direct+ --ctest-args tests +> colcon test --event-handlers console_direct+ --ctest-args tests > ``` diff --git a/docker-compose.yaml b/docker-compose.yaml index 91424c4..8413f62 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,32 +1,30 @@ -# Docker Compose file for TurtleBot3 Behavior Examples +# Docker Compose file for developer containers # # Usage: # -# To build the images: -# docker compose build -# -# To start up a specific service by name: -# docker compose up +# ROS_DISTRO= docker compose up dev --build # # To open an interactive shell to a running container: -# docker exec -it bash +# docker exec -it naoqi_driver-dev-1 bash version: "3.9" services: - # Developer container dev: - image: ros2-naoqi-driver:dev + image: naoqi-driver:dev-$ROS_DISTRO build: context: . dockerfile: docker/Dockerfile target: dev + args: + - ROS_DISTRO=$ROS_DISTRO # Interactive shell stdin_open: true tty: true + # Networking and IPC for ROS 2 network_mode: host ipc: host volumes: # Mount the source code - - .:/ws/src/naoqi_driver2:rw + - .:/ws/src/naoqi_driver:rw diff --git a/docker/Dockerfile b/docker/Dockerfile index 65b0107..1fdb6c9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,7 +6,7 @@ SHELL ["/bin/bash", "-c"] # Create Colcon workspace with the project and its deps ENV WS=/ws -ENV PROJ_SRC=${WS}/src/naoqi_driver2 +ENV PROJ_SRC=${WS}/src/naoqi_driver COPY . $PROJ_SRC WORKDIR $WS/src RUN apt install -y git python3-vcstool diff --git a/package.xml b/package.xml index 06b2a06..acf1107 100644 --- a/package.xml +++ b/package.xml @@ -1,7 +1,7 @@ naoqi_driver - 2.1.0 + 2.1.1 Driver module between Aldebaran's NAOqiOS and ROS2. It publishes all sensor and actuator data as well as basic diagnostic for battery, temperature. It subscribes also to RVIZ simple goal and cmd_vel for teleop. Karsten Knese diff --git a/rpm/ros-iron-naoqi-driver.spec b/rpm/ros-iron-naoqi-driver.spec deleted file mode 100644 index a04867c..0000000 --- a/rpm/ros-iron-naoqi-driver.spec +++ /dev/null @@ -1,128 +0,0 @@ -%bcond_without tests -%bcond_without weak_deps - -%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') -%global __provides_exclude_from ^/opt/ros/iron/.*$ -%global __requires_exclude_from ^/opt/ros/iron/.*$ - -Name: ros-iron-naoqi-driver -Version: 2.1.0 -Release: 1%{?dist}%{?release_suffix} -Summary: ROS naoqi_driver package - -License: BSD -Source0: %{name}-%{version}.tar.gz - -Requires: boost-devel -Requires: boost-python%{python3_pkgversion}-devel -Requires: ros-iron-action-msgs -Requires: ros-iron-cv-bridge -Requires: ros-iron-image-transport -Requires: ros-iron-kdl-parser -Requires: ros-iron-naoqi-bridge-msgs >= 2.0.0 -Requires: ros-iron-naoqi-libqi -Requires: ros-iron-naoqi-libqicore -Requires: ros-iron-rclcpp -Requires: ros-iron-rclcpp-action -Requires: ros-iron-robot-state-publisher -Requires: ros-iron-tf2-ros -Requires: ros-iron-ros-workspace -BuildRequires: boost-devel -BuildRequires: boost-python%{python3_pkgversion}-devel -BuildRequires: ros-iron-action-msgs -BuildRequires: ros-iron-ament-cmake -BuildRequires: ros-iron-cv-bridge -BuildRequires: ros-iron-diagnostic-msgs -BuildRequires: ros-iron-diagnostic-updater -BuildRequires: ros-iron-geometry-msgs -BuildRequires: ros-iron-image-transport -BuildRequires: ros-iron-kdl-parser -BuildRequires: ros-iron-naoqi-bridge-msgs >= 2.0.0 -BuildRequires: ros-iron-naoqi-libqi -BuildRequires: ros-iron-naoqi-libqicore -BuildRequires: ros-iron-rclcpp -BuildRequires: ros-iron-rclcpp-action -BuildRequires: ros-iron-robot-state-publisher -BuildRequires: ros-iron-rosidl-default-generators -BuildRequires: ros-iron-sensor-msgs -BuildRequires: ros-iron-tf2-geometry-msgs -BuildRequires: ros-iron-tf2-msgs -BuildRequires: ros-iron-tf2-ros -BuildRequires: ros-iron-ros-workspace -BuildRequires: ros-iron-rosidl-typesupport-fastrtps-c -BuildRequires: ros-iron-rosidl-typesupport-fastrtps-cpp -Conflicts: ros-iron-nao-driver -Conflicts: ros-iron-naoqi-rosbridge -Provides: %{name}-devel = %{version}-%{release} -Provides: %{name}-doc = %{version}-%{release} -Provides: %{name}-runtime = %{version}-%{release} -Provides: ros-iron-rosidl-interface-packages(member) - -%if 0%{?with_tests} -BuildRequires: ros-iron-ament-lint-auto -BuildRequires: ros-iron-ament-lint-common -%endif - -%if 0%{?with_weak_deps} -Supplements: ros-iron-rosidl-interface-packages(all) -%endif - -%description -Driver module between Aldebaran's NAOqiOS and ROS2. It publishes all sensor and -actuator data as well as basic diagnostic for battery, temperature. It -subscribes also to RVIZ simple goal and cmd_vel for teleop. - -%prep -%autosetup -p1 - -%build -# In case we're installing to a non-standard location, look for a setup.sh -# in the install tree and source it. It will set things like -# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. -if [ -f "/opt/ros/iron/setup.sh" ]; then . "/opt/ros/iron/setup.sh"; fi -mkdir -p .obj-%{_target_platform} && cd .obj-%{_target_platform} -%cmake3 \ - -UINCLUDE_INSTALL_DIR \ - -ULIB_INSTALL_DIR \ - -USYSCONF_INSTALL_DIR \ - -USHARE_INSTALL_PREFIX \ - -ULIB_SUFFIX \ - -DCMAKE_INSTALL_PREFIX="/opt/ros/iron" \ - -DAMENT_PREFIX_PATH="/opt/ros/iron" \ - -DCMAKE_PREFIX_PATH="/opt/ros/iron" \ - -DSETUPTOOLS_DEB_LAYOUT=OFF \ -%if !0%{?with_tests} - -DBUILD_TESTING=OFF \ -%endif - .. - -%make_build - -%install -# In case we're installing to a non-standard location, look for a setup.sh -# in the install tree and source it. It will set things like -# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. -if [ -f "/opt/ros/iron/setup.sh" ]; then . "/opt/ros/iron/setup.sh"; fi -%make_install -C .obj-%{_target_platform} - -%if 0%{?with_tests} -%check -# Look for a Makefile target with a name indicating that it runs tests -TEST_TARGET=$(%__make -qp -C .obj-%{_target_platform} | sed "s/^\(test\|check\):.*/\\1/;t f;d;:f;q0") -if [ -n "$TEST_TARGET" ]; then -# In case we're installing to a non-standard location, look for a setup.sh -# in the install tree and source it. It will set things like -# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. -if [ -f "/opt/ros/iron/setup.sh" ]; then . "/opt/ros/iron/setup.sh"; fi -CTEST_OUTPUT_ON_FAILURE=1 \ - %make_build -C .obj-%{_target_platform} $TEST_TARGET || echo "RPM TESTS FAILED" -else echo "RPM TESTS SKIPPED"; fi -%endif - -%files -/opt/ros/iron - -%changelog -* Thu Nov 23 2023 Victor Paléologue - 2.1.0-1 -- Autogenerated by Bloom - diff --git a/rpm/template.spec.em b/rpm/template.spec.em new file mode 100644 index 0000000..bebb96b --- /dev/null +++ b/rpm/template.spec.em @@ -0,0 +1,88 @@ +%bcond_without tests +%bcond_without weak_deps + +%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') +%global __provides_exclude_from ^@(InstallationPrefix)/.*$ +%global __requires_exclude_from ^@(InstallationPrefix)/.*$ + +Name: @(Package) +Version: @(Version) +Release: @(RPMInc)%{?dist}%{?release_suffix} +Summary: ROS @(Name) package + +License: @(License) +@[if Homepage and Homepage != '']URL: @(Homepage)@\n@[end if]@ +Source0: %{name}-%{version}.tar.gz +@[if NoArch]@\nBuildArch: noarch@\n@[end if]@ + +@[for p in Depends]Requires: @p@\n@[end for]@ +@[for p in BuildDepends]BuildRequires: @p@\n@[end for]@ +@[for p in Conflicts]Conflicts: @p@\n@[end for]@ +@[for p in Replaces]Obsoletes: @p@\n@[end for]@ +@[for p in Provides]Provides: @p@\n@[end for]@ +@[if TestDepends]@\n%if 0%{?with_tests} +@[for p in TestDepends]BuildRequires: @p@\n@[end for]@ +%endif@\n@[end if]@ +@[if Supplements]@\n%if 0%{?with_weak_deps} +@[for p in Supplements]Supplements: @p@\n@[end for]@ +%endif@\n@[end if]@ + +%description +@(Description) + +%prep +%autosetup -p1 + +%build +# In case we're installing to a non-standard location, look for a setup.sh +# in the install tree and source it. It will set things like +# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. +if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi +mkdir -p .obj-%{_target_platform} && cd .obj-%{_target_platform} +%cmake3 \ + -UINCLUDE_INSTALL_DIR \ + -ULIB_INSTALL_DIR \ + -USYSCONF_INSTALL_DIR \ + -USHARE_INSTALL_PREFIX \ + -ULIB_SUFFIX \ + -DCMAKE_INSTALL_PREFIX="@(InstallationPrefix)" \ + -DAMENT_PREFIX_PATH="@(InstallationPrefix)" \ + -DCMAKE_PREFIX_PATH="@(InstallationPrefix)" \ + -DSETUPTOOLS_DEB_LAYOUT=OFF \ +%if !0%{?with_tests} + -DBUILD_TESTING=OFF \ +%endif + .. + +%make_build + +%install +# In case we're installing to a non-standard location, look for a setup.sh +# in the install tree and source it. It will set things like +# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. +if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi +%make_install -C .obj-%{_target_platform} + +%if 0%{?with_tests} +%check +# Look for a Makefile target with a name indicating that it runs tests +TEST_TARGET=$(%__make -qp -C .obj-%{_target_platform} | sed "s/^\(test\|check\):.*/\\1/;t f;d;:f;q0") +if [ -n "$TEST_TARGET" ]; then +# In case we're installing to a non-standard location, look for a setup.sh +# in the install tree and source it. It will set things like +# CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. +if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi +CTEST_OUTPUT_ON_FAILURE=1 \ + %make_build -C .obj-%{_target_platform} $TEST_TARGET || echo "RPM TESTS FAILED" +else echo "RPM TESTS SKIPPED"; fi +%endif + +%files +@[for lf in LicenseFiles]%license @lf@\n@[end for]@ +@(InstallationPrefix) + +%changelog@ +@[for change_version, (change_date, main_name, main_email) in changelogs] +* @(change_date) @(main_name) <@(main_email)> - @(change_version) +- Autogenerated by Bloom +@[end for] diff --git a/src/converters/camera.cpp b/src/converters/camera.cpp index c4c5e5b..41b866d 100644 --- a/src/converters/camera.cpp +++ b/src/converters/camera.cpp @@ -26,7 +26,7 @@ /* * ROS includes */ -#include +#include // not .hpp for humble compat /* * CV includes