Skip to content

Commit

Permalink
Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176)
Browse files Browse the repository at this point in the history
* Update support for ESP 5

Signed-off-by: acuadros95 <[email protected]>

* C_STANDARD workarround

Signed-off-by: acuadros95 <[email protected]>

* Update docker, nightly and readme

Signed-off-by: acuadros95 <[email protected]>

* Generalice C_VERSION for different IDF versions

Signed-off-by: acuadros95 <[email protected]>

* Remove C_STANDARD from toolchain

Signed-off-by: acuadros95 <[email protected]>

* Fix embeddeRTPS

Signed-off-by: acuadros95 <[email protected]>

* Fix example

Signed-off-by: acuadros95 <[email protected]>

* Fix esp32c3 build

Signed-off-by: acuadros95 <[email protected]>

* Fix macro name

Signed-off-by: acuadros95 <[email protected]>

* Deprecate v4.1 and v4.2

Signed-off-by: acuadros95 <[email protected]>

* Deprecate galactic

Signed-off-by: acuadros95 <[email protected]>

* Revert XRCE client temporal branch

Signed-off-by: acuadros95 <[email protected]>

---------

Signed-off-by: acuadros95 <[email protected]>
(cherry picked from commit a71fb63)

# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/nightly.yml
#	CMakeLists.txt
#	docker/Dockerfile
#	esp32_toolchain.cmake.in
#	examples/int32_publisher/main/main.c
#	examples/int32_publisher_embeddedrtps/main/main.c
  • Loading branch information
Acuadros95 authored and mergify[bot] committed Feb 16, 2023
1 parent 7cc62d5 commit 6b00df1
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 125 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ jobs:
fail-fast: false
matrix:
idf_target: [ esp32, esp32s2, esp32s3, esp32c3]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:release-v4.4" ]
idf_version: [ "espressif/idf:release-v4.3", "espressif/idf:release-v4.4", "espressif/idf:release-v5.0" ]
exclude:
- idf_target: esp32s2
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32c3
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32c3
idf_version: "espressif/idf:release-v4.2"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.2"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.3"

Expand All @@ -44,6 +34,13 @@ jobs:
apt install -y git python3-pip
. $IDF_PATH/export.sh
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
<<<<<<< HEAD
=======
# This line avoids the error when using Python < 3.7 https://importlib-resources.readthedocs.io/en/latest/
pip3 install importlib-resources
# this installs the modules also for global python interpreter, needed for IDF v5
/usr/bin/pip3 install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
>>>>>>> a71fb63 (Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176))

- name: Build sample - int32_publisher
shell: bash
Expand Down
30 changes: 18 additions & 12 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@ jobs:
strategy:
fail-fast: false
matrix:
branch: [foxy, main, galactic]
branch: [foxy, main, humble]
idf_target: [ esp32, esp32s2, esp32c3, esp32s3]
idf_version: [ "espressif/idf:release-v4.1", "espressif/idf:release-v4.2", "espressif/idf:release-v4.3", "espressif/idf:release-v4.4" ]
idf_version: [ "espressif/idf:release-v4.3", "espressif/idf:release-v4.4", "espressif/idf:release-v5.0" ]
exclude:
- idf_target: esp32s2
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32c3
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32c3
idf_version: "espressif/idf:release-v4.2"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.1"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.2"
- idf_target: esp32s3
idf_version: "espressif/idf:release-v4.3"
container:
Expand All @@ -49,6 +39,8 @@ jobs:
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
# This line avoids the error when using Python < 3.7 https://importlib-resources.readthedocs.io/en/latest/
pip3 install importlib-resources
# this installs the modules also for global python interpreter, needed for IDF v5
/usr/bin/pip3 install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
- name: Build sample - int32_publisher
shell: bash
Expand Down Expand Up @@ -76,4 +68,18 @@ jobs:
sed -i 's/DRMW_UXRCE_TRANSPORT=udp/DRMW_UXRCE_TRANSPORT=custom/' colcon.meta
cd examples/int32_publisher_custom_transport
idf.py set-target ${{ matrix.idf_target }}
<<<<<<< HEAD
=======
idf.py build

