From be2a5f343baa70e260f0e7f900d90ad3fb307164 Mon Sep 17 00:00:00 2001 From: Nik Mohamad Aizuddin Date: Fri, 21 Jul 2023 12:13:39 +0800 Subject: [PATCH] feat(meta-user): add AMD Kria ROS2 Perception example --- .gitmodules | 3 + README.md | 3 +- docs/yocto/common/testing.md | 47 +++++++++++ .../files/kria_ros_perception | 1 + .../perception-2nodes_git.bb | 77 +++++++++++++++++++ .../recipes-images/images/ros2-image.bb | 1 + 6 files changed, 131 insertions(+), 1 deletion(-) create mode 160000 project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/files/kria_ros_perception create mode 100644 project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/perception-2nodes_git.bb diff --git a/.gitmodules b/.gitmodules index ef4a8d1..5f78e26 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "project/yocto/layers/meta-qt5"] path = project/yocto/layers/meta-qt5 url = https://github.com/meta-qt5/meta-qt5.git +[submodule "project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/files/kria_ros_perception"] + path = project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/files/kria_ros_perception + url = https://github.com/Xilinx/kria_ros_perception.git diff --git a/README.md b/README.md index d8dc791..7b9a874 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ A minimal ROS2 with Yocto workspace for learning purpose. ## Prerequisites -* [extra2000/yocto-toolkit v4.x image](https://github.com/extra2000/yocto-toolkit) +* [extra2000/yocto-toolkit v5.x image](https://github.com/extra2000/yocto-toolkit) +* [extra2000/ros2-gazebo11-classic v1.x image](https://github.com/extra2000/ros2-gazebo11-classic) * Available disk space: at least 350GB * SDCard with at least 4GB. * Digilent Analog Discovery 2 for accessing serial console through UART pins. diff --git a/docs/yocto/common/testing.md b/docs/yocto/common/testing.md index bf0d09e..643859f 100644 --- a/docs/yocto/common/testing.md +++ b/docs/yocto/common/testing.md @@ -1,5 +1,8 @@ # Testing + +## Simple ROS2 Helloworld Testing + Source ROS2 environment: ``` source /etc/profile.d/ros/setup.bash @@ -20,6 +23,50 @@ ros2 run ros2_helloworld_python helloworld To exit the program, either `CTRL` + `C` or send `0x0A03` (Number) to serial console. +## ROS2 Perception Node + +SSH into the target device and run simulation: +``` +source /etc/profile.d/ros/setup.bash +DISPLAY=:0 GAZEBO_RESOURCE_PATH="/usr/share/gazebo-11:/usr/share/OGRE/Media/ShadowVolume" ros2 launch perception_2nodes simulation.launch.py headless:='True' +``` + +Open another terminal. Then, run Rectify and Resize example on the target device: +``` +source /etc/profile.d/ros/setup.bash +DISPLAY=:0 GAZEBO_RESOURCE_PATH="/usr/share/gazebo-11:/usr/share/OGRE/Media/ShadowVolume" ros2 launch perception_2nodes trace_rectify_resize.launch.py +``` + +On host, allow X11 forwarding from local non-network connections: +``` +xhost +local: +``` + +Then execute the following command: +``` +podman run -it --rm \ + -e DISPLAY=$DISPLAY \ + --device=/dev/dri \ + --network=host \ + --userns="keep-id:uid=1000,gid=1000" \ + --security-opt label=disable \ + --name=ros2-workstation \ + localhost/extra2000/ros2-gazebo11-classic:latest \ + bash +source /opt/ros/humble/setup.bash +rqt +``` + +Open another terminal and execute the following command: +``` +podman exec -it ros2-workstation bash +source /opt/ros/humble/setup.bash +GAZEBO_MASTER_URI=http://TARGET_MACHINE:11345 gzclient --verbose +``` + +*NOTE: Replace the `TARGET_MACHINE` according to your target device IP address or FQDN.* + + ## Known Issues Python examples are broken at the moment due to Yocto Langdale uses `Python3 Setuptools v65.0.2`. See [entry_points install path is now 'bin' instead of 'lib' for setup.py installs](https://github.com/colcon/colcon-core/issues/518) issue. The examples only work with Yocto Honister which uses `Python3 Setuptools v57.4.0`. diff --git a/project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/files/kria_ros_perception b/project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/files/kria_ros_perception new file mode 160000 index 0000000..71a2d47 --- /dev/null +++ b/project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/files/kria_ros_perception @@ -0,0 +1 @@ +Subproject commit 71a2d473a96a77fb90afedc59a5091d7e7010184 diff --git a/project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/perception-2nodes_git.bb b/project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/perception-2nodes_git.bb new file mode 100644 index 0000000..ded471f --- /dev/null +++ b/project/yocto/layers/meta-user/recipes-apps/kria-ros-perception/perception-2nodes_git.bb @@ -0,0 +1,77 @@ +inherit ros_distro_humble +inherit ros_superflore_generated + +SUMMARY = "ROS2 Perception Nodes" +DESCRIPTION = "${SUMMARY}" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://../../LICENSE;md5=aaa7729bf8823a5d00dc80db2da0f9db" + +S = "${WORKDIR}/kria_ros_perception/src/perception_2nodes" + +SRC_URI = "\ + file://kria_ros_perception/ \ +" + +ROS_BUILD_TYPE = "ament_python" + +ROS_BUILDTOOL_DEPENDS = "" + +ROS_BUILD_DEPENDS = " \ + image-proc \ + python3-numpy \ + python3-numpy-native \ +" + +ROS_EXEC_DEPENDS = "\ + rclpy \ + std-msgs \ + python3-numpy \ + gazebo-ros-pkgs \ + image-pipeline \ + ros2trace \ + tracetools \ + tracetools-launch \ + tracetools-trace \ + lttng-modules \ + lttng-tools \ + lttng-ust \ +" + +ROS_EXPORT_DEPENDS = "" + +# Currently informational only -- see http://www.ros.org/reps/rep-0149.html#dependency-tags. +ROS_TEST_DEPENDS = " \ + ament-copyright \ + ament-flake8 \ + ament-pep257 \ + python3-pytest \ + python3-numpy \ +" + +ROS_BUILDTOOL_EXPORT_DEPENDS = "" + +DEPENDS = "${ROS_BUILD_DEPENDS} ${ROS_BUILDTOOL_DEPENDS}" +DEPENDS += "${ROS_EXPORT_DEPENDS} ${ROS_BUILDTOOL_EXPORT_DEPENDS}" +RDEPENDS:${PN} += "${ROS_EXEC_DEPENDS}" + +inherit ros_${ROS_BUILD_TYPE} + +FILES:${PN}:append = " \ + /usr/share/perception_2nodes \ + /usr/share/perception_2nodes/package.xml \ + /usr/share/perception_2nodes/launch \ + /usr/share/perception_2nodes/models \ + /usr/share/perception_2nodes/worlds \ + /usr/share/perception_2nodes/launch/simulation.launch.py \ + /usr/share/perception_2nodes/launch/trace_rectify_resize.launch.py \ + /usr/share/perception_2nodes/launch/trace_rectify_resize_fpga_streamlined.launch.py \ + /usr/share/perception_2nodes/models/camera-plugin \ + /usr/share/perception_2nodes/models/camera-plugin/model.config \ + /usr/share/perception_2nodes/models/camera-plugin/model_distorted.sdf \ + /usr/share/perception_2nodes/models/camera-plugin/model_undistorted.sdf \ + /usr/share/perception_2nodes/worlds/camera.world \ + /usr/share/perception_2nodes/worlds/camera_dynamic.world \ + /usr/share/perception_2nodes/worlds/camera_dynamic_hd.world \ + /usr/share/perception_2nodes/worlds/camera_dynamic_undistorted.world \ + /usr/share/perception_2nodes/worlds/camera_simple.world \ +" diff --git a/project/yocto/layers/meta-user/recipes-images/images/ros2-image.bb b/project/yocto/layers/meta-user/recipes-images/images/ros2-image.bb index f5a1f01..1b58bf7 100644 --- a/project/yocto/layers/meta-user/recipes-images/images/ros2-image.bb +++ b/project/yocto/layers/meta-user/recipes-images/images/ros2-image.bb @@ -92,6 +92,7 @@ ROS_SYSROOT_BUILD_DEPENDENCIES = " \ USER_APPS = " \ ros2-helloworld-cpp \ ros2-helloworld-python \ + perception-2nodes \ " NETWORKING = " \