ros / meta-ros

OpenEmbedded Layers for ROS 1 and ROS 2
MIT License
376 stars 250 forks source link

Build ROS2 package that contains custom interfaces (msg, srv) #978

Open bojankoce opened 2 years ago

bojankoce commented 2 years ago

Hi, guys!

I have a DART-MX8M-Mini machine running Yocto Hardknott.

I properly added meta-ros layer and ROS2 foxy distro to our Yocto build by following instructions from here (Sanity Tests pass successfully).

With the help of devtool, I was able to build my custom ROS2 package (containing simple talker and listener nodes - link). For that to happen, I got some great support from the Yocto community - link.

Here is the content of my-first-yocto-pkg_git.bb recipe that enabled me to download my source code from the git and properly build the ROS2 package:

# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)

# Unable to find any files that looked like license statements. Check the accompanying
# documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.
#
# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (it
# will not be in most cases) you must specify the correct value before using this
# recipe for anything other than initial testing/development!

DESCRIPTION = "Examples of minimal publisher/subscriber using rclcpp."
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://package.xml;beginline=8;endline=8;md5=12c26a18c7f493fdc7e8a93b16b7c04f"

SRC_URI = "git://github.com/bojankoce/my_first_yocto_pkg;protocol=https"

# Modify these as desired
PV = "0.1.0"
SRCREV = "1312445de2e6861d9561c0f89f4827b94c2ff6b1"

S = "${WORKDIR}/git"

# NOTE: unable to map the following CMake package dependencies: rclcpp ament_lint_auto std_msgs ros_ament_cmake
inherit ros_distro_foxy
inherit ros_superflore_generated
inherit ros_ament_cmake

ROS_BUILD_DEPENDS = " \
    rclcpp \
    std-msgs \
"

ROS_BUILDTOOL_DEPENDS = " \
    ament-cmake-native \
"

ROS_EXPORT_DEPENDS = ""

ROS_BUILDTOOL_EXPORT_DEPENDS = ""

ROS_EXEC_DEPENDS = " \
    launch-ros \
    std-msgs \
"

DEPENDS = "${ROS_BUILD_DEPENDS} ${ROS_BUILDTOOL_DEPENDS}"

DEPENDS += "${ROS_EXPORT_DEPENDS} ${ROS_BUILDTOOL_EXPORT_DEPENDS}"

# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
#EXTRA_OECMAKE = ""

I currently have a hard time building my ROS2 package that contains only custom ROS2 interfaces (messages and services). CMakeLists.txt file of that package contains the following lines that are causing the build errors:

find_package(rosidl_default_generators REQUIRED)
...

rosidl_generate_interfaces(${PROJECT_NAME}
  "msg/MessageX.msg"
  "msg/MessageY.msg"
  "srv/SrvX.srv"
  "srv/SrvY.srv"
 )

Do you have any idea about what should be included as inherit xxxxx or within ROS_BUILD_DEPENDS/ROS_BUILDTOOL_DEPENDS/ROS_EXEC_DEPENDS ... in order to successfully generate the ROS2 package containing custom interfaces?

Thanks in advance for your time and efforts. It is appreciated.

Sincerely, Bojan.

GeorgUr commented 2 years ago

Hey! I am currently facing the same issue. Can you provide more information about the build error?

bartoszptak commented 1 year ago

Any update?

yimlaisum2014 commented 6 months ago

Hi, everyone. I have same issue too. Does anyone solve it?

bartoszptak commented 6 months ago

Hi, everyone. I have same issue too. Does anyone solve it?

Hi @yimlaisum2014, I think the issue is still not solved. I workaround in that way https://github.com/PUTvision/put-meta-husky/blob/master/husky-msgs_git.bb#L44C19-L44C33. It is not a very practical solution, but I built successfully messages in yocto/petalinux.

robwoolley commented 6 months ago

@yimlaisum2014 @bartoszptak Thanks for posting comments on this. Sorry for the late response, I'm still getting used to the GitHub UI and didn't see this.

In the work I've been doing to update meta-ros, the *-msgs recipes have been the most trouble. At first, I added the dependencies manually, but recently I have been adding rosidl-default-runtime or rosidl-default-generators to the ROS_BUILDTOOL_DEPENDS. This has been supplying the dependencies it needs. I have seen in newer ROS 2 distributions; they also require a dependency on service-msgs.

I suspect that the problem is related to how superflore generates the base recipes and changes in the default dependencies that are needed. After I finish the work getting ros-image-world to work across all the supported combinations (which is soon), I plan to take a look at fixing superflore next.