Skip to content

Commit

Permalink
Merge branch 'main' into add-autowarefoundation-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
wep21 authored Jan 30, 2025
2 parents 94b0457 + f1c3205 commit a69267a
Show file tree
Hide file tree
Showing 12 changed files with 618 additions and 222 deletions.
5 changes: 5 additions & 0 deletions conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ cxx_compiler:
cxx_compiler_version: # [unix]
- 13 # [linux]
- 18 # [osx]

libzenohc:
- 1.1.1
libzenohcxx:
- 1.1.1
6 changes: 5 additions & 1 deletion patch/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,8 @@ rosx_introspection:
octomap_ros:
add_host: ["octomap"]
octomap_rviz_plugins:
add_host: ["octomap"]
add_host: ["octomap"]
zenoh_cpp_vendor:
add_host: ["libzenohc", "libzenohcxx"]
rmw_zenoh_cpp:
add_host: ["libzenohc", "libzenohcxx"]
54 changes: 54 additions & 0 deletions patch/ros-humble-ffmpeg-encoder-decoder.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/src/decoder.cpp b/src/decoder.cpp
index 0a12d25..10834e3 100644
--- a/src/decoder.cpp
+++ b/src/decoder.cpp
@@ -38,7 +38,11 @@ Decoder::~Decoder() { reset(); }
void Decoder::reset()
{
if (codecContext_) {
+#if LIBAVFORMAT_VERSION_MAJOR < 59
avcodec_close(codecContext_);
+#else
+ avcodec_free_context(&codecContext_);
+#endif
av_free(codecContext_);
codecContext_ = NULL;
}
diff --git a/src/encoder.cpp b/src/encoder.cpp
index a4b6de6..2e1d4a2 100644
--- a/src/encoder.cpp
+++ b/src/encoder.cpp
@@ -54,7 +54,11 @@ static void free_frame(AVFrame ** frame)
void Encoder::closeCodec()
{
if (codecContext_) {
+#if LIBAVFORMAT_VERSION_MAJOR < 59
avcodec_close(codecContext_);
+#else
+ avcodec_free_context(&codecContext_);
+#endif
codecContext_ = nullptr;
}
free_frame(&frame_);
diff --git a/src/utils.cpp b/src/utils.cpp
index da089e4..01e8eea 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -104,8 +104,15 @@ enum AVPixelFormat get_preferred_pixel_format(
std::vector<enum AVPixelFormat> get_encoder_formats(const AVCodec * c)
{
std::vector<enum AVPixelFormat> formats;
- if (c && c->pix_fmts) {
- for (const auto * p = c->pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
+#if LIBAVUTIL_VERSION_MAJOR > 59 || (LIBAVUTIL_VERSION_MAJOR == 59 && LIBAVUTIL_VERSION_MINOR >= 39)
+ const enum AVPixelFormat *pix_fmts = NULL;
+ avcodec_get_supported_config(NULL, c, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void **) &pix_fmts, NULL);
+ if (c && pix_fmts) {
+#else
+ const enum AVPixelFormat *pix_fmts = c->pix_fmts;
+ if (c && pix_fmts) {
+#endif
+ for (const auto * p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
formats.push_back(*p);
}
}
226 changes: 226 additions & 0 deletions patch/ros-humble-ur-client-library.osx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
diff --git a/include/ur_client_library/comm/bin_parser.h b/include/ur_client_library/comm/bin_parser.h
index e13aba6..6931af3 100644
--- a/include/ur_client_library/comm/bin_parser.h
+++ b/include/ur_client_library/comm/bin_parser.h
@@ -21,7 +21,31 @@
#pragma once

#include <assert.h>
+#ifdef __APPLE__
+
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+
+#else
+
#include <endian.h>
+
+#endif /* __APPLE__ */
#include <inttypes.h>
#include <array>
#include <bitset>
diff --git a/include/ur_client_library/comm/package_serializer.h b/include/ur_client_library/comm/package_serializer.h
index 7745da9..78859d9 100644
--- a/include/ur_client_library/comm/package_serializer.h
+++ b/include/ur_client_library/comm/package_serializer.h
@@ -29,7 +29,31 @@
#ifndef UR_CLIENT_LIBRARY_PACKAGE_SERIALIZER_H_INCLUDED
#define UR_CLIENT_LIBRARY_PACKAGE_SERIALIZER_H_INCLUDED

+#ifdef __APPLE__
+
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+
+#else
+
#include <endian.h>
+
+#endif /* __APPLE__ */
#include <cstring>

namespace urcl
diff --git a/include/ur_client_library/control/reverse_interface.h b/include/ur_client_library/control/reverse_interface.h
index 9919dbd..077403e 100644
--- a/include/ur_client_library/control/reverse_interface.h
+++ b/include/ur_client_library/control/reverse_interface.h
@@ -35,7 +35,31 @@
#include "ur_client_library/log.h"
#include "ur_client_library/ur/robot_receive_timeout.h"
#include <cstring>
+#ifdef __APPLE__
+
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+
+#else
+
#include <endian.h>
+
+#endif /* __APPLE__ */
#include <condition_variable>

namespace urcl
diff --git a/include/ur_client_library/primary/package_header.h b/include/ur_client_library/primary/package_header.h
index cd64bda..b4738dd 100644
--- a/include/ur_client_library/primary/package_header.h
+++ b/include/ur_client_library/primary/package_header.h
@@ -32,7 +32,31 @@

#include <inttypes.h>
#include <cstddef>
+#ifdef __APPLE__
+
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+
+#else
+
#include <endian.h>
+
+#endif /* __APPLE__ */
#include "ur_client_library/types.h"

namespace urcl
diff --git a/include/ur_client_library/rtde/package_header.h b/include/ur_client_library/rtde/package_header.h
index f910a08..4013e26 100644
--- a/include/ur_client_library/rtde/package_header.h
+++ b/include/ur_client_library/rtde/package_header.h
@@ -31,7 +31,31 @@
#define UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED

#include <cstddef>
+#ifdef __APPLE__
+
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+
+#else
+
#include <endian.h>
+
+#endif /* __APPLE__ */
#include "ur_client_library/types.h"
#include "ur_client_library/comm/package_serializer.h"

diff --git a/src/comm/tcp_socket.cpp b/src/comm/tcp_socket.cpp
index 8803664..f75f381 100644
--- a/src/comm/tcp_socket.cpp
+++ b/src/comm/tcp_socket.cpp
@@ -21,7 +21,31 @@
*/

#include <arpa/inet.h>
+#ifdef __APPLE__
+
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+
+#else
+
#include <endian.h>
+
+#endif /* __APPLE__ */
#include <netinet/tcp.h>
#include <unistd.h>
#include <chrono>
@@ -48,7 +72,9 @@ void TCPSocket::setupOptions()
{
int flag = 1;
setsockopt(socket_fd_, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int));
+#ifndef __APPLE__
setsockopt(socket_fd_, IPPROTO_TCP, TCP_QUICKACK, &flag, sizeof(int));
+#endif

if (recv_timeout_ != nullptr)
{
42 changes: 42 additions & 0 deletions patch/ros-humble-zenoh-cpp-vendor.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/zenoh_cpp_vendor/CMakeLists.txt b/zenoh_cpp_vendor/CMakeLists.txt
index 2d3ae046..de971841 100644
--- a/zenoh_cpp_vendor/CMakeLists.txt
+++ b/zenoh_cpp_vendor/CMakeLists.txt
@@ -10,35 +10,10 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_vendor_package REQUIRED)

-# Disable default features and enable only the most useful ones. This reduces build time and footprint.
-# For a complete list of features see: https://github.com/eclipse-zenoh/zenoh/blob/main/zenoh/Cargo.toml
-# Note: We separate the two args needed for cargo with "$<SEMICOLON>" and not ";" as the
-# latter is a list separater in cmake and hence the string will be split into two
-# when expanded.
-set(ZENOHC_CARGO_FLAGS "--no-default-features$<SEMICOLON>--features=shared-memory zenoh/transport_compression zenoh/transport_tcp zenoh/transport_tls")
-
-ament_vendor(zenoh_c_vendor
- VCS_URL https://github.com/eclipse-zenoh/zenoh-c.git
- VCS_VERSION 57d5e4d31d9b38fef34d7bcad3d3e54869c4ce73
- CMAKE_ARGS
- "-DZENOHC_CARGO_FLAGS=${ZENOHC_CARGO_FLAGS}"
- "-DZENOHC_BUILD_WITH_UNSTABLE_API=TRUE"
- "-DZENOHC_CUSTOM_TARGET=${ZENOHC_CUSTOM_TARGET}"
-)
-
+find_package(zenohc REQUIRED)
ament_export_dependencies(zenohc)

-# Set VCS_VERSION to include latest changes from zenoh-c to benefit from :
-# - https://github.com/eclipse-zenoh/zenoh-cpp/pull/342 (Fix include what you use)
-ament_vendor(zenoh_cpp_vendor
- VCS_URL https://github.com/eclipse-zenoh/zenoh-cpp
- VCS_VERSION 964b64dc8b935a43147287199e7bb12da7b141e6
- CMAKE_ARGS
- -DZENOHCXX_ZENOHC=OFF
-)
-
-externalproject_add_stepdependencies(zenoh_cpp_vendor configure zenoh_c_vendor)
-
+find_package(zenohcxx REQUIRED)
ament_export_dependencies(zenohcxx)

ament_package()
Loading

0 comments on commit a69267a

Please sign in to comment.