- name: EmbeddedRTPS
if: ${{ matrix.branch == 'humble' }}
shell: bash
run: |
. $IDF_PATH/export.sh
cd micro_ros_espidf_component
make -f libmicroros.mk clean
cd examples/int32_publisher_embeddedrtps
idf.py set-target ${{ matrix.idf_target }}
>>>>>>> a71fb63 (Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176))
idf.py build
56 changes: 55 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
idf_component_register(SRCS "network_interfaces/uros_ethernet_netif.c" "network_interfaces/uros_wlan_netif.c"
INCLUDE_DIRS "network_interfaces"
REQUIRES nvs_flash)
REQUIRES nvs_flash esp_wifi esp_eth lwip)

if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
set(submake "$(MAKE)")
else()
set(submake "make")
endif()

if (${IDF_VERSION_MAJOR} EQUAL 5)
set(CMAKE_C_STANDARD 17)
else()
set(CMAKE_C_STANDARD 11)
endif()

set(APP_COLCON_META "${PROJECT_DIR}/app-colcon.meta")
if(NOT EXISTS "${APP_COLCON_META}")
set(APP_COLCON_META "")
Expand All @@ -18,6 +24,7 @@ if(NOT EXISTS "${EXTRA_ROS_PACKAGES}")
set(EXTRA_ROS_PACKAGES "${COMPONENT_DIR}/extra_packages")
endif()

<<<<<<< HEAD
externalproject_add(libmicroros_project
PREFIX ${CMAKE_BINARY_DIR}/libmicroros-prefix
SOURCE_DIR ${COMPONENT_DIR}
Expand All @@ -41,6 +48,53 @@ externalproject_add(libmicroros_project
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${COMPONENT_DIR}/libmicroros.a
)
=======
if(${CONFIG_MICRO_ROS_ESP_EMBEDDEDRTPS_MIDDLEWARE})
message(STATUS "Using embeddedRTPS middleware")
set(MIDDLEWARE "embeddedrtps")
else()
message(STATUS "Using Micro XRCE-DDS middleware")
set(MIDDLEWARE "microxrcedds")
endif()

# Create a list of packages to get includes
idf_build_get_property(PACKAGES BUILD_COMPONENTS)

# Add includes for each package
foreach(package ${PACKAGES})
idf_component_get_property(${package}_dir ${package} COMPONENT_DIR)
idf_component_get_property(${package}_includes ${package} INCLUDE_DIRS)
list(TRANSFORM ${package}_includes PREPEND " -I${${package}_dir}/")
string(REPLACE ";" "" ${package}_includes_string "${${package}_includes}")
endforeach()

# Create a string with all packages with a for loop
foreach(package ${PACKAGES})
string(APPEND IDF_INCLUDES "${${package}_includes_string}")
endforeach()

execute_process(
WORKING_DIRECTORY ${COMPONENT_DIR}
COMMAND
${submake} -j -f libmicroros.mk
X_CC=${CMAKE_C_COMPILER}
X_AR=${CMAKE_AR}
X_STRIP=${CMAKE_STRIP}
X_CFLAGS=${CMAKE_C_FLAGS}
X_CXX=${CMAKE_CXX_COMPILER}
X_CXXFLAGS=${CMAKE_CXX_FLAGS}
C_STANDARD=${CMAKE_C_STANDARD}
MIDDLEWARE=${MIDDLEWARE}
BUILD_DIR=${CMAKE_BINARY_DIR}
IDF_INCLUDES=${IDF_INCLUDES}
IDF_PATH=${IDF_PATH}
IDF_TARGET=${IDF_TARGET}
APP_COLCON_META=${APP_COLCON_META}
IDF_VERSION_MAJOR=${IDF_VERSION_MAJOR}
IDF_VERSION_MINOR=${IDF_VERSION_MINOR}
EXTRA_ROS_PACKAGES=${EXTRA_ROS_PACKAGES}
)
>>>>>>> a71fb63 (Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176))

add_prebuilt_library(libmicroros-prebuilt ""
REQUIRES lwip)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# micro-ROS component for ESP-IDF

This component has been tested in ESP-IDF v4.1, v4.2, v4.3 and v4.4 with ESP32, ESP32-S2, ESP32-S3 and ESP32-C3.
This component has been tested in ESP-IDF v4.3, v4.4, and v5.0 with ESP32, ESP32-S2, ESP32-S3 and ESP32-C3.

## Dependencies

