From 8ae984bfe37b8356ef80a5453b2cba42155fe36f Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Mon, 19 Oct 2026 09:18:50 +1000 Subject: [PATCH 1/4] webots_ros2_driver on macOS [skip ci] For RoboStack/robostack#102 (upstream WIP: cyberbotics/webots_ros2#733). The bundled Webots controller library builds on macOS, but its Makefiles assume the app bundle layout and universal binaries: - map Contents/ onto the plain layout (symlink) and install the launcher from MacOS/; plain @rpath install names and @loader_path rpaths - build only the target architecture under conda (target_platform), and link without an explicit -target (conda's clang++ then rejects libLTO) - build the launcher with $(CC) and header padding for install_name_tool - Ros2LightSensor: fix chained comparisons (a < x < b), rejected by clang 21 Only webots_ros2_driver is selected on macOS; webots_ros2 stays linux-64. Co-Authored-By: Claude Opus 5.5 --- .../patch/ros2-webots-ros2-driver.patch | 219 +++++++++++++++- .../jazzy/patch/ros2-webots-ros2-driver.patch | 238 ++++++++++++++++++ .../patch/ros2-webots-ros2-driver.patch | 219 +++++++++++++++- .../patch/ros2-webots-ros2-driver.patch | 219 +++++++++++++++- shared/vinca.yaml | 4 + 5 files changed, 887 insertions(+), 12 deletions(-) create mode 100644 distros/jazzy/patch/ros2-webots-ros2-driver.patch diff --git a/distros/humble/patch/ros2-webots-ros2-driver.patch b/distros/humble/patch/ros2-webots-ros2-driver.patch index 202b9803..3040d000 100644 --- a/distros/humble/patch/ros2-webots-ros2-driver.patch +++ b/distros/humble/patch/ros2-webots-ros2-driver.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 693d9ed..54660a8 100644 +index 693d9ed..78ef33c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ @@ -8,7 +8,7 @@ index 693d9ed..54660a8 100644 project(webots_ros2_driver) set(CMAKE_CXX_STANDARD 17) -@@ -30,15 +30,7 @@ find_package(tinyxml2_vendor REQUIRED) +@@ -30,14 +30,18 @@ find_package(tinyxml2_vendor REQUIRED) find_package(TinyXML2 REQUIRED) find_package(yaml-cpp REQUIRED) @@ -20,8 +20,219 @@ index 693d9ed..54660a8 100644 - find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) -elseif($ENV{ROS_DISTRO} MATCHES "rolling") - find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) --endif() +find_package(Python 3 REQUIRED COMPONENTS Development) ++ ++if(APPLE) ++ # The bundled Webots Makefiles write the macOS app bundle layout (Contents/lib/..., ++ # Contents/MacOS/webots-controller): map it onto the plain layout installed below. ++ file(CREATE_LINK . ${CMAKE_CURRENT_SOURCE_DIR}/webots/Contents SYMBOLIC) ++ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/webots/MacOS) ++ set(WEBOTS_RPATH_ORIGIN "@loader_path") ++ set(WEBOTS_CONTROLLER_LAUNCHER webots/MacOS/webots-controller) ++else() ++ set(WEBOTS_RPATH_ORIGIN "$ORIGIN") ++ set(WEBOTS_CONTROLLER_LAUNCHER webots/webots-controller) + endif() add_custom_target(compile-lib-controller ALL - COMMAND ${CMAKE_COMMAND} -E env "WEBOTS_HOME=${CMAKE_CURRENT_SOURCE_DIR}/webots" make release -f Makefile > /dev/null 2>&1 +@@ -87,7 +91,7 @@ ament_python_install_package(${PROJECT_NAME} + PACKAGE_DIR ${PROJECT_NAME}) + + # Driver +-set(CMAKE_INSTALL_RPATH "$ORIGIN/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_executable(driver + src/Driver.cpp + src/WebotsNode.cpp +@@ -138,7 +142,7 @@ install(TARGETS driver + ) + + # Dynamic IMU +-set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_library( + ${PROJECT_NAME}_imu + SHARED +@@ -166,7 +170,7 @@ install(TARGETS ${PROJECT_NAME}_imu + ) + + # Dynamic RGBD +-set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_library( + ${PROJECT_NAME}_rgbd + SHARED +@@ -235,7 +239,7 @@ install( + + # Install webots-controller script + install( +- PROGRAMS webots/webots-controller ++ PROGRAMS ${WEBOTS_CONTROLLER_LAUNCHER} + DESTINATION share/${PROJECT_NAME}/scripts + ) + +diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp +index 63a5e4b..1288e06 100644 +--- a/src/plugins/static/Ros2LightSensor.cpp ++++ b/src/plugins/static/Ros2LightSensor.cpp +@@ -74,8 +74,8 @@ namespace webots_ros2_driver { + // Find relative standard deviation in lookup table + double relativeStd = NAN; + for (int i = 0; i < mLookupTable.size() - 3; i += 3) +- if ((mLookupTable[i + 1] < rawValue < mLookupTable[i + 3 + 1]) || +- (mLookupTable[i + 1] > rawValue > mLookupTable[i + 3 + 1])) { ++ if ((mLookupTable[i + 1] < rawValue && rawValue < mLookupTable[i + 3 + 1]) || ++ (mLookupTable[i + 1] > rawValue && rawValue > mLookupTable[i + 3 + 1])) { + relativeStd = mLookupTable[i + 2]; + break; + } +diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include +index 461793b..704adf6 100644 +--- a/webots/resources/Makefile.include ++++ b/webots/resources/Makefile.include +@@ -210,15 +210,15 @@ endif + ifneq ($(C_SOURCES)$(CXX_SOURCES),) + ifdef BUILD_EXECUTABLE + MAIN_TARGET = $(NAME)$(EXE_EXTENSION) +- X86_64_LINKER = -target x86_64-apple-macos12 +- ARM64_LINKER = -target arm64-apple-macos12 ++ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) ++ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) + else + ifdef BUILD_STATIC_LIBRARY + MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(STATIC_LIB_EXTENSION) + else + MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(SHARED_LIB_EXTENSION) +- X86_64_LINKER = -target x86_64-apple-macos12 +- ARM64_LINKER = -target arm64-apple-macos12 ++ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) ++ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) + endif + endif + endif +@@ -405,8 +405,8 @@ endif + + ifeq ($(OSTYPE),darwin) + ifdef WEBOTS_LIBRARY +- INSTALL_NAME ?= @rpath/Contents/lib/controller/$(MAIN_TARGET) +- LFLAGS += -Xlinker -rpath -Xlinker @loader_path/.. -install_name $(INSTALL_NAME) ++ INSTALL_NAME ?= @rpath/$(MAIN_TARGET) ++ LFLAGS += -Xlinker -rpath -Xlinker @loader_path -install_name $(INSTALL_NAME) + else + CALLING_MAKEFILE_DIR := $(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))") + WEBOTS_RELATIVE_PATH = $(call computeRelativePath,"$(WEBOTS_HOME_PATH)","$(CALLING_MAKEFILE_DIR)") +@@ -549,16 +549,18 @@ endif + ###----------------------------------------------------------------------------- + + ifdef FAT_BINARY ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/, $(OBJECTS_LIST)) + ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/, $(OBJECTS_LIST)) + +-$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + @echo "# creating fat" $(notdir $@) +- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + +-$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + @echo "# creating fat" $(notdir $@) +- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + + $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET): $(X86_64_OBJECTS) $(LINK_DEPENDENCIES) + @echo "# linking" $(notdir $@) "(x86_64)" +diff --git a/webots/src/controller/c/Makefile b/webots/src/controller/c/Makefile +index 14a32c7..bfceaf5 100644 +--- a/webots/src/controller/c/Makefile ++++ b/webots/src/controller/c/Makefile +@@ -44,7 +44,7 @@ endif + ifeq ($(OSTYPE),darwin) + CFLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -fpascal-strings -Wno-deprecated-declarations -Wno-single-bit-bitfield-constant-conversion -I/Developer/Headers/FlatCarbon -Wall -fno-common -D LIBCONTROLLER_VERSION='$(LIBCONTROLLER_VERSION)' + INCLUDE = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include +-LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/Contents/lib/controller/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 ++LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 + SHARED_LIBS = -lz + TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib + CC = gcc +@@ -144,12 +144,14 @@ endif + endif + + ifeq ($(OSTYPE),darwin) ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(OBJDIR)/x86_64/, $(OBJECTS)) + ARM64_OBJECTS = $(addprefix $(OBJDIR)/arm64/, $(OBJECTS)) + +-$(TARGET): $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib ++$(TARGET): $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib + @echo "# creating fat binary: $$"\(WEBOTS_HOME\)/lib/controller/libController.dylib +- @lipo -create -output $(TARGET) $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib ++ @lipo -create -output $(TARGET) $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib + @chmod a-x $@ + @codesign -s - $@ + +diff --git a/webots/src/controller/cpp/Makefile b/webots/src/controller/cpp/Makefile +index dde0a6e..910fb01 100644 +--- a/webots/src/controller/cpp/Makefile ++++ b/webots/src/controller/cpp/Makefile +@@ -100,7 +100,7 @@ SHAREDLIBS = -L$(WEBOTS_CONTROLLER_LIB_PATH) -lController + CPPFLAGS = -c -fPIC -Wall -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) + CPPINCLUDES = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include/controller/cpp + LIBCONTROLLER = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib +-LDFLAGS += -install_name @rpath/Contents/lib/controller/libCppController.dylib ++LDFLAGS += -install_name @rpath/libCppController.dylib -Wl,-rpath,@loader_path + TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libCppController.dylib + endif + +@@ -121,21 +121,23 @@ all debug profile release: $(TARGET) + + ifeq ($(OSTYPE),darwin) + ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/,$(OBJECTS)) + ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/,$(OBJECTS)) + +-$(TARGET): $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib ++$(TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib + @echo "# creating fat" $(notdir $@) +- @lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib ++ @lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib + @codesign -s - $@ + + $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib: $(X86_64_OBJECTS) + @echo "# linking" $@ "(x86_64)" +- @$(CXX) -target x86_64-apple-macos12 $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" ++ @$(CXX) $(if $(target_platform),,-target x86_64-apple-macos12) $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" + + $(BUILD_GOAL_DIR)/arm64/libCppController.dylib: $(ARM64_OBJECTS) + @echo "# linking" $@ "(arm64)" +- @$(CXX) -target arm64-apple-macos12 $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" ++ @$(CXX) $(if $(target_platform),,-target arm64-apple-macos12) $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" + + else + +diff --git a/webots/src/controller/launcher/Makefile b/webots/src/controller/launcher/Makefile +index 6c9cf55..7cd02ff 100644 +--- a/webots/src/controller/launcher/Makefile ++++ b/webots/src/controller/launcher/Makefile +@@ -33,6 +33,8 @@ ifeq ($(OSTYPE),windows) + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/msys64/mingw64/bin/webots-controller.exe + else ifeq ($(OSTYPE),darwin) + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/Contents/MacOS/webots-controller ++# the environment's compiler, and room for the install name tool to rewrite rpaths ++LAUNCHER_CC = $(CC) -Wl,-headerpad_max_install_names + else + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/webots-controller + endif +@@ -43,6 +45,6 @@ release debug profile: $(CONTROLLER_LAUNCHER) + + $(CONTROLLER_LAUNCHER): webots_controller.c + @echo "# compiling" $< +- @gcc $(CFLAGS) webots_controller.c -o $@ ++ @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ + + FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) diff --git a/distros/jazzy/patch/ros2-webots-ros2-driver.patch b/distros/jazzy/patch/ros2-webots-ros2-driver.patch new file mode 100644 index 00000000..3040d000 --- /dev/null +++ b/distros/jazzy/patch/ros2-webots-ros2-driver.patch @@ -0,0 +1,238 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 693d9ed..78ef33c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.10) ++cmake_minimum_required(VERSION 3.16) + project(webots_ros2_driver) + + set(CMAKE_CXX_STANDARD 17) +@@ -30,14 +30,18 @@ find_package(tinyxml2_vendor REQUIRED) + find_package(TinyXML2 REQUIRED) + find_package(yaml-cpp REQUIRED) + +-if($ENV{ROS_DISTRO} MATCHES "humble") +- find_package(Python 3.10 EXACT REQUIRED COMPONENTS Development) +-elseif($ENV{ROS_DISTRO} MATCHES "iron") +- find_package(Python 3.10 EXACT REQUIRED COMPONENTS Development) +-elseif($ENV{ROS_DISTRO} MATCHES "jazzy") +- find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) +-elseif($ENV{ROS_DISTRO} MATCHES "rolling") +- find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) ++find_package(Python 3 REQUIRED COMPONENTS Development) ++ ++if(APPLE) ++ # The bundled Webots Makefiles write the macOS app bundle layout (Contents/lib/..., ++ # Contents/MacOS/webots-controller): map it onto the plain layout installed below. ++ file(CREATE_LINK . ${CMAKE_CURRENT_SOURCE_DIR}/webots/Contents SYMBOLIC) ++ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/webots/MacOS) ++ set(WEBOTS_RPATH_ORIGIN "@loader_path") ++ set(WEBOTS_CONTROLLER_LAUNCHER webots/MacOS/webots-controller) ++else() ++ set(WEBOTS_RPATH_ORIGIN "$ORIGIN") ++ set(WEBOTS_CONTROLLER_LAUNCHER webots/webots-controller) + endif() + + add_custom_target(compile-lib-controller ALL +@@ -87,7 +91,7 @@ ament_python_install_package(${PROJECT_NAME} + PACKAGE_DIR ${PROJECT_NAME}) + + # Driver +-set(CMAKE_INSTALL_RPATH "$ORIGIN/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_executable(driver + src/Driver.cpp + src/WebotsNode.cpp +@@ -138,7 +142,7 @@ install(TARGETS driver + ) + + # Dynamic IMU +-set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_library( + ${PROJECT_NAME}_imu + SHARED +@@ -166,7 +170,7 @@ install(TARGETS ${PROJECT_NAME}_imu + ) + + # Dynamic RGBD +-set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_library( + ${PROJECT_NAME}_rgbd + SHARED +@@ -235,7 +239,7 @@ install( + + # Install webots-controller script + install( +- PROGRAMS webots/webots-controller ++ PROGRAMS ${WEBOTS_CONTROLLER_LAUNCHER} + DESTINATION share/${PROJECT_NAME}/scripts + ) + +diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp +index 63a5e4b..1288e06 100644 +--- a/src/plugins/static/Ros2LightSensor.cpp ++++ b/src/plugins/static/Ros2LightSensor.cpp +@@ -74,8 +74,8 @@ namespace webots_ros2_driver { + // Find relative standard deviation in lookup table + double relativeStd = NAN; + for (int i = 0; i < mLookupTable.size() - 3; i += 3) +- if ((mLookupTable[i + 1] < rawValue < mLookupTable[i + 3 + 1]) || +- (mLookupTable[i + 1] > rawValue > mLookupTable[i + 3 + 1])) { ++ if ((mLookupTable[i + 1] < rawValue && rawValue < mLookupTable[i + 3 + 1]) || ++ (mLookupTable[i + 1] > rawValue && rawValue > mLookupTable[i + 3 + 1])) { + relativeStd = mLookupTable[i + 2]; + break; + } +diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include +index 461793b..704adf6 100644 +--- a/webots/resources/Makefile.include ++++ b/webots/resources/Makefile.include +@@ -210,15 +210,15 @@ endif + ifneq ($(C_SOURCES)$(CXX_SOURCES),) + ifdef BUILD_EXECUTABLE + MAIN_TARGET = $(NAME)$(EXE_EXTENSION) +- X86_64_LINKER = -target x86_64-apple-macos12 +- ARM64_LINKER = -target arm64-apple-macos12 ++ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) ++ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) + else + ifdef BUILD_STATIC_LIBRARY + MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(STATIC_LIB_EXTENSION) + else + MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(SHARED_LIB_EXTENSION) +- X86_64_LINKER = -target x86_64-apple-macos12 +- ARM64_LINKER = -target arm64-apple-macos12 ++ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) ++ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) + endif + endif + endif +@@ -405,8 +405,8 @@ endif + + ifeq ($(OSTYPE),darwin) + ifdef WEBOTS_LIBRARY +- INSTALL_NAME ?= @rpath/Contents/lib/controller/$(MAIN_TARGET) +- LFLAGS += -Xlinker -rpath -Xlinker @loader_path/.. -install_name $(INSTALL_NAME) ++ INSTALL_NAME ?= @rpath/$(MAIN_TARGET) ++ LFLAGS += -Xlinker -rpath -Xlinker @loader_path -install_name $(INSTALL_NAME) + else + CALLING_MAKEFILE_DIR := $(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))") + WEBOTS_RELATIVE_PATH = $(call computeRelativePath,"$(WEBOTS_HOME_PATH)","$(CALLING_MAKEFILE_DIR)") +@@ -549,16 +549,18 @@ endif + ###----------------------------------------------------------------------------- + + ifdef FAT_BINARY ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/, $(OBJECTS_LIST)) + ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/, $(OBJECTS_LIST)) + +-$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + @echo "# creating fat" $(notdir $@) +- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + +-$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + @echo "# creating fat" $(notdir $@) +- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + + $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET): $(X86_64_OBJECTS) $(LINK_DEPENDENCIES) + @echo "# linking" $(notdir $@) "(x86_64)" +diff --git a/webots/src/controller/c/Makefile b/webots/src/controller/c/Makefile +index 14a32c7..bfceaf5 100644 +--- a/webots/src/controller/c/Makefile ++++ b/webots/src/controller/c/Makefile +@@ -44,7 +44,7 @@ endif + ifeq ($(OSTYPE),darwin) + CFLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -fpascal-strings -Wno-deprecated-declarations -Wno-single-bit-bitfield-constant-conversion -I/Developer/Headers/FlatCarbon -Wall -fno-common -D LIBCONTROLLER_VERSION='$(LIBCONTROLLER_VERSION)' + INCLUDE = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include +-LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/Contents/lib/controller/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 ++LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 + SHARED_LIBS = -lz + TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib + CC = gcc +@@ -144,12 +144,14 @@ endif + endif + + ifeq ($(OSTYPE),darwin) ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(OBJDIR)/x86_64/, $(OBJECTS)) + ARM64_OBJECTS = $(addprefix $(OBJDIR)/arm64/, $(OBJECTS)) + +-$(TARGET): $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib ++$(TARGET): $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib + @echo "# creating fat binary: $$"\(WEBOTS_HOME\)/lib/controller/libController.dylib +- @lipo -create -output $(TARGET) $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib ++ @lipo -create -output $(TARGET) $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib + @chmod a-x $@ + @codesign -s - $@ + +diff --git a/webots/src/controller/cpp/Makefile b/webots/src/controller/cpp/Makefile +index dde0a6e..910fb01 100644 +--- a/webots/src/controller/cpp/Makefile ++++ b/webots/src/controller/cpp/Makefile +@@ -100,7 +100,7 @@ SHAREDLIBS = -L$(WEBOTS_CONTROLLER_LIB_PATH) -lController + CPPFLAGS = -c -fPIC -Wall -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) + CPPINCLUDES = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include/controller/cpp + LIBCONTROLLER = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib +-LDFLAGS += -install_name @rpath/Contents/lib/controller/libCppController.dylib ++LDFLAGS += -install_name @rpath/libCppController.dylib -Wl,-rpath,@loader_path + TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libCppController.dylib + endif + +@@ -121,21 +121,23 @@ all debug profile release: $(TARGET) + + ifeq ($(OSTYPE),darwin) + ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/,$(OBJECTS)) + ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/,$(OBJECTS)) + +-$(TARGET): $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib ++$(TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib + @echo "# creating fat" $(notdir $@) +- @lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib ++ @lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib + @codesign -s - $@ + + $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib: $(X86_64_OBJECTS) + @echo "# linking" $@ "(x86_64)" +- @$(CXX) -target x86_64-apple-macos12 $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" ++ @$(CXX) $(if $(target_platform),,-target x86_64-apple-macos12) $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" + + $(BUILD_GOAL_DIR)/arm64/libCppController.dylib: $(ARM64_OBJECTS) + @echo "# linking" $@ "(arm64)" +- @$(CXX) -target arm64-apple-macos12 $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" ++ @$(CXX) $(if $(target_platform),,-target arm64-apple-macos12) $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" + + else + +diff --git a/webots/src/controller/launcher/Makefile b/webots/src/controller/launcher/Makefile +index 6c9cf55..7cd02ff 100644 +--- a/webots/src/controller/launcher/Makefile ++++ b/webots/src/controller/launcher/Makefile +@@ -33,6 +33,8 @@ ifeq ($(OSTYPE),windows) + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/msys64/mingw64/bin/webots-controller.exe + else ifeq ($(OSTYPE),darwin) + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/Contents/MacOS/webots-controller ++# the environment's compiler, and room for the install name tool to rewrite rpaths ++LAUNCHER_CC = $(CC) -Wl,-headerpad_max_install_names + else + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/webots-controller + endif +@@ -43,6 +45,6 @@ release debug profile: $(CONTROLLER_LAUNCHER) + + $(CONTROLLER_LAUNCHER): webots_controller.c + @echo "# compiling" $< +- @gcc $(CFLAGS) webots_controller.c -o $@ ++ @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ + + FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) diff --git a/distros/lyrical/patch/ros2-webots-ros2-driver.patch b/distros/lyrical/patch/ros2-webots-ros2-driver.patch index 8d0f7ed9..e89340e0 100644 --- a/distros/lyrical/patch/ros2-webots-ros2-driver.patch +++ b/distros/lyrical/patch/ros2-webots-ros2-driver.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1f913c1..52dbf3e 100644 +index 1f913c1..18a0097 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -32,17 +32,14 @@ find_package(tinyxml2_vendor REQUIRED) +@@ -32,16 +32,25 @@ find_package(tinyxml2_vendor REQUIRED) find_package(TinyXML2 REQUIRED) find_package(yaml-cpp REQUIRED) @@ -16,7 +16,6 @@ index 1f913c1..52dbf3e 100644 - find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) -elseif($ENV{ROS_DISTRO} MATCHES "rolling") - find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) --endif() +# Upstream hardcodes an EXACT Python version per ROS_DISTRO matching whatever +# Python Ubuntu ships for that distro's release. conda-forge's Python version +# moves independently (currently 3.14 for rolling, not the 3.12 upstream @@ -25,6 +24,218 @@ index 1f913c1..52dbf3e 100644 +# multiarch pyconfig.h. Just find whatever Python 3 is active in the build +# environment instead of hardcoding a version tied to Ubuntu's release. +find_package(Python 3 REQUIRED COMPONENTS Development) ++ ++if(APPLE) ++ # The bundled Webots Makefiles write the macOS app bundle layout (Contents/lib/..., ++ # Contents/MacOS/webots-controller): map it onto the plain layout installed below. ++ file(CREATE_LINK . ${CMAKE_CURRENT_SOURCE_DIR}/webots/Contents SYMBOLIC) ++ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/webots/MacOS) ++ set(WEBOTS_RPATH_ORIGIN "@loader_path") ++ set(WEBOTS_CONTROLLER_LAUNCHER webots/MacOS/webots-controller) ++else() ++ set(WEBOTS_RPATH_ORIGIN "$ORIGIN") ++ set(WEBOTS_CONTROLLER_LAUNCHER webots/webots-controller) + endif() add_custom_target(compile-lib-controller ALL - COMMAND ${CMAKE_COMMAND} -E env "WEBOTS_HOME=${CMAKE_CURRENT_SOURCE_DIR}/webots" make release -f Makefile > /dev/null 2>&1 +@@ -91,7 +100,7 @@ ament_python_install_package(${PROJECT_NAME} + PACKAGE_DIR ${PROJECT_NAME}) + + # Driver +-set(CMAKE_INSTALL_RPATH "$ORIGIN/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_executable(driver + src/Driver.cpp + src/WebotsNode.cpp +@@ -161,7 +170,7 @@ install(TARGETS driver + ) + + # Dynamic IMU +-set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_library( + ${PROJECT_NAME}_imu + SHARED +@@ -200,7 +209,7 @@ install(TARGETS ${PROJECT_NAME}_imu + ) + + # Dynamic RGBD +-set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_library( + ${PROJECT_NAME}_rgbd + SHARED +@@ -279,7 +288,7 @@ install( + + # Install webots-controller script + install( +- PROGRAMS webots/webots-controller ++ PROGRAMS ${WEBOTS_CONTROLLER_LAUNCHER} + DESTINATION share/${PROJECT_NAME}/scripts + ) + +diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp +index 63a5e4b..1288e06 100644 +--- a/src/plugins/static/Ros2LightSensor.cpp ++++ b/src/plugins/static/Ros2LightSensor.cpp +@@ -74,8 +74,8 @@ namespace webots_ros2_driver { + // Find relative standard deviation in lookup table + double relativeStd = NAN; + for (int i = 0; i < mLookupTable.size() - 3; i += 3) +- if ((mLookupTable[i + 1] < rawValue < mLookupTable[i + 3 + 1]) || +- (mLookupTable[i + 1] > rawValue > mLookupTable[i + 3 + 1])) { ++ if ((mLookupTable[i + 1] < rawValue && rawValue < mLookupTable[i + 3 + 1]) || ++ (mLookupTable[i + 1] > rawValue && rawValue > mLookupTable[i + 3 + 1])) { + relativeStd = mLookupTable[i + 2]; + break; + } +diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include +index 461793b..704adf6 100644 +--- a/webots/resources/Makefile.include ++++ b/webots/resources/Makefile.include +@@ -210,15 +210,15 @@ endif + ifneq ($(C_SOURCES)$(CXX_SOURCES),) + ifdef BUILD_EXECUTABLE + MAIN_TARGET = $(NAME)$(EXE_EXTENSION) +- X86_64_LINKER = -target x86_64-apple-macos12 +- ARM64_LINKER = -target arm64-apple-macos12 ++ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) ++ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) + else + ifdef BUILD_STATIC_LIBRARY + MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(STATIC_LIB_EXTENSION) + else + MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(SHARED_LIB_EXTENSION) +- X86_64_LINKER = -target x86_64-apple-macos12 +- ARM64_LINKER = -target arm64-apple-macos12 ++ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) ++ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) + endif + endif + endif +@@ -405,8 +405,8 @@ endif + + ifeq ($(OSTYPE),darwin) + ifdef WEBOTS_LIBRARY +- INSTALL_NAME ?= @rpath/Contents/lib/controller/$(MAIN_TARGET) +- LFLAGS += -Xlinker -rpath -Xlinker @loader_path/.. -install_name $(INSTALL_NAME) ++ INSTALL_NAME ?= @rpath/$(MAIN_TARGET) ++ LFLAGS += -Xlinker -rpath -Xlinker @loader_path -install_name $(INSTALL_NAME) + else + CALLING_MAKEFILE_DIR := $(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))") + WEBOTS_RELATIVE_PATH = $(call computeRelativePath,"$(WEBOTS_HOME_PATH)","$(CALLING_MAKEFILE_DIR)") +@@ -549,16 +549,18 @@ endif + ###----------------------------------------------------------------------------- + + ifdef FAT_BINARY ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/, $(OBJECTS_LIST)) + ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/, $(OBJECTS_LIST)) + +-$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + @echo "# creating fat" $(notdir $@) +- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + +-$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + @echo "# creating fat" $(notdir $@) +- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + + $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET): $(X86_64_OBJECTS) $(LINK_DEPENDENCIES) + @echo "# linking" $(notdir $@) "(x86_64)" +diff --git a/webots/src/controller/c/Makefile b/webots/src/controller/c/Makefile +index 14a32c7..bfceaf5 100644 +--- a/webots/src/controller/c/Makefile ++++ b/webots/src/controller/c/Makefile +@@ -44,7 +44,7 @@ endif + ifeq ($(OSTYPE),darwin) + CFLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -fpascal-strings -Wno-deprecated-declarations -Wno-single-bit-bitfield-constant-conversion -I/Developer/Headers/FlatCarbon -Wall -fno-common -D LIBCONTROLLER_VERSION='$(LIBCONTROLLER_VERSION)' + INCLUDE = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include +-LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/Contents/lib/controller/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 ++LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 + SHARED_LIBS = -lz + TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib + CC = gcc +@@ -144,12 +144,14 @@ endif + endif + + ifeq ($(OSTYPE),darwin) ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(OBJDIR)/x86_64/, $(OBJECTS)) + ARM64_OBJECTS = $(addprefix $(OBJDIR)/arm64/, $(OBJECTS)) + +-$(TARGET): $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib ++$(TARGET): $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib + @echo "# creating fat binary: $$"\(WEBOTS_HOME\)/lib/controller/libController.dylib +- @lipo -create -output $(TARGET) $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib ++ @lipo -create -output $(TARGET) $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib + @chmod a-x $@ + @codesign -s - $@ + +diff --git a/webots/src/controller/cpp/Makefile b/webots/src/controller/cpp/Makefile +index dde0a6e..910fb01 100644 +--- a/webots/src/controller/cpp/Makefile ++++ b/webots/src/controller/cpp/Makefile +@@ -100,7 +100,7 @@ SHAREDLIBS = -L$(WEBOTS_CONTROLLER_LIB_PATH) -lController + CPPFLAGS = -c -fPIC -Wall -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) + CPPINCLUDES = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include/controller/cpp + LIBCONTROLLER = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib +-LDFLAGS += -install_name @rpath/Contents/lib/controller/libCppController.dylib ++LDFLAGS += -install_name @rpath/libCppController.dylib -Wl,-rpath,@loader_path + TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libCppController.dylib + endif + +@@ -121,21 +121,23 @@ all debug profile release: $(TARGET) + + ifeq ($(OSTYPE),darwin) + ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/,$(OBJECTS)) + ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/,$(OBJECTS)) + +-$(TARGET): $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib ++$(TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib + @echo "# creating fat" $(notdir $@) +- @lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib ++ @lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib + @codesign -s - $@ + + $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib: $(X86_64_OBJECTS) + @echo "# linking" $@ "(x86_64)" +- @$(CXX) -target x86_64-apple-macos12 $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" ++ @$(CXX) $(if $(target_platform),,-target x86_64-apple-macos12) $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" + + $(BUILD_GOAL_DIR)/arm64/libCppController.dylib: $(ARM64_OBJECTS) + @echo "# linking" $@ "(arm64)" +- @$(CXX) -target arm64-apple-macos12 $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" ++ @$(CXX) $(if $(target_platform),,-target arm64-apple-macos12) $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" + + else + +diff --git a/webots/src/controller/launcher/Makefile b/webots/src/controller/launcher/Makefile +index 6c9cf55..7cd02ff 100644 +--- a/webots/src/controller/launcher/Makefile ++++ b/webots/src/controller/launcher/Makefile +@@ -33,6 +33,8 @@ ifeq ($(OSTYPE),windows) + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/msys64/mingw64/bin/webots-controller.exe + else ifeq ($(OSTYPE),darwin) + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/Contents/MacOS/webots-controller ++# the environment's compiler, and room for the install name tool to rewrite rpaths ++LAUNCHER_CC = $(CC) -Wl,-headerpad_max_install_names + else + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/webots-controller + endif +@@ -43,6 +45,6 @@ release debug profile: $(CONTROLLER_LAUNCHER) + + $(CONTROLLER_LAUNCHER): webots_controller.c + @echo "# compiling" $< +- @gcc $(CFLAGS) webots_controller.c -o $@ ++ @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ + + FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) diff --git a/distros/rolling/patch/ros2-webots-ros2-driver.patch b/distros/rolling/patch/ros2-webots-ros2-driver.patch index 8d0f7ed9..e89340e0 100644 --- a/distros/rolling/patch/ros2-webots-ros2-driver.patch +++ b/distros/rolling/patch/ros2-webots-ros2-driver.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1f913c1..52dbf3e 100644 +index 1f913c1..18a0097 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -32,17 +32,14 @@ find_package(tinyxml2_vendor REQUIRED) +@@ -32,16 +32,25 @@ find_package(tinyxml2_vendor REQUIRED) find_package(TinyXML2 REQUIRED) find_package(yaml-cpp REQUIRED) @@ -16,7 +16,6 @@ index 1f913c1..52dbf3e 100644 - find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) -elseif($ENV{ROS_DISTRO} MATCHES "rolling") - find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) --endif() +# Upstream hardcodes an EXACT Python version per ROS_DISTRO matching whatever +# Python Ubuntu ships for that distro's release. conda-forge's Python version +# moves independently (currently 3.14 for rolling, not the 3.12 upstream @@ -25,6 +24,218 @@ index 1f913c1..52dbf3e 100644 +# multiarch pyconfig.h. Just find whatever Python 3 is active in the build +# environment instead of hardcoding a version tied to Ubuntu's release. +find_package(Python 3 REQUIRED COMPONENTS Development) ++ ++if(APPLE) ++ # The bundled Webots Makefiles write the macOS app bundle layout (Contents/lib/..., ++ # Contents/MacOS/webots-controller): map it onto the plain layout installed below. ++ file(CREATE_LINK . ${CMAKE_CURRENT_SOURCE_DIR}/webots/Contents SYMBOLIC) ++ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/webots/MacOS) ++ set(WEBOTS_RPATH_ORIGIN "@loader_path") ++ set(WEBOTS_CONTROLLER_LAUNCHER webots/MacOS/webots-controller) ++else() ++ set(WEBOTS_RPATH_ORIGIN "$ORIGIN") ++ set(WEBOTS_CONTROLLER_LAUNCHER webots/webots-controller) + endif() add_custom_target(compile-lib-controller ALL - COMMAND ${CMAKE_COMMAND} -E env "WEBOTS_HOME=${CMAKE_CURRENT_SOURCE_DIR}/webots" make release -f Makefile > /dev/null 2>&1 +@@ -91,7 +100,7 @@ ament_python_install_package(${PROJECT_NAME} + PACKAGE_DIR ${PROJECT_NAME}) + + # Driver +-set(CMAKE_INSTALL_RPATH "$ORIGIN/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_executable(driver + src/Driver.cpp + src/WebotsNode.cpp +@@ -161,7 +170,7 @@ install(TARGETS driver + ) + + # Dynamic IMU +-set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_library( + ${PROJECT_NAME}_imu + SHARED +@@ -200,7 +209,7 @@ install(TARGETS ${PROJECT_NAME}_imu + ) + + # Dynamic RGBD +-set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 ++set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 + add_library( + ${PROJECT_NAME}_rgbd + SHARED +@@ -279,7 +288,7 @@ install( + + # Install webots-controller script + install( +- PROGRAMS webots/webots-controller ++ PROGRAMS ${WEBOTS_CONTROLLER_LAUNCHER} + DESTINATION share/${PROJECT_NAME}/scripts + ) + +diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp +index 63a5e4b..1288e06 100644 +--- a/src/plugins/static/Ros2LightSensor.cpp ++++ b/src/plugins/static/Ros2LightSensor.cpp +@@ -74,8 +74,8 @@ namespace webots_ros2_driver { + // Find relative standard deviation in lookup table + double relativeStd = NAN; + for (int i = 0; i < mLookupTable.size() - 3; i += 3) +- if ((mLookupTable[i + 1] < rawValue < mLookupTable[i + 3 + 1]) || +- (mLookupTable[i + 1] > rawValue > mLookupTable[i + 3 + 1])) { ++ if ((mLookupTable[i + 1] < rawValue && rawValue < mLookupTable[i + 3 + 1]) || ++ (mLookupTable[i + 1] > rawValue && rawValue > mLookupTable[i + 3 + 1])) { + relativeStd = mLookupTable[i + 2]; + break; + } +diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include +index 461793b..704adf6 100644 +--- a/webots/resources/Makefile.include ++++ b/webots/resources/Makefile.include +@@ -210,15 +210,15 @@ endif + ifneq ($(C_SOURCES)$(CXX_SOURCES),) + ifdef BUILD_EXECUTABLE + MAIN_TARGET = $(NAME)$(EXE_EXTENSION) +- X86_64_LINKER = -target x86_64-apple-macos12 +- ARM64_LINKER = -target arm64-apple-macos12 ++ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) ++ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) + else + ifdef BUILD_STATIC_LIBRARY + MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(STATIC_LIB_EXTENSION) + else + MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(SHARED_LIB_EXTENSION) +- X86_64_LINKER = -target x86_64-apple-macos12 +- ARM64_LINKER = -target arm64-apple-macos12 ++ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) ++ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) + endif + endif + endif +@@ -405,8 +405,8 @@ endif + + ifeq ($(OSTYPE),darwin) + ifdef WEBOTS_LIBRARY +- INSTALL_NAME ?= @rpath/Contents/lib/controller/$(MAIN_TARGET) +- LFLAGS += -Xlinker -rpath -Xlinker @loader_path/.. -install_name $(INSTALL_NAME) ++ INSTALL_NAME ?= @rpath/$(MAIN_TARGET) ++ LFLAGS += -Xlinker -rpath -Xlinker @loader_path -install_name $(INSTALL_NAME) + else + CALLING_MAKEFILE_DIR := $(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))") + WEBOTS_RELATIVE_PATH = $(call computeRelativePath,"$(WEBOTS_HOME_PATH)","$(CALLING_MAKEFILE_DIR)") +@@ -549,16 +549,18 @@ endif + ###----------------------------------------------------------------------------- + + ifdef FAT_BINARY ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/, $(OBJECTS_LIST)) + ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/, $(OBJECTS_LIST)) + +-$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + @echo "# creating fat" $(notdir $@) +- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + +-$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + @echo "# creating fat" $(notdir $@) +- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) ++ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) + + $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET): $(X86_64_OBJECTS) $(LINK_DEPENDENCIES) + @echo "# linking" $(notdir $@) "(x86_64)" +diff --git a/webots/src/controller/c/Makefile b/webots/src/controller/c/Makefile +index 14a32c7..bfceaf5 100644 +--- a/webots/src/controller/c/Makefile ++++ b/webots/src/controller/c/Makefile +@@ -44,7 +44,7 @@ endif + ifeq ($(OSTYPE),darwin) + CFLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -fpascal-strings -Wno-deprecated-declarations -Wno-single-bit-bitfield-constant-conversion -I/Developer/Headers/FlatCarbon -Wall -fno-common -D LIBCONTROLLER_VERSION='$(LIBCONTROLLER_VERSION)' + INCLUDE = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include +-LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/Contents/lib/controller/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 ++LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 + SHARED_LIBS = -lz + TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib + CC = gcc +@@ -144,12 +144,14 @@ endif + endif + + ifeq ($(OSTYPE),darwin) ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(OBJDIR)/x86_64/, $(OBJECTS)) + ARM64_OBJECTS = $(addprefix $(OBJDIR)/arm64/, $(OBJECTS)) + +-$(TARGET): $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib ++$(TARGET): $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib + @echo "# creating fat binary: $$"\(WEBOTS_HOME\)/lib/controller/libController.dylib +- @lipo -create -output $(TARGET) $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib ++ @lipo -create -output $(TARGET) $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib + @chmod a-x $@ + @codesign -s - $@ + +diff --git a/webots/src/controller/cpp/Makefile b/webots/src/controller/cpp/Makefile +index dde0a6e..910fb01 100644 +--- a/webots/src/controller/cpp/Makefile ++++ b/webots/src/controller/cpp/Makefile +@@ -100,7 +100,7 @@ SHAREDLIBS = -L$(WEBOTS_CONTROLLER_LIB_PATH) -lController + CPPFLAGS = -c -fPIC -Wall -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) + CPPINCLUDES = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include/controller/cpp + LIBCONTROLLER = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib +-LDFLAGS += -install_name @rpath/Contents/lib/controller/libCppController.dylib ++LDFLAGS += -install_name @rpath/libCppController.dylib -Wl,-rpath,@loader_path + TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libCppController.dylib + endif + +@@ -121,21 +121,23 @@ all debug profile release: $(TARGET) + + ifeq ($(OSTYPE),darwin) + ++# conda builds for one architecture (target_platform), not universal binaries ++WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) + X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/,$(OBJECTS)) + ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/,$(OBJECTS)) + +-$(TARGET): $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib ++$(TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib + @echo "# creating fat" $(notdir $@) +- @lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib ++ @lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib + @codesign -s - $@ + + $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib: $(X86_64_OBJECTS) + @echo "# linking" $@ "(x86_64)" +- @$(CXX) -target x86_64-apple-macos12 $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" ++ @$(CXX) $(if $(target_platform),,-target x86_64-apple-macos12) $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" + + $(BUILD_GOAL_DIR)/arm64/libCppController.dylib: $(ARM64_OBJECTS) + @echo "# linking" $@ "(arm64)" +- @$(CXX) -target arm64-apple-macos12 $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" ++ @$(CXX) $(if $(target_platform),,-target arm64-apple-macos12) $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" + + else + +diff --git a/webots/src/controller/launcher/Makefile b/webots/src/controller/launcher/Makefile +index 6c9cf55..7cd02ff 100644 +--- a/webots/src/controller/launcher/Makefile ++++ b/webots/src/controller/launcher/Makefile +@@ -33,6 +33,8 @@ ifeq ($(OSTYPE),windows) + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/msys64/mingw64/bin/webots-controller.exe + else ifeq ($(OSTYPE),darwin) + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/Contents/MacOS/webots-controller ++# the environment's compiler, and room for the install name tool to rewrite rpaths ++LAUNCHER_CC = $(CC) -Wl,-headerpad_max_install_names + else + CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/webots-controller + endif +@@ -43,6 +45,6 @@ release debug profile: $(CONTROLLER_LAUNCHER) + + $(CONTROLLER_LAUNCHER): webots_controller.c + @echo "# compiling" $< +- @gcc $(CFLAGS) webots_controller.c -o $@ ++ @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ + + FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) diff --git a/shared/vinca.yaml b/shared/vinca.yaml index c93bc085..80aec924 100644 --- a/shared/vinca.yaml +++ b/shared/vinca.yaml @@ -517,6 +517,10 @@ packages_select_by_deps: - libfranka # conda-forge's libfranka is only published for linux-64, not linux-aarch64 - webots_ros2 # Cyberbotics + - if: osx + then: + - webots_ros2_driver # the driver only; requested in https://github.com/RoboStack/robostack/issues/102 + - if: not win then: - as2_cli From 7d4ede311b6780e26d9efbdf5e1c8479a7c27fe6 Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Mon, 19 Oct 2026 11:23:52 +1000 Subject: [PATCH 2/4] webots_ros2_driver on macOS: runtime fixes from a Webots run [skip ci] Found running the webots_ros2_mavic demo against Webots R2025a on macOS: - utils.py: Webots.app's version.txt is in Contents/Resources - webots_launcher.py: start Contents/MacOS/webots - controller/wb.py, vehicle/driver.py: the ROS nodes point WEBOTS_HOME at this package's prefix, so load the controller libraries from lib/controller - Driver.cpp: the /proc//cmdline check (only for a deprecation warning) is Linux-only; without /proc it aborted the driver - webots_ros2_importer: run-depend on pillow (urdf2webots imports PIL; the package.xml doesn't declare it, on any platform) Co-Authored-By: Claude Opus 5.5 --- .../patch/ros2-webots-ros2-driver.patch | 73 +++++++++++++++++++ .../jazzy/patch/ros2-webots-ros2-driver.patch | 73 +++++++++++++++++++ .../patch/ros2-webots-ros2-driver.patch | 73 +++++++++++++++++++ .../patch/ros2-webots-ros2-driver.patch | 73 +++++++++++++++++++ shared/patch/dependencies.yaml | 3 + 5 files changed, 295 insertions(+) diff --git a/distros/humble/patch/ros2-webots-ros2-driver.patch b/distros/humble/patch/ros2-webots-ros2-driver.patch index 3040d000..da618768 100644 --- a/distros/humble/patch/ros2-webots-ros2-driver.patch +++ b/distros/humble/patch/ros2-webots-ros2-driver.patch @@ -71,6 +71,26 @@ index 693d9ed..78ef33c 100644 DESTINATION share/${PROJECT_NAME}/scripts ) +diff --git a/src/Driver.cpp b/src/Driver.cpp +index cf79908..22069db 100644 +--- a/src/Driver.cpp ++++ b/src/Driver.cpp +@@ -46,6 +46,7 @@ int main(int argc, char **argv) { + std::make_shared(robotName, nodeOptions); + node->init(); + ++#if defined(__linux__) // /proc//cmdline is Linux-only + // The parent process must be ros2 run. Declaring from launch file is deprecated. Remove with 2024.0.0. + const pid_t parentPid = getppid(); + char buffer[4096]; +@@ -65,6 +66,7 @@ int main(int argc, char **argv) { + if (strstr(buffer, "ros2 launch")) + RCLCPP_WARN(node->get_logger(), "\033[33mThe direct declaration of the driver node in the launch file is deprecated. " + "Please use the new WebotsController node instead.\033[0m"); ++#endif + + RCLCPP_INFO(node->get_logger(), "Controller successfully connected to robot in Webots simulation."); + while (true) { diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp index 63a5e4b..1288e06 100644 --- a/src/plugins/static/Ros2LightSensor.cpp @@ -86,6 +106,32 @@ index 63a5e4b..1288e06 100644 relativeStd = mLookupTable[i + 2]; break; } +diff --git a/webots/lib/controller/python/controller/wb.py b/webots/lib/controller/python/controller/wb.py +index 48c9506..64f07de 100644 +--- a/webots/lib/controller/python/controller/wb.py ++++ b/webots/lib/controller/python/controller/wb.py +@@ -21,7 +21,7 @@ if sys.platform == 'linux' or sys.platform == 'linux2': + elif sys.platform == 'win32': + path = os.path.join('lib', 'controller', 'Controller.dll') + elif sys.platform == 'darwin': +- path = os.path.join('Contents', 'lib', 'controller', 'libController.dylib') ++ path = os.path.join('lib', 'controller', 'libController.dylib') + + wb = ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path)) + +diff --git a/webots/lib/controller/python/vehicle/driver.py b/webots/lib/controller/python/vehicle/driver.py +index 6d70788..5123beb 100644 +--- a/webots/lib/controller/python/vehicle/driver.py ++++ b/webots/lib/controller/python/vehicle/driver.py +@@ -43,7 +43,7 @@ class Driver(Supervisor): + car = 'car.dll' + driver = 'driver.dll' + elif sys.platform == 'darwin': +- path = os.path.join('Contents', 'lib', 'controller') ++ path = os.path.join('lib', 'controller') + car = 'libcar.dylib' + driver = 'libdriver.dylib' + ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path, car)) diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include index 461793b..704adf6 100644 --- a/webots/resources/Makefile.include @@ -236,3 +282,30 @@ index 6c9cf55..7cd02ff 100644 + @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) +diff --git a/webots_ros2_driver/utils.py b/webots_ros2_driver/utils.py +index db7e2b6..a1cf870 100644 +--- a/webots_ros2_driver/utils.py ++++ b/webots_ros2_driver/utils.py +@@ -46,6 +46,9 @@ class WebotsVersion: + @staticmethod + def from_path(path): + version_file = os.path.join(path, 'resources', 'version.txt') ++ if sys.platform == 'darwin' and not os.path.isfile(version_file): ++ # the macOS app bundle: /Applications/Webots.app/Contents/Resources ++ version_file = os.path.join(path, 'Contents', 'Resources', 'version.txt') + if not os.path.isfile(version_file): + return None + with open(version_file, 'r') as f: +diff --git a/webots_ros2_driver/webots_launcher.py b/webots_ros2_driver/webots_launcher.py +index 3952906..12c493c 100644 +--- a/webots_ros2_driver/webots_launcher.py ++++ b/webots_ros2_driver/webots_launcher.py +@@ -72,6 +72,8 @@ class WebotsLauncher(ExecuteProcess): + webots_path = get_webots_home() + if self.__is_wsl: + webots_path = os.path.join(webots_path, 'msys64', 'mingw64', 'bin', 'webots.exe') ++ elif sys.platform == 'darwin': ++ webots_path = os.path.join(webots_path, 'Contents', 'MacOS', 'webots') + else: + webots_path = os.path.join(webots_path, 'webots') + else: diff --git a/distros/jazzy/patch/ros2-webots-ros2-driver.patch b/distros/jazzy/patch/ros2-webots-ros2-driver.patch index 3040d000..da618768 100644 --- a/distros/jazzy/patch/ros2-webots-ros2-driver.patch +++ b/distros/jazzy/patch/ros2-webots-ros2-driver.patch @@ -71,6 +71,26 @@ index 693d9ed..78ef33c 100644 DESTINATION share/${PROJECT_NAME}/scripts ) +diff --git a/src/Driver.cpp b/src/Driver.cpp +index cf79908..22069db 100644 +--- a/src/Driver.cpp ++++ b/src/Driver.cpp +@@ -46,6 +46,7 @@ int main(int argc, char **argv) { + std::make_shared(robotName, nodeOptions); + node->init(); + ++#if defined(__linux__) // /proc//cmdline is Linux-only + // The parent process must be ros2 run. Declaring from launch file is deprecated. Remove with 2024.0.0. + const pid_t parentPid = getppid(); + char buffer[4096]; +@@ -65,6 +66,7 @@ int main(int argc, char **argv) { + if (strstr(buffer, "ros2 launch")) + RCLCPP_WARN(node->get_logger(), "\033[33mThe direct declaration of the driver node in the launch file is deprecated. " + "Please use the new WebotsController node instead.\033[0m"); ++#endif + + RCLCPP_INFO(node->get_logger(), "Controller successfully connected to robot in Webots simulation."); + while (true) { diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp index 63a5e4b..1288e06 100644 --- a/src/plugins/static/Ros2LightSensor.cpp @@ -86,6 +106,32 @@ index 63a5e4b..1288e06 100644 relativeStd = mLookupTable[i + 2]; break; } +diff --git a/webots/lib/controller/python/controller/wb.py b/webots/lib/controller/python/controller/wb.py +index 48c9506..64f07de 100644 +--- a/webots/lib/controller/python/controller/wb.py ++++ b/webots/lib/controller/python/controller/wb.py +@@ -21,7 +21,7 @@ if sys.platform == 'linux' or sys.platform == 'linux2': + elif sys.platform == 'win32': + path = os.path.join('lib', 'controller', 'Controller.dll') + elif sys.platform == 'darwin': +- path = os.path.join('Contents', 'lib', 'controller', 'libController.dylib') ++ path = os.path.join('lib', 'controller', 'libController.dylib') + + wb = ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path)) + +diff --git a/webots/lib/controller/python/vehicle/driver.py b/webots/lib/controller/python/vehicle/driver.py +index 6d70788..5123beb 100644 +--- a/webots/lib/controller/python/vehicle/driver.py ++++ b/webots/lib/controller/python/vehicle/driver.py +@@ -43,7 +43,7 @@ class Driver(Supervisor): + car = 'car.dll' + driver = 'driver.dll' + elif sys.platform == 'darwin': +- path = os.path.join('Contents', 'lib', 'controller') ++ path = os.path.join('lib', 'controller') + car = 'libcar.dylib' + driver = 'libdriver.dylib' + ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path, car)) diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include index 461793b..704adf6 100644 --- a/webots/resources/Makefile.include @@ -236,3 +282,30 @@ index 6c9cf55..7cd02ff 100644 + @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) +diff --git a/webots_ros2_driver/utils.py b/webots_ros2_driver/utils.py +index db7e2b6..a1cf870 100644 +--- a/webots_ros2_driver/utils.py ++++ b/webots_ros2_driver/utils.py +@@ -46,6 +46,9 @@ class WebotsVersion: + @staticmethod + def from_path(path): + version_file = os.path.join(path, 'resources', 'version.txt') ++ if sys.platform == 'darwin' and not os.path.isfile(version_file): ++ # the macOS app bundle: /Applications/Webots.app/Contents/Resources ++ version_file = os.path.join(path, 'Contents', 'Resources', 'version.txt') + if not os.path.isfile(version_file): + return None + with open(version_file, 'r') as f: +diff --git a/webots_ros2_driver/webots_launcher.py b/webots_ros2_driver/webots_launcher.py +index 3952906..12c493c 100644 +--- a/webots_ros2_driver/webots_launcher.py ++++ b/webots_ros2_driver/webots_launcher.py +@@ -72,6 +72,8 @@ class WebotsLauncher(ExecuteProcess): + webots_path = get_webots_home() + if self.__is_wsl: + webots_path = os.path.join(webots_path, 'msys64', 'mingw64', 'bin', 'webots.exe') ++ elif sys.platform == 'darwin': ++ webots_path = os.path.join(webots_path, 'Contents', 'MacOS', 'webots') + else: + webots_path = os.path.join(webots_path, 'webots') + else: diff --git a/distros/lyrical/patch/ros2-webots-ros2-driver.patch b/distros/lyrical/patch/ros2-webots-ros2-driver.patch index e89340e0..37269f3a 100644 --- a/distros/lyrical/patch/ros2-webots-ros2-driver.patch +++ b/distros/lyrical/patch/ros2-webots-ros2-driver.patch @@ -74,6 +74,26 @@ index 1f913c1..18a0097 100644 DESTINATION share/${PROJECT_NAME}/scripts ) +diff --git a/src/Driver.cpp b/src/Driver.cpp +index cf79908..22069db 100644 +--- a/src/Driver.cpp ++++ b/src/Driver.cpp +@@ -46,6 +46,7 @@ int main(int argc, char **argv) { + std::make_shared(robotName, nodeOptions); + node->init(); + ++#if defined(__linux__) // /proc//cmdline is Linux-only + // The parent process must be ros2 run. Declaring from launch file is deprecated. Remove with 2024.0.0. + const pid_t parentPid = getppid(); + char buffer[4096]; +@@ -65,6 +66,7 @@ int main(int argc, char **argv) { + if (strstr(buffer, "ros2 launch")) + RCLCPP_WARN(node->get_logger(), "\033[33mThe direct declaration of the driver node in the launch file is deprecated. " + "Please use the new WebotsController node instead.\033[0m"); ++#endif + + RCLCPP_INFO(node->get_logger(), "Controller successfully connected to robot in Webots simulation."); + while (true) { diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp index 63a5e4b..1288e06 100644 --- a/src/plugins/static/Ros2LightSensor.cpp @@ -89,6 +109,32 @@ index 63a5e4b..1288e06 100644 relativeStd = mLookupTable[i + 2]; break; } +diff --git a/webots/lib/controller/python/controller/wb.py b/webots/lib/controller/python/controller/wb.py +index 48c9506..64f07de 100644 +--- a/webots/lib/controller/python/controller/wb.py ++++ b/webots/lib/controller/python/controller/wb.py +@@ -21,7 +21,7 @@ if sys.platform == 'linux' or sys.platform == 'linux2': + elif sys.platform == 'win32': + path = os.path.join('lib', 'controller', 'Controller.dll') + elif sys.platform == 'darwin': +- path = os.path.join('Contents', 'lib', 'controller', 'libController.dylib') ++ path = os.path.join('lib', 'controller', 'libController.dylib') + + wb = ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path)) + +diff --git a/webots/lib/controller/python/vehicle/driver.py b/webots/lib/controller/python/vehicle/driver.py +index 6d70788..5123beb 100644 +--- a/webots/lib/controller/python/vehicle/driver.py ++++ b/webots/lib/controller/python/vehicle/driver.py +@@ -43,7 +43,7 @@ class Driver(Supervisor): + car = 'car.dll' + driver = 'driver.dll' + elif sys.platform == 'darwin': +- path = os.path.join('Contents', 'lib', 'controller') ++ path = os.path.join('lib', 'controller') + car = 'libcar.dylib' + driver = 'libdriver.dylib' + ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path, car)) diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include index 461793b..704adf6 100644 --- a/webots/resources/Makefile.include @@ -239,3 +285,30 @@ index 6c9cf55..7cd02ff 100644 + @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) +diff --git a/webots_ros2_driver/utils.py b/webots_ros2_driver/utils.py +index b6a9a54..87acc5f 100644 +--- a/webots_ros2_driver/utils.py ++++ b/webots_ros2_driver/utils.py +@@ -46,6 +46,9 @@ class WebotsVersion: + @staticmethod + def from_path(path): + version_file = os.path.join(path, 'resources', 'version.txt') ++ if sys.platform == 'darwin' and not os.path.isfile(version_file): ++ # the macOS app bundle: /Applications/Webots.app/Contents/Resources ++ version_file = os.path.join(path, 'Contents', 'Resources', 'version.txt') + if not os.path.isfile(version_file): + return None + with open(version_file, 'r') as f: +diff --git a/webots_ros2_driver/webots_launcher.py b/webots_ros2_driver/webots_launcher.py +index 3952906..12c493c 100644 +--- a/webots_ros2_driver/webots_launcher.py ++++ b/webots_ros2_driver/webots_launcher.py +@@ -72,6 +72,8 @@ class WebotsLauncher(ExecuteProcess): + webots_path = get_webots_home() + if self.__is_wsl: + webots_path = os.path.join(webots_path, 'msys64', 'mingw64', 'bin', 'webots.exe') ++ elif sys.platform == 'darwin': ++ webots_path = os.path.join(webots_path, 'Contents', 'MacOS', 'webots') + else: + webots_path = os.path.join(webots_path, 'webots') + else: diff --git a/distros/rolling/patch/ros2-webots-ros2-driver.patch b/distros/rolling/patch/ros2-webots-ros2-driver.patch index e89340e0..37269f3a 100644 --- a/distros/rolling/patch/ros2-webots-ros2-driver.patch +++ b/distros/rolling/patch/ros2-webots-ros2-driver.patch @@ -74,6 +74,26 @@ index 1f913c1..18a0097 100644 DESTINATION share/${PROJECT_NAME}/scripts ) +diff --git a/src/Driver.cpp b/src/Driver.cpp +index cf79908..22069db 100644 +--- a/src/Driver.cpp ++++ b/src/Driver.cpp +@@ -46,6 +46,7 @@ int main(int argc, char **argv) { + std::make_shared(robotName, nodeOptions); + node->init(); + ++#if defined(__linux__) // /proc//cmdline is Linux-only + // The parent process must be ros2 run. Declaring from launch file is deprecated. Remove with 2024.0.0. + const pid_t parentPid = getppid(); + char buffer[4096]; +@@ -65,6 +66,7 @@ int main(int argc, char **argv) { + if (strstr(buffer, "ros2 launch")) + RCLCPP_WARN(node->get_logger(), "\033[33mThe direct declaration of the driver node in the launch file is deprecated. " + "Please use the new WebotsController node instead.\033[0m"); ++#endif + + RCLCPP_INFO(node->get_logger(), "Controller successfully connected to robot in Webots simulation."); + while (true) { diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp index 63a5e4b..1288e06 100644 --- a/src/plugins/static/Ros2LightSensor.cpp @@ -89,6 +109,32 @@ index 63a5e4b..1288e06 100644 relativeStd = mLookupTable[i + 2]; break; } +diff --git a/webots/lib/controller/python/controller/wb.py b/webots/lib/controller/python/controller/wb.py +index 48c9506..64f07de 100644 +--- a/webots/lib/controller/python/controller/wb.py ++++ b/webots/lib/controller/python/controller/wb.py +@@ -21,7 +21,7 @@ if sys.platform == 'linux' or sys.platform == 'linux2': + elif sys.platform == 'win32': + path = os.path.join('lib', 'controller', 'Controller.dll') + elif sys.platform == 'darwin': +- path = os.path.join('Contents', 'lib', 'controller', 'libController.dylib') ++ path = os.path.join('lib', 'controller', 'libController.dylib') + + wb = ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path)) + +diff --git a/webots/lib/controller/python/vehicle/driver.py b/webots/lib/controller/python/vehicle/driver.py +index 6d70788..5123beb 100644 +--- a/webots/lib/controller/python/vehicle/driver.py ++++ b/webots/lib/controller/python/vehicle/driver.py +@@ -43,7 +43,7 @@ class Driver(Supervisor): + car = 'car.dll' + driver = 'driver.dll' + elif sys.platform == 'darwin': +- path = os.path.join('Contents', 'lib', 'controller') ++ path = os.path.join('lib', 'controller') + car = 'libcar.dylib' + driver = 'libdriver.dylib' + ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path, car)) diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include index 461793b..704adf6 100644 --- a/webots/resources/Makefile.include @@ -239,3 +285,30 @@ index 6c9cf55..7cd02ff 100644 + @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) +diff --git a/webots_ros2_driver/utils.py b/webots_ros2_driver/utils.py +index b6a9a54..87acc5f 100644 +--- a/webots_ros2_driver/utils.py ++++ b/webots_ros2_driver/utils.py +@@ -46,6 +46,9 @@ class WebotsVersion: + @staticmethod + def from_path(path): + version_file = os.path.join(path, 'resources', 'version.txt') ++ if sys.platform == 'darwin' and not os.path.isfile(version_file): ++ # the macOS app bundle: /Applications/Webots.app/Contents/Resources ++ version_file = os.path.join(path, 'Contents', 'Resources', 'version.txt') + if not os.path.isfile(version_file): + return None + with open(version_file, 'r') as f: +diff --git a/webots_ros2_driver/webots_launcher.py b/webots_ros2_driver/webots_launcher.py +index 3952906..12c493c 100644 +--- a/webots_ros2_driver/webots_launcher.py ++++ b/webots_ros2_driver/webots_launcher.py +@@ -72,6 +72,8 @@ class WebotsLauncher(ExecuteProcess): + webots_path = get_webots_home() + if self.__is_wsl: + webots_path = os.path.join(webots_path, 'msys64', 'mingw64', 'bin', 'webots.exe') ++ elif sys.platform == 'darwin': ++ webots_path = os.path.join(webots_path, 'Contents', 'MacOS', 'webots') + else: + webots_path = os.path.join(webots_path, 'webots') + else: diff --git a/shared/patch/dependencies.yaml b/shared/patch/dependencies.yaml index 0a42505a..6323356a 100644 --- a/shared/patch/dependencies.yaml +++ b/shared/patch/dependencies.yaml @@ -148,6 +148,9 @@ tvm_vendor: add_host: ["libblas", "openblas", "libcblas"] velodyne_pointcloud: add_host: ["libboost-devel"] +webots_ros2_importer: + # urdf2webots imports PIL, but the package.xml doesn't declare python3-pil + add_run: ["pillow"] yaml_cpp_vendor: add_host: ["yaml-cpp"] add_run: ["yaml-cpp"] From 27780a4056e187937745a1eaa67007a3877180fe Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Mon, 19 Oct 2026 18:33:21 +1000 Subject: [PATCH 3/4] webots_ros2_driver: recipe test for the bundled controller libraries [skip ci] Turns the local checks of this PR into a recipe test, so later rebuilds keep them. Co-Authored-By: Claude Opus 5.5 --- shared/tests/ros2-webots-ros2-driver.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 shared/tests/ros2-webots-ros2-driver.yaml diff --git a/shared/tests/ros2-webots-ros2-driver.yaml b/shared/tests/ros2-webots-ros2-driver.yaml new file mode 100644 index 00000000..2ba26999 --- /dev/null +++ b/shared/tests/ros2-webots-ros2-driver.yaml @@ -0,0 +1,8 @@ +tests: + # The bundled Webots controller libraries are built and installed (on macOS by our patch, + # which maps the Makefiles' app bundle layout onto the plain one). + - if: unix + then: + script: + - python -c "import glob, os; assert glob.glob(os.path.join(os.environ['PREFIX'], 'lib', 'controller', 'libController.*'))" + - python -c "import webots_ros2_driver.utils" From d44f7a0658d0e57a4e4ebfd14bb8fa68aa801370 Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Tue, 20 Oct 2026 09:05:27 +1000 Subject: [PATCH 4/4] webots_ros2_driver: shared patch for 2025.0.1, distro ones only for 2025.0.0 [skip ci] lyrical and rolling (2025.0.1) had the same patch: it becomes the shared one, and humble and jazzy (2025.0.0) keep theirs until they get 2025.0.1. No distribution's patch content changes. Co-Authored-By: Claude Opus 5.5 --- .../patch/ros2-webots-ros2-driver.patch | 314 ------------------ .../patch/ros2-webots-ros2-driver.patch | 0 2 files changed, 314 deletions(-) delete mode 100644 distros/rolling/patch/ros2-webots-ros2-driver.patch rename {distros/lyrical => shared}/patch/ros2-webots-ros2-driver.patch (100%) diff --git a/distros/rolling/patch/ros2-webots-ros2-driver.patch b/distros/rolling/patch/ros2-webots-ros2-driver.patch deleted file mode 100644 index 37269f3a..00000000 --- a/distros/rolling/patch/ros2-webots-ros2-driver.patch +++ /dev/null @@ -1,314 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1f913c1..18a0097 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -32,16 +32,25 @@ find_package(tinyxml2_vendor REQUIRED) - find_package(TinyXML2 REQUIRED) - find_package(yaml-cpp REQUIRED) - --if($ENV{ROS_DISTRO} MATCHES "humble") -- find_package(Python 3.10 EXACT REQUIRED COMPONENTS Development) --elseif($ENV{ROS_DISTRO} MATCHES "iron") -- find_package(Python 3.10 EXACT REQUIRED COMPONENTS Development) --elseif($ENV{ROS_DISTRO} MATCHES "jazzy") -- find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) --elseif($ENV{ROS_DISTRO} MATCHES "kilted") -- find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) --elseif($ENV{ROS_DISTRO} MATCHES "rolling") -- find_package(Python 3.12 EXACT REQUIRED COMPONENTS Development) -+# Upstream hardcodes an EXACT Python version per ROS_DISTRO matching whatever -+# Python Ubuntu ships for that distro's release. conda-forge's Python version -+# moves independently (currently 3.14 for rolling, not the 3.12 upstream -+# expects), so the EXACT match fails to find conda's Python and CMake falls -+# back to the system Python headers instead, which lack the Debian -+# multiarch pyconfig.h. Just find whatever Python 3 is active in the build -+# environment instead of hardcoding a version tied to Ubuntu's release. -+find_package(Python 3 REQUIRED COMPONENTS Development) -+ -+if(APPLE) -+ # The bundled Webots Makefiles write the macOS app bundle layout (Contents/lib/..., -+ # Contents/MacOS/webots-controller): map it onto the plain layout installed below. -+ file(CREATE_LINK . ${CMAKE_CURRENT_SOURCE_DIR}/webots/Contents SYMBOLIC) -+ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/webots/MacOS) -+ set(WEBOTS_RPATH_ORIGIN "@loader_path") -+ set(WEBOTS_CONTROLLER_LAUNCHER webots/MacOS/webots-controller) -+else() -+ set(WEBOTS_RPATH_ORIGIN "$ORIGIN") -+ set(WEBOTS_CONTROLLER_LAUNCHER webots/webots-controller) - endif() - - add_custom_target(compile-lib-controller ALL -@@ -91,7 +100,7 @@ ament_python_install_package(${PROJECT_NAME} - PACKAGE_DIR ${PROJECT_NAME}) - - # Driver --set(CMAKE_INSTALL_RPATH "$ORIGIN/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 -+set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/../controller") # Deprecated with new WebotsController node, remove with 2024.0.0 - add_executable(driver - src/Driver.cpp - src/WebotsNode.cpp -@@ -161,7 +170,7 @@ install(TARGETS driver - ) - - # Dynamic IMU --set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 -+set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 - add_library( - ${PROJECT_NAME}_imu - SHARED -@@ -200,7 +209,7 @@ install(TARGETS ${PROJECT_NAME}_imu - ) - - # Dynamic RGBD --set(CMAKE_INSTALL_RPATH "$ORIGIN/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 -+set(CMAKE_INSTALL_RPATH "${WEBOTS_RPATH_ORIGIN}/controller") # Deprecated with new WebotsController node, remove with 2024.0.0 - add_library( - ${PROJECT_NAME}_rgbd - SHARED -@@ -279,7 +288,7 @@ install( - - # Install webots-controller script - install( -- PROGRAMS webots/webots-controller -+ PROGRAMS ${WEBOTS_CONTROLLER_LAUNCHER} - DESTINATION share/${PROJECT_NAME}/scripts - ) - -diff --git a/src/Driver.cpp b/src/Driver.cpp -index cf79908..22069db 100644 ---- a/src/Driver.cpp -+++ b/src/Driver.cpp -@@ -46,6 +46,7 @@ int main(int argc, char **argv) { - std::make_shared(robotName, nodeOptions); - node->init(); - -+#if defined(__linux__) // /proc//cmdline is Linux-only - // The parent process must be ros2 run. Declaring from launch file is deprecated. Remove with 2024.0.0. - const pid_t parentPid = getppid(); - char buffer[4096]; -@@ -65,6 +66,7 @@ int main(int argc, char **argv) { - if (strstr(buffer, "ros2 launch")) - RCLCPP_WARN(node->get_logger(), "\033[33mThe direct declaration of the driver node in the launch file is deprecated. " - "Please use the new WebotsController node instead.\033[0m"); -+#endif - - RCLCPP_INFO(node->get_logger(), "Controller successfully connected to robot in Webots simulation."); - while (true) { -diff --git a/src/plugins/static/Ros2LightSensor.cpp b/src/plugins/static/Ros2LightSensor.cpp -index 63a5e4b..1288e06 100644 ---- a/src/plugins/static/Ros2LightSensor.cpp -+++ b/src/plugins/static/Ros2LightSensor.cpp -@@ -74,8 +74,8 @@ namespace webots_ros2_driver { - // Find relative standard deviation in lookup table - double relativeStd = NAN; - for (int i = 0; i < mLookupTable.size() - 3; i += 3) -- if ((mLookupTable[i + 1] < rawValue < mLookupTable[i + 3 + 1]) || -- (mLookupTable[i + 1] > rawValue > mLookupTable[i + 3 + 1])) { -+ if ((mLookupTable[i + 1] < rawValue && rawValue < mLookupTable[i + 3 + 1]) || -+ (mLookupTable[i + 1] > rawValue && rawValue > mLookupTable[i + 3 + 1])) { - relativeStd = mLookupTable[i + 2]; - break; - } -diff --git a/webots/lib/controller/python/controller/wb.py b/webots/lib/controller/python/controller/wb.py -index 48c9506..64f07de 100644 ---- a/webots/lib/controller/python/controller/wb.py -+++ b/webots/lib/controller/python/controller/wb.py -@@ -21,7 +21,7 @@ if sys.platform == 'linux' or sys.platform == 'linux2': - elif sys.platform == 'win32': - path = os.path.join('lib', 'controller', 'Controller.dll') - elif sys.platform == 'darwin': -- path = os.path.join('Contents', 'lib', 'controller', 'libController.dylib') -+ path = os.path.join('lib', 'controller', 'libController.dylib') - - wb = ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path)) - -diff --git a/webots/lib/controller/python/vehicle/driver.py b/webots/lib/controller/python/vehicle/driver.py -index 6d70788..5123beb 100644 ---- a/webots/lib/controller/python/vehicle/driver.py -+++ b/webots/lib/controller/python/vehicle/driver.py -@@ -43,7 +43,7 @@ class Driver(Supervisor): - car = 'car.dll' - driver = 'driver.dll' - elif sys.platform == 'darwin': -- path = os.path.join('Contents', 'lib', 'controller') -+ path = os.path.join('lib', 'controller') - car = 'libcar.dylib' - driver = 'libdriver.dylib' - ctypes.cdll.LoadLibrary(os.path.join(os.environ['WEBOTS_HOME'], path, car)) -diff --git a/webots/resources/Makefile.include b/webots/resources/Makefile.include -index 461793b..704adf6 100644 ---- a/webots/resources/Makefile.include -+++ b/webots/resources/Makefile.include -@@ -210,15 +210,15 @@ endif - ifneq ($(C_SOURCES)$(CXX_SOURCES),) - ifdef BUILD_EXECUTABLE - MAIN_TARGET = $(NAME)$(EXE_EXTENSION) -- X86_64_LINKER = -target x86_64-apple-macos12 -- ARM64_LINKER = -target arm64-apple-macos12 -+ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) -+ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) - else - ifdef BUILD_STATIC_LIBRARY - MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(STATIC_LIB_EXTENSION) - else - MAIN_TARGET ?= $(LIB_PREFIX)$(NAME)$(SHARED_LIB_EXTENSION) -- X86_64_LINKER = -target x86_64-apple-macos12 -- ARM64_LINKER = -target arm64-apple-macos12 -+ X86_64_LINKER = $(if $(target_platform),,-target x86_64-apple-macos12) -+ ARM64_LINKER = $(if $(target_platform),,-target arm64-apple-macos12) - endif - endif - endif -@@ -405,8 +405,8 @@ endif - - ifeq ($(OSTYPE),darwin) - ifdef WEBOTS_LIBRARY -- INSTALL_NAME ?= @rpath/Contents/lib/controller/$(MAIN_TARGET) -- LFLAGS += -Xlinker -rpath -Xlinker @loader_path/.. -install_name $(INSTALL_NAME) -+ INSTALL_NAME ?= @rpath/$(MAIN_TARGET) -+ LFLAGS += -Xlinker -rpath -Xlinker @loader_path -install_name $(INSTALL_NAME) - else - CALLING_MAKEFILE_DIR := $(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))") - WEBOTS_RELATIVE_PATH = $(call computeRelativePath,"$(WEBOTS_HOME_PATH)","$(CALLING_MAKEFILE_DIR)") -@@ -549,16 +549,18 @@ endif - ###----------------------------------------------------------------------------- - - ifdef FAT_BINARY -+# conda builds for one architecture (target_platform), not universal binaries -+WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) - X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/, $(OBJECTS_LIST)) - ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/, $(OBJECTS_LIST)) - --$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) -+$(BUILD_GOAL_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) - @echo "# creating fat" $(notdir $@) -- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) -+ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) - --$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) -+$(TARGET_LIB_DIR)/$(MAIN_TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) - @echo "# creating fat" $(notdir $@) -- $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET) $(BUILD_GOAL_DIR)/arm64/$(MAIN_TARGET) -+ $(SILENT)lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/$(MAIN_TARGET) - - $(BUILD_GOAL_DIR)/x86_64/$(MAIN_TARGET): $(X86_64_OBJECTS) $(LINK_DEPENDENCIES) - @echo "# linking" $(notdir $@) "(x86_64)" -diff --git a/webots/src/controller/c/Makefile b/webots/src/controller/c/Makefile -index 14a32c7..bfceaf5 100644 ---- a/webots/src/controller/c/Makefile -+++ b/webots/src/controller/c/Makefile -@@ -44,7 +44,7 @@ endif - ifeq ($(OSTYPE),darwin) - CFLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -fpascal-strings -Wno-deprecated-declarations -Wno-single-bit-bitfield-constant-conversion -I/Developer/Headers/FlatCarbon -Wall -fno-common -D LIBCONTROLLER_VERSION='$(LIBCONTROLLER_VERSION)' - INCLUDE = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include --LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/Contents/lib/controller/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 -+LD_FLAGS = -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) -dynamiclib -install_name @rpath/libController.dylib -compatibility_version 1.0 -current_version 1.0.0 - SHARED_LIBS = -lz - TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib - CC = gcc -@@ -144,12 +144,14 @@ endif - endif - - ifeq ($(OSTYPE),darwin) -+# conda builds for one architecture (target_platform), not universal binaries -+WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) - X86_64_OBJECTS = $(addprefix $(OBJDIR)/x86_64/, $(OBJECTS)) - ARM64_OBJECTS = $(addprefix $(OBJDIR)/arm64/, $(OBJECTS)) - --$(TARGET): $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib -+$(TARGET): $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib - @echo "# creating fat binary: $$"\(WEBOTS_HOME\)/lib/controller/libController.dylib -- @lipo -create -output $(TARGET) $(OBJDIR)/x86_64/libController.dylib $(OBJDIR)/arm64/libController.dylib -+ @lipo -create -output $(TARGET) $(OBJDIR)/$(WEBOTS_MAC_ARCH)/libController.dylib - @chmod a-x $@ - @codesign -s - $@ - -diff --git a/webots/src/controller/cpp/Makefile b/webots/src/controller/cpp/Makefile -index dde0a6e..910fb01 100644 ---- a/webots/src/controller/cpp/Makefile -+++ b/webots/src/controller/cpp/Makefile -@@ -100,7 +100,7 @@ SHAREDLIBS = -L$(WEBOTS_CONTROLLER_LIB_PATH) -lController - CPPFLAGS = -c -fPIC -Wall -mmacosx-version-min=$(MACOSX_MIN_SDK_VERSION) - CPPINCLUDES = -I$(WEBOTS_HOME_PATH)/include/controller/c -I$(WEBOTS_HOME_PATH)/include/controller/cpp - LIBCONTROLLER = $(WEBOTS_CONTROLLER_LIB_PATH)/libController.dylib --LDFLAGS += -install_name @rpath/Contents/lib/controller/libCppController.dylib -+LDFLAGS += -install_name @rpath/libCppController.dylib -Wl,-rpath,@loader_path - TARGET = $(WEBOTS_CONTROLLER_LIB_PATH)/libCppController.dylib - endif - -@@ -121,21 +121,23 @@ all debug profile release: $(TARGET) - - ifeq ($(OSTYPE),darwin) - -+# conda builds for one architecture (target_platform), not universal binaries -+WEBOTS_MAC_ARCH ?= $(if $(filter osx-64,$(target_platform)),x86_64,$(if $(filter osx-arm64,$(target_platform)),arm64,$(shell uname -m))) - X86_64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/x86_64/,$(OBJECTS)) - ARM64_OBJECTS = $(addprefix $(BUILD_GOAL_DIR)/arm64/,$(OBJECTS)) - --$(TARGET): $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib -+$(TARGET): $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib - @echo "# creating fat" $(notdir $@) -- @lipo -create -output $@ $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib $(BUILD_GOAL_DIR)/arm64/libCppController.dylib -+ @lipo -create -output $@ $(BUILD_GOAL_DIR)/$(WEBOTS_MAC_ARCH)/libCppController.dylib - @codesign -s - $@ - - $(BUILD_GOAL_DIR)/x86_64/libCppController.dylib: $(X86_64_OBJECTS) - @echo "# linking" $@ "(x86_64)" -- @$(CXX) -target x86_64-apple-macos12 $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" -+ @$(CXX) $(if $(target_platform),,-target x86_64-apple-macos12) $(LDFLAGS) $(X86_64_OBJECTS) $(SHAREDLIBS) -o "$@" - - $(BUILD_GOAL_DIR)/arm64/libCppController.dylib: $(ARM64_OBJECTS) - @echo "# linking" $@ "(arm64)" -- @$(CXX) -target arm64-apple-macos12 $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" -+ @$(CXX) $(if $(target_platform),,-target arm64-apple-macos12) $(LDFLAGS) $(ARM64_OBJECTS) $(SHAREDLIBS) -o "$@" - - else - -diff --git a/webots/src/controller/launcher/Makefile b/webots/src/controller/launcher/Makefile -index 6c9cf55..7cd02ff 100644 ---- a/webots/src/controller/launcher/Makefile -+++ b/webots/src/controller/launcher/Makefile -@@ -33,6 +33,8 @@ ifeq ($(OSTYPE),windows) - CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/msys64/mingw64/bin/webots-controller.exe - else ifeq ($(OSTYPE),darwin) - CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/Contents/MacOS/webots-controller -+# the environment's compiler, and room for the install name tool to rewrite rpaths -+LAUNCHER_CC = $(CC) -Wl,-headerpad_max_install_names - else - CONTROLLER_LAUNCHER = $(WEBOTS_HOME_PATH)/webots-controller - endif -@@ -43,6 +45,6 @@ release debug profile: $(CONTROLLER_LAUNCHER) - - $(CONTROLLER_LAUNCHER): webots_controller.c - @echo "# compiling" $< -- @gcc $(CFLAGS) webots_controller.c -o $@ -+ @$(or $(LAUNCHER_CC),gcc) $(CFLAGS) webots_controller.c -o $@ - - FILES_TO_REMOVE += $(CONTROLLER_LAUNCHER) -diff --git a/webots_ros2_driver/utils.py b/webots_ros2_driver/utils.py -index b6a9a54..87acc5f 100644 ---- a/webots_ros2_driver/utils.py -+++ b/webots_ros2_driver/utils.py -@@ -46,6 +46,9 @@ class WebotsVersion: - @staticmethod - def from_path(path): - version_file = os.path.join(path, 'resources', 'version.txt') -+ if sys.platform == 'darwin' and not os.path.isfile(version_file): -+ # the macOS app bundle: /Applications/Webots.app/Contents/Resources -+ version_file = os.path.join(path, 'Contents', 'Resources', 'version.txt') - if not os.path.isfile(version_file): - return None - with open(version_file, 'r') as f: -diff --git a/webots_ros2_driver/webots_launcher.py b/webots_ros2_driver/webots_launcher.py -index 3952906..12c493c 100644 ---- a/webots_ros2_driver/webots_launcher.py -+++ b/webots_ros2_driver/webots_launcher.py -@@ -72,6 +72,8 @@ class WebotsLauncher(ExecuteProcess): - webots_path = get_webots_home() - if self.__is_wsl: - webots_path = os.path.join(webots_path, 'msys64', 'mingw64', 'bin', 'webots.exe') -+ elif sys.platform == 'darwin': -+ webots_path = os.path.join(webots_path, 'Contents', 'MacOS', 'webots') - else: - webots_path = os.path.join(webots_path, 'webots') - else: diff --git a/distros/lyrical/patch/ros2-webots-ros2-driver.patch b/shared/patch/ros2-webots-ros2-driver.patch similarity index 100% rename from distros/lyrical/patch/ros2-webots-ros2-driver.patch rename to shared/patch/ros2-webots-ros2-driver.patch