Expand Down Expand Up @@ -57,7 +57,7 @@ It's possible to build this example application using preconfigured docker conta
docker run -it --rm --user espidf --volume="/etc/timezone:/etc/timezone:ro" -v $(pwd):/micro_ros_espidf_component -v /dev:/dev --privileged --workdir /micro_ros_espidf_component microros/esp-idf-microros:latest /bin/bash -c "cd examples/int32_publisher; idf.py menuconfig build flash monitor"
```

Dockerfile for this container is provided in the ./docker directory and available in dockerhub.
Dockerfile for this container is provided in the ./docker directory and available in dockerhub. This approach uses ESP-IDF v5.

## Using serial transport

Expand Down
9 changes: 7 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@


<<<<<<< HEAD
FROM espressif/idf:release-v4.1
=======
FROM espressif/idf:release-v5.0
>>>>>>> a71fb63 (Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176))

ENV DEBIAN_FRONTEND noninteractive
RUN echo "Set disable_coredump false" >> /etc/sudo.conf
Expand All @@ -16,9 +20,10 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY ./install_micro_ros_deps_script.sh /install_micro_ros_deps_script.sh

RUN mkdir -p /tmp/install_micro_ros_deps_script && mv /install_micro_ros_deps_script.sh /tmp/install_micro_ros_deps_script/ && \
/tmp/install_micro_ros_deps_script/install_micro_ros_deps_script.sh && \
IDF_EXPORT_QUIET=1 /tmp/install_micro_ros_deps_script/install_micro_ros_deps_script.sh && \
rm -rf /var/lib/apt/lists/*


RUN /usr/bin/pip3 --no-cache-dir install catkin_pkg lark-parser empy colcon-common-extensions importlib-resources
ARG USER_ID=espidf

RUN useradd --create-home --home-dir /home/$USER_ID --shell /bin/bash --user-group --groups adm,sudo $USER_ID && \
Expand Down
104 changes: 11 additions & 93 deletions esp32_toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ set(idf_target "@IDF_TARGET@")

if("${idf_target}" STREQUAL "esp32c3")
set(CMAKE_SYSTEM_PROCESSOR riscv)
set(FLAGS "-ffunction-sections -fdata-sections" CACHE STRING "" FORCE)
else()
set(CMAKE_SYSTEM_PROCESSOR xtensa)
set(FLAGS "-mlongcalls -ffunction-sections -fdata-sections" CACHE STRING "" FORCE)
endif()

set(CMAKE_CROSSCOMPILING 1)
Expand All @@ -21,9 +23,10 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@)
set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@)

set(CMAKE_C_FLAGS_INIT "@CFLAGS@" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_INIT "@CXXFLAGS@" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS} ${IDF_INCLUDES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti ${FLAGS} ${IDF_INCLUDES}")

<<<<<<< HEAD
set(idf_path "@IDF_PATH@")
set(idf_target "@IDF_TARGET@")

Expand All @@ -49,96 +52,11 @@ include_directories(
${idf_path}/components/soc/src/${idf_target}/.
${idf_path}/components/soc/src/${idf_target}/include
${idf_path}/components/soc/include
${idf_path}/components/soc/${idf_target}/include
${idf_path}/components/esp_rom/include
${idf_path}/components/esp_common/include
${idf_path}/components/esp_system/include
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/include
${idf_path}/components/${CMAKE_SYSTEM_PROCESSOR}/${idf_target}/include
${idf_path}/components/${idf_target}/include
${idf_path}/components/driver/include
${idf_path}/components/driver/${idf_target}/include
${idf_path}/components/esp_ringbuf/include
${idf_path}/components/efuse/include
${idf_path}/components/efuse/${idf_target}/include
${idf_path}/components/espcoredump/include
${idf_path}/components/esp_timer/include
${idf_path}/components/esp_ipc/include
${idf_path}/components/soc/soc/${idf_target}/include
${idf_path}/components/soc/soc/${idf_target}/../include
${idf_path}/components/soc/soc/${idf_target}/private_include
${idf_path}/components/vfs/include
${idf_path}/components/esp_wifi/include
${idf_path}/components/esp_wifi/${idf_target}/include
${idf_path}/components/esp_event/include
${idf_path}/components/esp_netif/include
${idf_path}/components/esp_eth/include
${idf_path}/components/tcpip_adapter/include
${idf_path}/components/app_trace/include
${idf_path}/components/mbedtls/port/include
${idf_path}/components/mbedtls/mbedtls/include
${idf_path}/components/mbedtls/esp_crt_bundle/include
${idf_path}/components/bootloader_support/include
${idf_path}/components/app_update/include
${idf_path}/components/spi_flash/include
${idf_path}/components/wpa_supplicant/include
${idf_path}/components/wpa_supplicant/port/include
${idf_path}/components/wpa_supplicant/include/esp_supplicant
${idf_path}/components/nvs_flash/include
${idf_path}/components/pthread/include
${idf_path}/components/perfmon/include
${idf_path}/components/asio/asio/asio/include
${idf_path}/components/asio/port/include
${idf_path}/components/cbor/port/include
${idf_path}/components/coap/port/include
${idf_path}/components/coap/port/include/coap
${idf_path}/components/coap/libcoap/include
${idf_path}/components/coap/libcoap/include/coap2
${idf_path}/components/console
${idf_path}/components/nghttp/port/include
${idf_path}/components/nghttp/nghttp2/lib/includes
${idf_path}/components/esp-tls
${idf_path}/components/esp_adc_cal/include
${idf_path}/components/esp_gdbstub/include
${idf_path}/components/esp_hid/include
${idf_path}/components/tcp_transport/include
${idf_path}/components/esp_http_client/include
${idf_path}/components/esp_http_server/include
${idf_path}/components/esp_https_ota/include
${idf_path}/components/protobuf-c/protobuf-c
${idf_path}/components/protocomm/include/common
${idf_path}/components/protocomm/include/security
${idf_path}/components/protocomm/include/transports
${idf_path}/components/mdns/include
${idf_path}/components/esp_local_ctrl/include
${idf_path}/components/sdmmc/include
${idf_path}/components/esp_serial_slave_link/include
${idf_path}/components/esp_websocket_client/include
${idf_path}/components/expat/expat/expat/lib
${idf_path}/components/expat/port/include
${idf_path}/components/wear_levelling/include
${idf_path}/components/fatfs/diskio
${idf_path}/components/fatfs/vfs
${idf_path}/components/fatfs/src
${idf_path}/components/freemodbus/common/include
${idf_path}/components/idf_test/include
${idf_path}/components/idf_test/include/${idf_target}
${idf_path}/components/jsmn/include
${idf_path}/components/json/cJSON
${idf_path}/components/libsodium/libsodium/src/libsodium/include
${idf_path}/components/libsodium/port_include
${idf_path}/components/mqtt/esp-mqtt/include
${idf_path}/components/openssl/include
${idf_path}/components/spiffs/include
${idf_path}/components/ulp/include
${idf_path}/components/unity/include
${idf_path}/components/unity/unity/src
${idf_path}/components/wifi_provisioning/include
=======
add_compile_definitions(ESP_PLATFORM LWIP_IPV4 LWIP_IPV6 PLATFORM_NAME_FREERTOS)

${idf_path}/components/freertos/include/esp_additions/freertos
${idf_path}/components/freertos/include/esp_additions
${idf_path}/components/esp_hw_support/include
${idf_path}/components/esp_hw_support/include/soc
${idf_path}/components/esp_hw_support/include/soc/${idf_target}
${idf_path}/components/esp_hw_support/port/${idf_target}/.
include_directories(
"@BUILD_CONFIG_DIR@"
>>>>>>> a71fb63 (Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176))
${idf_path}/components/soc/${idf_target}/include
)
4 changes: 4 additions & 0 deletions examples/int32_publisher/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
{
RCLC_UNUSED(last_call_time);
if (timer != NULL) {
<<<<<<< HEAD
=======
printf("Publishing: %d\n", (int) msg.data);
>>>>>>> a71fb63 (Add IDF 5 support and deprecate versions 4.1 and 4.2 (#176))
RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL));
msg.data++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ size_t esp32_serial_write(struct uxrCustomTransport* transport, const uint8_t *

size_t esp32_serial_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err){
size_t * uart_port = (size_t*) transport->args;
const int rxBytes = uart_read_bytes(*uart_port, buf, len, timeout / portTICK_RATE_MS);
const int rxBytes = uart_read_bytes(*uart_port, buf, len, timeout / portTICK_PERIOD_MS);
return rxBytes;
}
Loading

0 comments on commit 6b00df1

Please sign in to comment.