├── modules └── libmicroros │ ├── zephyr │ └── module.yml │ ├── .gitignore │ ├── zephyr_toolchain.cmake.in │ ├── utils.sh │ ├── colcon.meta │ ├── microros_transports │ ├── udp │ │ ├── microros_transports.h │ │ └── microros_transports.c │ ├── serial-usb │ │ ├── microros_transports.h │ │ └── microros_transports.c │ └── serial │ │ ├── microros_transports.h │ │ └── microros_transports.c │ ├── Kconfig │ ├── CMakeLists.txt │ └── libmicroros.mk ├── .images ├── banner-dark-theme.png └── banner-light-theme.png ├── 3rd-party-licenses.txt ├── CMakeLists.txt ├── prj.conf ├── app.overlay ├── package.xml ├── .github ├── ISSUE_TEMPLATE │ └── general-issue.md └── workflows │ ├── ci.yml │ └── nightly.yml ├── NOTICE ├── README.md ├── src └── main.c ├── CONTRIBUTING.md ├── CHANGELOG.rst └── LICENSE /modules/libmicroros/zephyr/module.yml: -------------------------------------------------------------------------------- 1 | build: 2 | cmake: . 3 | kconfig: Kconfig -------------------------------------------------------------------------------- /.images/banner-dark-theme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micro-ROS/micro_ros_zephyr_module/HEAD/.images/banner-dark-theme.png -------------------------------------------------------------------------------- /.images/banner-light-theme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micro-ROS/micro_ros_zephyr_module/HEAD/.images/banner-light-theme.png -------------------------------------------------------------------------------- /modules/libmicroros/.gitignore: -------------------------------------------------------------------------------- 1 | micro_ros_dev 2 | micro_ros_src 3 | zephyr_toolchain.cmake 4 | include 5 | configured_colcon.meta 6 | *.a -------------------------------------------------------------------------------- /3rd-party-licenses.txt: -------------------------------------------------------------------------------- 1 | Third Party Licenses 2 | ==================== 3 | 4 | This repository does not directly contain 3rd party source code. -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | 5 | list(APPEND ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/modules/libmicroros) 6 | 7 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 8 | project(microros_sample_app) 9 | 10 | target_sources(app PRIVATE src/main.c) 11 | -------------------------------------------------------------------------------- /prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_GPIO=y 2 | CONFIG_MICROROS=y 3 | CONFIG_CPP=y 4 | 5 | CONFIG_MAIN_STACK_SIZE=25000 6 | CONFIG_MAIN_THREAD_PRIORITY=3 7 | 8 | CONFIG_NEWLIB_LIBC=y 9 | CONFIG_NEWLIB_LIBC_NANO=n 10 | CONFIG_PTHREAD_IPC=n 11 | 12 | CONFIG_POSIX_API=y 13 | CONFIG_POSIX_CLOCK=y 14 | 15 | CONFIG_STDOUT_CONSOLE=y 16 | CONFIG_LOG=y 17 | CONFIG_SERIAL=y 18 | CONFIG_UART_INTERRUPT_DRIVEN=y 19 | CONFIG_UART_LINE_CTRL=y 20 | -------------------------------------------------------------------------------- /app.overlay: -------------------------------------------------------------------------------- 1 | /*Added these lines for compability with Zephyr v2.7*/ 2 | zephyr_udc0: &usbotg_fs { 3 | pinctrl-0 = <&usb_otg_fs_dm_pa11 &usb_otg_fs_dp_pa12 4 | &usb_otg_fs_id_pa10>; 5 | pinctrl-names = "default"; 6 | status = "okay"; 7 | }; 8 | /* End of compability part */ 9 | 10 | 11 | &zephyr_udc0 { 12 | cdc_acm_uart0: cdc_acm_uart0 { 13 | compatible = "zephyr,cdc-acm-uart"; 14 | label = "CDC_ACM_0"; 15 | }; 16 | }; 17 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | micro_ros_zephyr 5 | 6.0.0 6 | micro-ROS tools for Zephyr RTOS 7 | Eugenio Collado 8 | Carlos Espinoza 9 | Apache License 2.0 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/general-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: General issue 3 | about: General issue template for micro-ROS 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Issue template 11 | 12 | - Hardware description: 13 | - RTOS: 14 | - Installation type: 15 | - Version or commit hash: 16 | 17 | #### Steps to reproduce the issue 18 | 19 | 20 | #### Expected behavior 21 | 22 | #### Actual behavior 23 | 24 | #### Additional information 25 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | # This is the official list of copyright holders and authors. 2 | # 3 | # Often employers or academic institutions have ownership over code that is 4 | # written in certain circumstances, so please do due diligence to ensure that 5 | # you have the right to submit the code. 6 | # 7 | # When adding J Random Contributor's name to this file, either J's name on its 8 | # own or J's name associated with J's organization's name should be added, 9 | # depending on whether J's employer (or academic institution) has ownership 10 | # over code that is written for this project. 11 | # 12 | # How to add names to this file: 13 | # Individual's name . 14 | # 15 | # If Individual's organization is copyright holder of her contributions add the 16 | # organization's name, optionally also the contributor's name: 17 | # 18 | # Organization's name 19 | # Individual's name 20 | # 21 | # Please keep the list sorted. 22 | 23 | eProsima 24 | Pablo Garrido -------------------------------------------------------------------------------- /modules/libmicroros/zephyr_toolchain.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeForceCompiler) 2 | 3 | set(CMAKE_SYSTEM_NAME Generic) 4 | # set(CMAKE_SYSTEM_PROCESSOR arm) 5 | set(CMAKE_CROSSCOMPILING 1) 6 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 7 | set(PLATFORM_NAME "zephyr") 8 | 9 | set(CMAKE_SYSROOT @CMAKE_SYSROOT@) 10 | 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | 15 | # Makefile flags 16 | 17 | set(CMAKE_THREAD_LIBS_INIT "-lpthread") 18 | set(CMAKE_HAVE_THREADS_LIBRARY 1) 19 | set(CMAKE_USE_WIN32_THREADS_INIT 0) 20 | set(CMAKE_USE_PTHREADS_INIT 1) 21 | set(THREADS_PREFER_PTHREAD_FLAG ON) 22 | 23 | SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") 24 | SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") 25 | 26 | set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@) 27 | set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@) 28 | 29 | set(CMAKE_C_FLAGS_INIT "@CFLAGS@" CACHE STRING "" FORCE) 30 | set(CMAKE_CXX_FLAGS_INIT "@CXXFLAGS@" CACHE STRING "" FORCE) 31 | 32 | set(__BIG_ENDIAN__ 0) -------------------------------------------------------------------------------- /modules/libmicroros/utils.sh: -------------------------------------------------------------------------------- 1 | update_meta() { 2 | python3 -c "import sys; import json; c = '-D' +'$2'; s = json.loads(''.join([l for l in sys.stdin])); k = s['names']['$1']['cmake-args']; i = [c.startswith(v.split('=')[0]) for v in k]; k.pop(i.index(True)) if any(i) else None; k.append(c) if len(c.split('=')[1]) else None; print(json.dumps(s,indent=4))" < $COMPONENT_PATH/configured_colcon.meta > $COMPONENT_PATH/configured_colcon_new.meta 3 | mv $COMPONENT_PATH/configured_colcon_new.meta $COMPONENT_PATH/configured_colcon.meta 4 | } 5 | 6 | remove_meta() { 7 | python3 -c "import sys; import json; c = '-D' +'$2'; s = json.loads(''.join([l for l in sys.stdin])); k = s['names']['$1']['cmake-args']; i = [c.startswith(v.split('=')[0]) for v in k]; k.pop(i.index(True)) if any(i) else None; print(json.dumps(s,indent=4))" < $COMPONENT_PATH/configured_colcon.meta > $COMPONENT_PATH/configured_colcon_new.meta 8 | mv $COMPONENT_PATH/configured_colcon_new.meta $COMPONENT_PATH/configured_colcon.meta 9 | } 10 | 11 | update_meta_from_zephyr_config() { 12 | AUX_VARIABLE=$(grep $1 $ZEPHYR_CONF_FILE | awk -F '=' '{gsub(/"/, "", $2); print $2}'); \ 13 | update_meta "$2" "$3=$AUX_VARIABLE"; \ 14 | } 15 | -------------------------------------------------------------------------------- /modules/libmicroros/colcon.meta: -------------------------------------------------------------------------------- 1 | { 2 | "names": { 3 | "tracetools": { 4 | "cmake-args": [ 5 | "-DTRACETOOLS_DISABLED=ON", 6 | "-DTRACETOOLS_STATUS_CHECKING_TOOL=OFF" 7 | ] 8 | }, 9 | "rcl":{ 10 | "cmake-args":[ 11 | "-DRCL_MICROROS=ON" 12 | ] 13 | }, 14 | "rcutils": { 15 | "cmake-args": [ 16 | "-DENABLE_TESTING=OFF", 17 | "-DRCUTILS_NO_FILESYSTEM=ON", 18 | "-DRCUTILS_NO_THREAD_SUPPORT=ON", 19 | "-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=ON", 20 | "-DRCUTILS_NO_64_ATOMIC=ON" 21 | ] 22 | }, 23 | "microxrcedds_client": { 24 | "cmake-args": [ 25 | "-DUCLIENT_PIC=OFF", 26 | "-DUCLIENT_PROFILE_DISCOVERY=OFF", 27 | "-DUCLIENT_EXTERNAL_SERIAL=ON" 28 | ] 29 | }, 30 | "rmw_microxrcedds": { 31 | "cmake-args": [ 32 | "-DRMW_UXRCE_MAX_NODES=1", 33 | "-DRMW_UXRCE_MAX_PUBLISHERS=1", 34 | "-DRMW_UXRCE_MAX_SUBSCRIPTIONS=0", 35 | "-DRMW_UXRCE_MAX_HISTORY=4", 36 | "-DRMW_UXRCE_MAX_SERVICES=0", 37 | "-DRMW_UXRCE_MAX_CLIENTS=0", 38 | "-DRMW_UXRCE_TRANSPORT=custom_serial" 39 | ] 40 | }, 41 | "tracetools": { 42 | "cmake-args": [ 43 | "-DTRACETOOLS_DISABLED=ON", 44 | "-DTRACETOOLS_STATUS_CHECKING_TOOL=OFF" 45 | ] 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /modules/libmicroros/microros_transports/udp/microros_transports.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ 16 | #define _MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" 26 | { 27 | #endif 28 | 29 | typedef struct { 30 | struct pollfd poll_fd; 31 | char ip[16]; 32 | char port[6]; 33 | } zephyr_transport_params_t; 34 | 35 | #define MICRO_ROS_FRAMING_REQUIRED false 36 | static zephyr_transport_params_t default_params = {{0,0,0}, "192.168.1.100", "8888"}; 37 | 38 | bool zephyr_transport_open(struct uxrCustomTransport * transport); 39 | bool zephyr_transport_close(struct uxrCustomTransport * transport); 40 | size_t zephyr_transport_write(struct uxrCustomTransport* transport, const uint8_t * buf, size_t len, uint8_t * err); 41 | size_t zephyr_transport_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif //_MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ -------------------------------------------------------------------------------- /modules/libmicroros/microros_transports/serial-usb/microros_transports.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ 16 | #define _MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ 17 | 18 | #include 19 | #include 20 | 21 | #if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0) 22 | #include 23 | #else 24 | #include 25 | #endif 26 | 27 | #ifdef __cplusplus 28 | extern "C" 29 | { 30 | #endif 31 | 32 | typedef struct { 33 | size_t fd; 34 | const struct device *uart_dev; 35 | } zephyr_transport_params_t; 36 | 37 | #define MICRO_ROS_FRAMING_REQUIRED true 38 | static zephyr_transport_params_t default_params; 39 | 40 | bool zephyr_transport_open(struct uxrCustomTransport * transport); 41 | bool zephyr_transport_close(struct uxrCustomTransport * transport); 42 | size_t zephyr_transport_write(struct uxrCustomTransport* transport, const uint8_t * buf, size_t len, uint8_t * err); 43 | size_t zephyr_transport_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif //_MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ -------------------------------------------------------------------------------- /modules/libmicroros/microros_transports/serial/microros_transports.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima). 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef _MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ 16 | #define _MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ 17 | 18 | #include 19 | #include 20 | 21 | #if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0) 22 | #include 23 | #else 24 | #include 25 | #endif 26 | 27 | #ifdef __cplusplus 28 | extern "C" 29 | { 30 | #endif 31 | 32 | typedef struct { 33 | size_t fd; 34 | const struct device * uart_dev; 35 | } zephyr_transport_params_t; 36 | 37 | #define MICRO_ROS_FRAMING_REQUIRED true 38 | volatile static zephyr_transport_params_t default_params = {.fd = 1}; 39 | 40 | bool zephyr_transport_open(struct uxrCustomTransport * transport); 41 | bool zephyr_transport_close(struct uxrCustomTransport * transport); 42 | size_t zephyr_transport_write(struct uxrCustomTransport* transport, const uint8_t * buf, size_t len, uint8_t * err); 43 | size_t zephyr_transport_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif //_MICROROS_CLIENT_ZEPHYR_TRANSPORT_H_ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![banner](.images/banner-dark-theme.png#gh-dark-mode-only) 2 | ![banner](.images/banner-light-theme.png#gh-light-mode-only) 3 | 4 | # micro-ROS module for Zephyr 5 | 6 | This module has been tested in Zephyr RTOS v4.0.0 (SDK 0.16.9-rc3), and v4.1.0 (SDK 0.16.9-rc3), using a docker image based on `zephyrprojectrtos/zephyr-build:v0.26.17`. 7 | 8 | ## Dependencies 9 | 10 | This component needs `colcon` and other Python 3 packages in order to build micro-ROS packages: 11 | 12 | ```bash 13 | pip3 install catkin_pkg lark-parser empy colcon-common-extensions 14 | ``` 15 | 16 | ## Usage 17 | 18 | For example for `disco_l475_iot1` board: 19 | 20 | ```bash 21 | west build -b disco_l475_iot1 -p 22 | ``` 23 | 24 | Some configuration parameters can be found using: 25 | 26 | ```bash 27 | west build -t menuconfig 28 | # Modules -> micro-ROS support 29 | ``` 30 | 31 | Is possible to use a micro-ROS Agent just with this docker command: 32 | 33 | ```bash 34 | # Serial micro-ROS Agent 35 | docker run -it --rm -v /dev:/dev --privileged --net=host microros/micro-ros-agent:kilted serial --dev [YOUR BOARD PORT] -v6 36 | 37 | # UDPv4 micro-ROS Agent 38 | docker run -it --rm --net=host microros/micro-ros-agent:kilted udp4 --port 8888 -v6 39 | 40 | ``` 41 | 42 | ## Purpose of the Project 43 | 44 | This software is not ready for production use. It has neither been developed nor 45 | tested for a specific use case. However, the license conditions of the 46 | applicable Open Source licenses allow you to adapt the software to your needs. 47 | Before using it in a safety relevant setting, make sure that the software 48 | fulfills your requirements and adjust it according to any applicable safety 49 | standards, e.g., ISO 26262. 50 | 51 | ## License 52 | 53 | This repository is open-sourced under the Apache-2.0 license. See the [LICENSE](LICENSE) file for details. 54 | 55 | For a list of other open-source components included in ROS 2 system_modes, 56 | see the file [3rd-party-licenses.txt](3rd-party-licenses.txt). 57 | 58 | ## Known Issues/Limitations 59 | 60 | There are no known limitations. 61 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | name: 7 | description: "Manual trigger" 8 | pull_request: 9 | branches: ["rolling", "kilted", "jazzy", "humble"] 10 | 11 | jobs: 12 | 13 | micro_ros_zephyr_module: 14 | runs-on: ubuntu-latest 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | zephyr_version: ["v4.0.0", "v4.1.0"] 19 | steps: 20 | - uses: actions/checkout@v4 21 | with: 22 | path: micro_ros_zephyr_module 23 | 24 | - name: Free disk space 25 | run: | 26 | sudo rm -rf /usr/share/dotnet 27 | sudo rm -rf /usr/local/lib/android 28 | sudo rm -rf /opt/ghc 29 | sudo docker image prune --all --force 30 | 31 | - name: Create build script 32 | run: | 33 | cat << 'EOF' > build.sh 34 | #!/bin/bash 35 | set -e 36 | 37 | # Zephyr setup 38 | apt -y update 39 | west init 40 | cd zephyr 41 | git checkout $ZEPHYR_VERSION 42 | cd .. 43 | west update --narrow 44 | 45 | # Installing micro-ROS prerequisites 46 | pip3 install catkin_pkg lark-parser empy colcon-common-extensions 47 | 48 | if [[ "$REF_NAME" == "humble" ]] || [[ "$HEAD_REF" == *"humble"* ]]; then 49 | # Use empy version 3.3.4 for Humble 50 | pip3 install empy==3.3.4 51 | fi 52 | 53 | # Build with Serial USB transport 54 | west build -b disco_l475_iot1 /github/workspace/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y 55 | 56 | # Build with Serial transport 57 | west build -b disco_l475_iot1 /github/workspace/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y 58 | EOF 59 | chmod +x build.sh 60 | 61 | - name: Build 62 | run: | 63 | sudo docker run --rm \ 64 | --user root \ 65 | -v ${{ github.workspace }}:/github/workspace \ 66 | -w /github/workspace \ 67 | -e CMAKE_PREFIX_PATH=/opt/toolchains \ 68 | -e ZEPHYR_VERSION=${{ matrix.zephyr_version }} \ 69 | -e REF_NAME=${{ github.ref_name }} \ 70 | -e HEAD_REF=${{ github.head_ref }} \ 71 | zephyrprojectrtos/ci:v0.26.17 \ 72 | /github/workspace/build.sh 73 | -------------------------------------------------------------------------------- /.github/workflows/nightly.yml: -------------------------------------------------------------------------------- 1 | name: Nightly 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | name: 7 | description: "Manual trigger" 8 | schedule: 9 | - cron: '0 4 * * *' 10 | 11 | jobs: 12 | 13 | nightly_micro_ros_zephyr_module: 14 | runs-on: ubuntu-latest 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | zephyr_version: ["v4.0.0", "v4.1.0"] 19 | distro: ["rolling", "kilted", "jazzy", "humble"] 20 | include: 21 | - distro: rolling 22 | branch: rolling 23 | - distro: kilted 24 | branch: kilted 25 | - distro: jazzy 26 | branch: jazzy 27 | - distro: humble 28 | branch: humble 29 | steps: 30 | - uses: actions/checkout@v4 31 | with: 32 | path: micro_ros_zephyr_module 33 | ref: ${{ matrix.branch }} 34 | 35 | - name: Free disk space 36 | run: | 37 | sudo rm -rf /usr/share/dotnet 38 | sudo rm -rf /usr/local/lib/android 39 | sudo rm -rf /opt/ghc 40 | sudo docker image prune --all --force 41 | 42 | - name: Create build script 43 | run: | 44 | cat << 'EOF' > build.sh 45 | #!/bin/bash 46 | set -e 47 | 48 | # Zephyr setup 49 | apt -y update 50 | west init 51 | cd zephyr 52 | git checkout $ZEPHYR_VERSION 53 | cd .. 54 | west update --narrow 55 | 56 | # Installing micro-ROS prerequisites 57 | pip3 install catkin_pkg lark-parser empy colcon-common-extensions 58 | 59 | if [[ "$BRANCH_NAME" == "humble" ]]; then 60 | # Use empy version 3.3.4 for Humble 61 | pip3 install empy==3.3.4 62 | fi 63 | 64 | # Build with Serial USB transport 65 | west build -b disco_l475_iot1 /github/workspace/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y 66 | 67 | # Build with Serial transport 68 | west build -b disco_l475_iot1 /github/workspace/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y 69 | EOF 70 | chmod +x build.sh 71 | 72 | - name: Build 73 | run: | 74 | sudo docker run --rm \ 75 | --user root \ 76 | -v ${{ github.workspace }}:/github/workspace \ 77 | -w /github/workspace \ 78 | -e CMAKE_PREFIX_PATH=/opt/toolchains \ 79 | -e ZEPHYR_VERSION=${{ matrix.zephyr_version }} \ 80 | -e BRANCH_NAME=${{ matrix.branch }} \ 81 | zephyrprojectrtos/ci:v0.26.17 \ 82 | /github/workspace/build.sh 83 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0) 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #else 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #endif 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Aborting.\n",__LINE__,(int)temp_rc);for(;;){};}} 28 | #define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Continuing.\n",__LINE__,(int)temp_rc);}} 29 | 30 | rcl_publisher_t publisher; 31 | std_msgs__msg__Int32 msg; 32 | 33 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 34 | { 35 | RCLC_UNUSED(last_call_time); 36 | if (timer != NULL) { 37 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 38 | msg.data++; 39 | } 40 | } 41 | 42 | int main(void) 43 | { 44 | rmw_uros_set_custom_transport( 45 | MICRO_ROS_FRAMING_REQUIRED, 46 | (void *) &default_params, 47 | zephyr_transport_open, 48 | zephyr_transport_close, 49 | zephyr_transport_write, 50 | zephyr_transport_read 51 | ); 52 | 53 | rcl_allocator_t allocator = rcl_get_default_allocator(); 54 | rclc_support_t support; 55 | 56 | // create init_options 57 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 58 | 59 | // create node 60 | rcl_node_t node; 61 | RCCHECK(rclc_node_init_default(&node, "zephyr_int32_publisher", "", &support)); 62 | 63 | // create publisher 64 | RCCHECK(rclc_publisher_init_default( 65 | &publisher, 66 | &node, 67 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 68 | "zephyr_int32_publisher")); 69 | 70 | // create timer, 71 | rcl_timer_t timer; 72 | const unsigned int timer_timeout = 1000; 73 | RCCHECK(rclc_timer_init_default( 74 | &timer, 75 | &support, 76 | RCL_MS_TO_NS(timer_timeout), 77 | timer_callback)); 78 | 79 | // create executor 80 | rclc_executor_t executor; 81 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 82 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 83 | 84 | msg.data = 0; 85 | 86 | while(1){ 87 | rclc_executor_spin_some(&executor, 100); 88 | usleep(100000); 89 | } 90 | 91 | // free resources 92 | RCCHECK(rcl_publisher_fini(&publisher, &node)) 93 | RCCHECK(rcl_node_fini(&node)) 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /modules/libmicroros/microros_transports/udp/microros_transports.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0) 6 | #include 7 | #include 8 | #include 9 | #include 10 | #else 11 | #include 12 | #include 13 | #include 14 | #include 15 | #endif 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | bool zephyr_transport_open(struct uxrCustomTransport * transport){ 25 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 26 | 27 | bool rv = false; 28 | params->poll_fd.fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); 29 | 30 | if (-1 != params->poll_fd.fd) 31 | { 32 | struct addrinfo hints; 33 | struct addrinfo* result; 34 | struct addrinfo* ptr; 35 | 36 | memset(&hints, 0, sizeof(hints)); 37 | hints.ai_family = AF_INET; 38 | hints.ai_socktype = SOCK_DGRAM; 39 | 40 | if (0 == getaddrinfo(params->ip, params->port, &hints, &result)) 41 | { 42 | for (ptr = result; ptr != NULL; ptr = ptr->ai_next) 43 | { 44 | if (0 == connect(params->poll_fd.fd, ptr->ai_addr, ptr->ai_addrlen)) 45 | { 46 | params->poll_fd.events = POLLIN; 47 | rv = true; 48 | break; 49 | } 50 | } 51 | } 52 | freeaddrinfo(result); 53 | } 54 | return rv; 55 | } 56 | 57 | bool zephyr_transport_close(struct uxrCustomTransport * transport){ 58 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 59 | 60 | return (-1 == params->poll_fd.fd) ? true : (0 == close(params->poll_fd.fd)); 61 | } 62 | 63 | size_t zephyr_transport_write(struct uxrCustomTransport* transport, const uint8_t * buf, size_t len, uint8_t * err){ 64 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 65 | 66 | size_t rv = 0; 67 | ssize_t bytes_sent = send(params->poll_fd.fd, (void*)buf, len, 0); 68 | if (-1 != bytes_sent) 69 | { 70 | rv = (size_t)bytes_sent; 71 | *err = 0; 72 | } 73 | else 74 | { 75 | *err = 1; 76 | } 77 | return rv; 78 | } 79 | 80 | size_t zephyr_transport_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err){ 81 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 82 | 83 | size_t rv = 0; 84 | int poll_rv = poll(¶ms->poll_fd, 1, timeout); 85 | if (0 < poll_rv) 86 | { 87 | ssize_t bytes_received = recv(params->poll_fd.fd, (void*)buf, len, 0); 88 | if (-1 != bytes_received) 89 | { 90 | rv = (size_t)bytes_received; 91 | *err = 0; 92 | } 93 | else 94 | { 95 | *err = 1; 96 | } 97 | } 98 | else 99 | { 100 | *err = (0 == poll_rv) ? 0 : 1; 101 | } 102 | return rv; 103 | } -------------------------------------------------------------------------------- /modules/libmicroros/microros_transports/serial/microros_transports.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0) 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #else 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #define RING_BUF_SIZE 2048 27 | #define UART_NODE DT_NODELABEL(usart1) 28 | 29 | char uart_in_buffer[RING_BUF_SIZE]; 30 | char uart_out_buffer[RING_BUF_SIZE]; 31 | 32 | struct ring_buf out_ringbuf, in_ringbuf; 33 | 34 | // --- micro-ROS Serial Transport for Zephyr --- 35 | 36 | static void uart_fifo_callback(const struct device * dev, void * args){ 37 | while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { 38 | if (uart_irq_rx_ready(dev)) { 39 | int recv_len; 40 | char buffer[64]; 41 | size_t len = MIN(ring_buf_space_get(&in_ringbuf), sizeof(buffer)); 42 | 43 | if (len > 0){ 44 | recv_len = uart_fifo_read(dev, buffer, len); 45 | ring_buf_put(&in_ringbuf, buffer, recv_len); 46 | } 47 | 48 | } 49 | } 50 | } 51 | 52 | 53 | bool zephyr_transport_open(struct uxrCustomTransport * transport){ 54 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 55 | 56 | params->uart_dev = DEVICE_DT_GET(UART_NODE); 57 | if (!params->uart_dev) { 58 | printk("Serial device not found\n"); 59 | return false; 60 | } 61 | 62 | ring_buf_init(&in_ringbuf, sizeof(uart_in_buffer), uart_out_buffer); 63 | 64 | uart_irq_callback_set(params->uart_dev, uart_fifo_callback); 65 | 66 | /* Enable rx interrupts */ 67 | uart_irq_rx_enable(params->uart_dev); 68 | 69 | return true; 70 | } 71 | 72 | bool zephyr_transport_close(struct uxrCustomTransport * transport){ 73 | (void) transport; 74 | // TODO: close serial transport here 75 | return true; 76 | } 77 | 78 | size_t zephyr_transport_write(struct uxrCustomTransport* transport, const uint8_t * buf, size_t len, uint8_t * err){ 79 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 80 | 81 | for (size_t i = 0; i < len; i++) 82 | { 83 | uart_poll_out(params->uart_dev, buf[i]); 84 | } 85 | 86 | return len; 87 | } 88 | 89 | size_t zephyr_transport_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err){ 90 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 91 | 92 | size_t read = 0; 93 | int spent_time = 0; 94 | 95 | while(ring_buf_is_empty(&in_ringbuf) && spent_time < timeout){ 96 | usleep(1000); 97 | spent_time++; 98 | } 99 | 100 | uart_irq_rx_disable(params->uart_dev); 101 | read = ring_buf_get(&in_ringbuf, buf, len); 102 | uart_irq_rx_enable(params->uart_dev); 103 | 104 | return read; 105 | } -------------------------------------------------------------------------------- /modules/libmicroros/Kconfig: -------------------------------------------------------------------------------- 1 | menuconfig MICROROS 2 | bool 3 | default n 4 | prompt "micro-ROS Support" 5 | select APP_LINK_WITH_MICROROS 6 | help 7 | Enables a micro-ROS library 8 | 9 | if MICROROS 10 | config APP_LINK_WITH_MICROROS 11 | bool "Link 'app' with MICROROS" 12 | default n 13 | help 14 | Add MICROROS header files to the 'app' include path. 15 | 16 | choice 17 | prompt "micro-ROS transport" 18 | 19 | config MICROROS_TRANSPORT_SERIAL 20 | bool "micro-ROS serial transport" 21 | select RING_BUFFER 22 | config MICROROS_TRANSPORT_SERIAL_USB 23 | bool "micro-ROS USB serial transport" 24 | select RING_BUFFER 25 | select USB_DEVICE_STACK 26 | config MICROROS_TRANSPORT_UDP 27 | bool "micro-ROS UDP network transport" 28 | 29 | endchoice 30 | 31 | if MICROROS_TRANSPORT_UDP 32 | config MICROROS_AGENT_IP 33 | string "micro-ROS Agent IP" 34 | default "192.168.1.100" 35 | help 36 | micro-ROS Agent IP. 37 | 38 | config MICROROS_AGENT_PORT 39 | string "micro-ROS Agent Port" 40 | default "8888" 41 | help 42 | micro-ROS Agent port. 43 | 44 | menu "WiFi Configuration" 45 | 46 | config MICROROS_WIFI_SSID 47 | string "WiFi SSID" 48 | default "myssid" 49 | help 50 | SSID (network name) for the example to connect to. 51 | 52 | config MICROROS_WIFI_PASSWORD 53 | string "WiFi Password" 54 | default "mypassword" 55 | help 56 | WiFi password (WPA or WPA2) for the example to use. 57 | endmenu 58 | endif 59 | 60 | if MICROROS_TRANSPORT_SERIAL 61 | config MICROROS_SERIAL_PORT 62 | string "micro-ROS Agent serial port" 63 | default "1" 64 | help 65 | micro-ROS Agent IP. 66 | endif 67 | 68 | if MICROROS_TRANSPORT_SERIAL_USB 69 | config USB_CDC_ACM 70 | bool 71 | default y 72 | config USB_CDC_ACM_RINGBUF_SIZE 73 | int "USB-CDC-ACM Ringbuffer size" 74 | default "2048" 75 | config USB_DEVICE_PRODUCT 76 | string "USB Device Product" 77 | default "Zephyr micro-ROS" 78 | 79 | endif 80 | config MICROROS_NODES 81 | string "available micro-ROS nodes" 82 | default "1" 83 | 84 | config MICROROS_PUBLISHERS 85 | string "available micro-ROS publishers" 86 | default "1" 87 | 88 | config MICROROS_SUBSCRIBERS 89 | string "available micro-ROS subscribers" 90 | default "1" 91 | 92 | config MICROROS_CLIENTS 93 | string "available micro-ROS service clients" 94 | default "1" 95 | 96 | config MICROROS_SERVERS 97 | string "available micro-ROS service servers" 98 | default "1" 99 | 100 | config MICROROS_RMW_HISTORIC 101 | string "available micro-ROS RMW historic memory" 102 | default "4" 103 | 104 | config MICROROS_XRCE_DDS_MTU 105 | string "micro-ROS transport MTU" 106 | default "512" 107 | 108 | config MICROROS_XRCE_DDS_HISTORIC 109 | string "micro-ROS middleware memory slots" 110 | default "4" 111 | 112 | endif 113 | 114 | -------------------------------------------------------------------------------- /modules/libmicroros/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | if(CONFIG_MICROROS) 4 | 5 | set(MICROROS_DIR ${ZEPHYR_CURRENT_MODULE_DIR}) 6 | 7 | if(CMAKE_GENERATOR STREQUAL "Unix Makefiles") 8 | set(submake "$(MAKE)") 9 | else() 10 | set(submake "make") 11 | endif() 12 | 13 | # micro-ROS library 14 | 15 | zephyr_get_include_directories_for_lang_as_string( C includes) 16 | zephyr_get_system_include_directories_for_lang_as_string(C system_includes) 17 | zephyr_get_compile_definitions_for_lang_as_string( C definitions) 18 | zephyr_get_compile_options_for_lang_as_string( C options) 19 | 20 | zephyr_get_include_directories_for_lang_as_string( CXX includes_cxx) 21 | zephyr_get_system_include_directories_for_lang_as_string(CXX system_includes_cxx) 22 | zephyr_get_compile_definitions_for_lang_as_string( CXX definitions_cxx) 23 | zephyr_get_compile_options_for_lang_as_string( CXX options_cxx) 24 | 25 | set(external_project_cflags 26 | "${includes} ${definitions} ${options} ${system_includes}" 27 | ) 28 | 29 | set(external_project_cxxflags 30 | "${includes_cxx} ${definitions_cxx} ${options_cxx} ${system_includes_cxx}" 31 | ) 32 | 33 | include(ExternalProject) 34 | 35 | externalproject_add(libmicroros_project 36 | PREFIX ${CMAKE_BINARY_DIR}/libmicroros-prefix 37 | SOURCE_DIR ${MICROROS_DIR} 38 | BINARY_DIR ${MICROROS_DIR} 39 | CONFIGURE_COMMAND "" 40 | BUILD_COMMAND 41 | ${submake} -f libmicroros.mk 42 | X_CFLAGS=${external_project_cflags} 43 | X_CXXFLAGS=${external_project_cxxflags} 44 | X_CC=${CMAKE_C_COMPILER} 45 | X_AR=${CMAKE_AR} 46 | X_RANLIB=${CMAKE_RANLIB} 47 | X_CXX=${CMAKE_CXX_COMPILER} 48 | COMPONENT_PATH=${MICROROS_DIR} 49 | ZEPHYR_BASE=${ZEPHYR_BASE} 50 | PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} 51 | INSTALL_COMMAND "" 52 | BUILD_BYPRODUCTS ${MICROROS_DIR}/libmicroros.a 53 | ) 54 | 55 | zephyr_link_libraries(${MICROROS_DIR}/libmicroros.a) 56 | 57 | zephyr_interface_library_named(microros) 58 | add_dependencies(microros libmicroros_project) 59 | target_include_directories(microros INTERFACE ${MICROROS_DIR}/include) 60 | 61 | execute_process( 62 | COMMAND 63 | make -f libmicroros.mk get_package_names 64 | COMPONENT_PATH=${MICROROS_DIR} 65 | WORKING_DIRECTORY 66 | ${MICROROS_DIR} 67 | OUTPUT_VARIABLE 68 | INCLUDE_ROS2_PACKAGES 69 | OUTPUT_STRIP_TRAILING_WHITESPACE 70 | ) 71 | 72 | foreach(pkg ${INCLUDE_ROS2_PACKAGES}) 73 | target_include_directories(microros INTERFACE ${MICROROS_DIR}/include/${pkg}) 74 | endforeach() 75 | 76 | # micro-ROS transport library 77 | 78 | if(CONFIG_MICROROS_TRANSPORT_SERIAL) 79 | set(MICROROS_TRANSPORT_DIR ${MICROROS_DIR}/microros_transports/serial) 80 | elseif(CONFIG_MICROROS_TRANSPORT_SERIAL_USB) 81 | set(MICROROS_TRANSPORT_DIR ${MICROROS_DIR}/microros_transports/serial-usb) 82 | elseif(CONFIG_MICROROS_TRANSPORT_UDP) 83 | set(MICROROS_TRANSPORT_DIR ${MICROROS_DIR}/microros_transports/udp) 84 | else() 85 | message(FATAL_ERROR Please set a micro-ROS transport) 86 | endif() 87 | 88 | zephyr_library_named(microros_transports) 89 | zephyr_include_directories(${MICROROS_DIR}/include) 90 | zephyr_include_directories(${MICROROS_TRANSPORT_DIR}) 91 | 92 | zephyr_library_sources( 93 | ${MICROROS_TRANSPORT_DIR}/microros_transports.c 94 | ) 95 | 96 | add_dependencies(microros microros_transports) 97 | add_dependencies(microros_transports libmicroros_project) 98 | 99 | # Cleaning 100 | 101 | set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES 102 | ${MICROROS_DIR}/include 103 | ${MICROROS_DIR}/configured_colcon.meta 104 | ${MICROROS_DIR}/zephyr_toolchain.cmake 105 | ) 106 | 107 | endif() 108 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Want to contribute? Great! You can do so through the standard GitHub pull 4 | request model. For large contributions we do encourage you to file a ticket in 5 | the GitHub issues tracking system prior to any code development to coordinate 6 | with the system_modes development team early in the process. Coordinating up 7 | front helps to avoid frustration later on. 8 | 9 | Your contribution must be licensed under the Apache-2.0 license, the license 10 | used by this project. 11 | 12 | ## Add / retain copyright notices 13 | 14 | Include a copyright notice and license in each new file to be contributed, 15 | consistent with the style used by this project. If your contribution contains 16 | code under the copyright of a third party, document its origin, license, and 17 | copyright holders. 18 | 19 | ## Sign your work 20 | 21 | This project tracks patch provenance and licensing using a modified Developer 22 | Certificate of Origin (DCO; from [OSDL][DCO]) and Signed-off-by tags initially 23 | developed by the Linux kernel project. 24 | 25 | ``` 26 | system_modes Developer's Certificate of Origin. Version 1.0 27 | By making a contribution to this project, I certify that: 28 | (a) The contribution was created in whole or in part by me and I 29 | have the right to submit it under the "Apache License, Version 2.0" 30 | ("Apache-2.0"); or 31 | (b) The contribution is based upon previous work that is covered by 32 | an appropriate open source license and I have the right under 33 | that license to submit that work with modifications, whether 34 | created in whole or in part by me, under the Apache-2.0 license; 35 | or 36 | (c) The contribution was provided directly to me by some other 37 | person who certified (a) or (b) and I have not modified it. 38 | (d) I understand and agree that this project and the contribution 39 | are public and that a record of the contribution (including all 40 | metadata and personal information I submit with it, including my 41 | sign-off) is maintained indefinitely and may be redistributed 42 | consistent with this project and the requirements of the Apache-2.0 43 | license or any open source license(s) involved, where they are 44 | relevant. 45 | (e) I am granting the contribution to this project under the terms of 46 | Apache-2.0. 47 | http://www.apache.org/licenses/LICENSE-2.0 48 | ``` 49 | 50 | With the sign-off in a commit message you certify that you authored the patch 51 | or otherwise have the right to submit it under an open source license. The 52 | procedure is simple: To certify above system_modes Developer's Certificate of 53 | Origin 1.0 for your contribution just append a line 54 | 55 | Signed-off-by: Random J Developer 56 | 57 | to every commit message using your real name or your pseudonym and a valid 58 | email address. 59 | 60 | If you have set your `user.name` and `user.email` git configs you can 61 | automatically sign the commit by running the git-commit command with the `-s` 62 | option. There may be multiple sign-offs if more than one developer was 63 | involved in authoring the contribution. 64 | 65 | For a more detailed description of this procedure, please see 66 | [SubmittingPatches][] which was extracted from the Linux kernel project, and 67 | which is stored in an external repository. 68 | 69 | ### Individual vs. Corporate Contributors 70 | 71 | Often employers or academic institution have ownership over code that is 72 | written in certain circumstances, so please do due diligence to ensure that 73 | you have the right to submit the code. 74 | 75 | If you are a developer who is authorized to contribute to system_modes on 76 | behalf of your employer, then please use your corporate email address in the 77 | Signed-off-by tag. Otherwise please use a personal email address. 78 | 79 | ## Maintain Copyright holder / Contributor list 80 | 81 | Each contributor is responsible for identifying themselves in the 82 | [NOTICE](NOTICE) file, the project's list of copyright holders and authors. 83 | Please add the respective information corresponding to the Signed-off-by tag 84 | as part of your first pull request. 85 | 86 | If you are a developer who is authorized to contribute to system_modes on 87 | behalf of your employer, then add your company / organization to the list of 88 | copyright holders in the [NOTICE](NOTICE) file. As author of a corporate 89 | contribution you can also add your name and corporate email address as in the 90 | Signed-off-by tag. 91 | 92 | If your contribution is covered by this project's DCO's clause "(c) The 93 | contribution was provided directly to me by some other person who certified 94 | (a) or (b) and I have not modified it", please add the appropriate copyright 95 | holder(s) to the [NOTICE](NOTICE) file as part of your contribution. 96 | 97 | 98 | [DCO]: http://web.archive.org/web/20070306195036/http://osdlab.org/newsroom/press_releases/2004/2004_05_24_dco.html 99 | 100 | [SubmittingPatches]: https://github.com/wking/signed-off-by/blob/7d71be37194df05c349157a2161c7534feaf86a4/Documentation/SubmittingPatches -------------------------------------------------------------------------------- /modules/libmicroros/microros_transports/serial-usb/microros_transports.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0) 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #else 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | 29 | #define RING_BUF_SIZE 2048 30 | 31 | char uart_in_buffer[RING_BUF_SIZE]; 32 | char uart_out_buffer[RING_BUF_SIZE]; 33 | 34 | struct ring_buf out_ringbuf, in_ringbuf; 35 | 36 | static void uart_fifo_callback(const struct device *dev, void * user_data){ 37 | while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { 38 | if (uart_irq_rx_ready(dev)) { 39 | int recv_len; 40 | char buffer[64]; 41 | size_t len = MIN(ring_buf_space_get(&in_ringbuf), sizeof(buffer)); 42 | 43 | if (len > 0){ 44 | recv_len = uart_fifo_read(dev, buffer, len); 45 | ring_buf_put(&in_ringbuf, buffer, recv_len); 46 | } 47 | 48 | } 49 | 50 | if (uart_irq_tx_ready(dev)) { 51 | char buffer[64]; 52 | int rb_len; 53 | 54 | rb_len = ring_buf_get(&out_ringbuf, buffer, sizeof(buffer)); 55 | 56 | if (rb_len == 0) { 57 | uart_irq_tx_disable(dev); 58 | continue; 59 | } 60 | 61 | uart_fifo_fill(dev, buffer, rb_len); 62 | } 63 | } 64 | } 65 | 66 | bool zephyr_transport_open(struct uxrCustomTransport * transport){ 67 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 68 | 69 | int ret; 70 | uint32_t baudrate, dtr = 0U; 71 | 72 | 73 | params->uart_dev = device_get_binding("CDC_ACM_0"); 74 | if (!params->uart_dev) { 75 | printk("CDC ACM device not found\n"); 76 | return false; 77 | } 78 | 79 | ret = usb_enable(NULL); 80 | if (ret != 0) { 81 | printk("Failed to enable USB\n"); 82 | return false; 83 | } 84 | 85 | ring_buf_init(&out_ringbuf, sizeof(uart_out_buffer), uart_out_buffer); 86 | ring_buf_init(&in_ringbuf, sizeof(uart_in_buffer), uart_out_buffer); 87 | 88 | printk("Waiting for agent connection\n"); 89 | 90 | while (true) { 91 | uart_line_ctrl_get(params->uart_dev, UART_LINE_CTRL_DTR, &dtr); 92 | if (dtr) { 93 | break; 94 | } else { 95 | /* Give CPU resources to low priority threads. */ 96 | k_sleep(K_MSEC(100)); 97 | } 98 | } 99 | 100 | printk("Serial port connected!\n"); 101 | 102 | /* They are optional, we use them to test the interrupt endpoint */ 103 | ret = uart_line_ctrl_set(params->uart_dev, UART_LINE_CTRL_DCD, 1); 104 | if (ret) { 105 | printk("Failed to set DCD, ret code %d\n", ret); 106 | } 107 | 108 | ret = uart_line_ctrl_set(params->uart_dev, UART_LINE_CTRL_DSR, 1); 109 | if (ret) { 110 | printk("Failed to set DSR, ret code %d\n", ret); 111 | } 112 | 113 | /* Wait 1 sec for the host to do all settings */ 114 | k_busy_wait(1000*1000); 115 | 116 | ret = uart_line_ctrl_get(params->uart_dev, UART_LINE_CTRL_BAUD_RATE, &baudrate); 117 | if (ret) { 118 | printk("Failed to get baudrate, ret code %d\n", ret); 119 | } 120 | 121 | uart_irq_callback_set(params->uart_dev, uart_fifo_callback); 122 | 123 | /* Enable rx interrupts */ 124 | uart_irq_rx_enable(params->uart_dev); 125 | 126 | return true; 127 | } 128 | 129 | bool zephyr_transport_close(struct uxrCustomTransport * transport){ 130 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 131 | (void) params; 132 | 133 | return true; 134 | } 135 | 136 | size_t zephyr_transport_write(struct uxrCustomTransport* transport, const uint8_t * buf, size_t len, uint8_t * err){ 137 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 138 | 139 | size_t wrote; 140 | 141 | wrote = ring_buf_put(&out_ringbuf, buf, len); 142 | 143 | uart_irq_tx_enable(params->uart_dev); 144 | 145 | while (!ring_buf_is_empty(&out_ringbuf)){ 146 | k_sleep(K_MSEC(5)); 147 | } 148 | 149 | return wrote; 150 | } 151 | 152 | size_t zephyr_transport_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* err){ 153 | zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; 154 | 155 | size_t read = 0; 156 | int spent_time = 0; 157 | 158 | while(ring_buf_is_empty(&in_ringbuf) && spent_time < timeout){ 159 | k_sleep(K_MSEC(1)); 160 | spent_time++; 161 | } 162 | 163 | uart_irq_rx_disable(params->uart_dev); 164 | read = ring_buf_get(&in_ringbuf, buf, len); 165 | uart_irq_rx_enable(params->uart_dev); 166 | 167 | return read; 168 | } -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | Changelog for package micro_ros_zephyr 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | 6.0.0 (2024-06-03) 6 | ------------------ 7 | * Ignore lttngpy (`#135 `_) 8 | * Fix of unknown Ringbuffer and not found USB-Serial Device (`#125 `_) (`#130 `_) 9 | * Added Ringbuffer-config in prj.conf for eliminating error 10 | * Added Label CDC_ACM_0 label with an overlay so "modules/libmicroros/microros_transports/serial-usb/microros_transports.c" can find the device 11 | * Update app.overlay 12 | * Update app.overlay 13 | A fix for backwards compability 14 | * Update app.overlay 15 | * Update app.overlay 16 | * Update prj.conf 17 | * Better comments 18 | * Changed settings to conditional from transport choice 19 | * Update prj.conf 20 | Co-authored-by: Pablo Garrido 21 | * Update modules/libmicroros/Kconfig 22 | Co-authored-by: Pablo Garrido 23 | --------- 24 | Co-authored-by: scrapforge 25 | Co-authored-by: Pablo Garrido 26 | (cherry picked from commit 7c5edcdf9e0a6c6e131d9e45ad357fa0757a5584) 27 | Co-authored-by: scrapforge <99104728+scrapforge@users.noreply.github.com> 28 | * Update CI with Serial USB build (`#126 `_) (`#128 `_) 29 | (cherry picked from commit e1e23407664625c5cb145c791561007fe6d51df9) 30 | Co-authored-by: Pablo Garrido 31 | * Fix Nightly 32 | * Remove micro-ROS fork (`#123 `_) 33 | * Contributors: Antonio Cuadros, Pablo Garrido, mergify[bot] 34 | 35 | 5.0.0 (2023-06-12) 36 | ------------------ 37 | * Update branches to rolling (`#121 `_) 38 | * Update rolling sources (`#120 `_) 39 | * Fix Zephyr headers for UDP transport (`#108 `_) (`#114 `_) 40 | * Adjust default_params initialization for cpp compatibility (`#107 `_) (`#111 `_) 41 | * Ignore test_msgs (`#99 `_) (`#102 `_) 42 | * Fix headers and timer (`#94 `_) (`#97 `_) 43 | * transports: add mising version.h to serial-usb transport header (`#90 `_) (`#91 `_) 44 | * Use ZEPHYR_VERSION_CODE instead of KERNEL_VERSION_MAJOR (`#86 `_) 45 | * Fix/zephyr includes (`#82 `_) (`#85 `_) 46 | * Add rosidl_core (`#75 `_) 47 | * Fix nightly (`#69 `_) (`#71 `_) 48 | * Move support to v2.7.x and v3.1.0 (`#64 `_) 49 | 50 | 4.0.0 (2022-05-25) 51 | ------------------ 52 | * Update banner (`#56 `_) 53 | * Merge pull request `#54 `_ from micro-ROS/mergify/bp/main/pr-53 54 | * [FIX] pass zephyr MTU config to UClient 55 | * Add logos (`#50 `_) 56 | * Fix Rolling includes (`#49 `_) 57 | * Fix CI (`#46 `_) 58 | * Fix include paths 59 | * Fix include paths (`#45 `_) 60 | * Fix example and serial transports (`#36 `_) (`#39 `_) 61 | * Add typesupport introspection (backport `#37 `_) (`#38 `_) 62 | * multichange tool (`#31 `_) (`#33 `_) 63 | * Hotfix: Zephyr gcc typesupport error (`#27 `_) 64 | * Update from 2.6.0rc1 to 2.6.0 (`#30 `_) 65 | * Add micro_ros_utilities repo (`#23 `_) 66 | * Enable introspection (`#21 `_) 67 | * Initial changes for Rolling release 68 | * Fix CI (`#25 `_) 69 | * Add v2.5/v2.6 (`#24 `_) 70 | * Simplify Colcon installation (`#19 `_) 71 | * Modify RMW API include (`#16 `_) 72 | * Fix RCLC Foxy (`#17 `_) 73 | * Update RCLC repo (`#15 `_) 74 | * Refactor external transports (`#14 `_) 75 | * Add issue template 76 | * Add nightly CI 77 | * Update ci.yml 78 | * Add new micro_ros_msgs repo (`#13 `_) 79 | * rclc_executor_set_timeout (`#12 `_) 80 | * rework demos (`#11 `_) 81 | * Update main.c (`#10 `_) 82 | * Remove explicit C++ support (fixes `#4 `_) (`#9 `_) 83 | * README: Fix docker command for the serial micro-ROS agent (`#8 `_) 84 | * Update README.md 85 | * Update README.md 86 | * update ranlib (`#3 `_) 87 | * Update README.md 88 | * Update CI (`#5 `_) 89 | * Add preliminary CI 90 | * Fix copyright 91 | * Remove sample.yml 92 | * Added license and README 93 | * Updated Kconfig uros params 94 | * Initial 95 | * Initial commit 96 | -------------------------------------------------------------------------------- /modules/libmicroros/libmicroros.mk: -------------------------------------------------------------------------------- 1 | UROS_DIR = $(COMPONENT_PATH)/micro_ros_src 2 | DEBUG ?= 0 3 | 4 | ifeq ($(DEBUG), 1) 5 | BUILD_TYPE = Debug 6 | else 7 | BUILD_TYPE = Release 8 | endif 9 | 10 | CFLAGS_INTERNAL := $(X_CFLAGS) 11 | CXXFLAGS_INTERNAL := $(X_CXXFLAGS) 12 | 13 | CFLAGS_INTERNAL := -c -I$(ZEPHYR_BASE)/include/posix -I$(PROJECT_BINARY_DIR)/include/generated $(CFLAGS_INTERNAL) 14 | CXXFLAGS_INTERNAL := -c -I$(ZEPHYR_BASE)/include/posix -I$(PROJECT_BINARY_DIR)/include/generated $(CXXFLAGS_INTERNAL) 15 | 16 | all: $(COMPONENT_PATH)/libmicroros.a 17 | 18 | clean: 19 | rm -rf $(COMPONENT_PATH)/libmicroros.a; \ 20 | rm -rf $(COMPONENT_PATH)/include; \ 21 | rm -rf $(COMPONENT_PATH)/zephyr_toolchain.cmake; \ 22 | rm -rf $(COMPONENT_PATH)/micro_ros_dev; \ 23 | rm -rf $(COMPONENT_PATH)/micro_ros_src; 24 | 25 | ZEPHYR_CONF_FILE := $(PROJECT_BINARY_DIR)/.config 26 | 27 | get_package_names: $(COMPONENT_PATH)/micro_ros_src/src 28 | @cd $(COMPONENT_PATH)/micro_ros_src/src; \ 29 | colcon list | awk '{print $$1}' | awk -v d=";" '{s=(NR==1?s:s d)$$0}END{print s}' 30 | 31 | configure_colcon_meta: $(COMPONENT_PATH)/colcon.meta $(COMPONENT_PATH)/micro_ros_src/src 32 | . $(COMPONENT_PATH)/utils.sh; \ 33 | cp $(COMPONENT_PATH)/colcon.meta $(COMPONENT_PATH)/configured_colcon.meta; \ 34 | ZEPHYR_CONF_FILE=$(ZEPHYR_CONF_FILE); \ 35 | update_meta_from_zephyr_config "CONFIG_MICROROS_NODES" "rmw_microxrcedds" "RMW_UXRCE_MAX_NODES"; \ 36 | update_meta_from_zephyr_config "CONFIG_MICROROS_PUBLISHERS" "rmw_microxrcedds" "RMW_UXRCE_MAX_PUBLISHERS"; \ 37 | update_meta_from_zephyr_config "CONFIG_MICROROS_SUBSCRIBERS" "rmw_microxrcedds" "RMW_UXRCE_MAX_SUBSCRIPTIONS"; \ 38 | update_meta_from_zephyr_config "CONFIG_MICROROS_CLIENTS" "rmw_microxrcedds" "RMW_UXRCE_MAX_CLIENTS"; \ 39 | update_meta_from_zephyr_config "CONFIG_MICROROS_SERVERS" "rmw_microxrcedds" "RMW_UXRCE_MAX_SERVICES"; \ 40 | update_meta_from_zephyr_config "CONFIG_MICROROS_RMW_HISTORIC" "rmw_microxrcedds" "RMW_UXRCE_MAX_HISTORY"; \ 41 | update_meta_from_zephyr_config "CONFIG_MICROROS_XRCE_DDS_HISTORIC" "rmw_microxrcedds" "RMW_UXRCE_STREAM_HISTORY"; \ 42 | update_meta_from_zephyr_config "CONFIG_MICROROS_XRCE_DDS_MTU" "microxrcedds_client" "UCLIENT_CUSTOM_TRANSPORT_MTU"; \ 43 | update_meta "microxrcedds_client" "UCLIENT_PROFILE_SERIAL=OFF"; \ 44 | update_meta "microxrcedds_client" "UCLIENT_PROFILE_UDP=OFF"; \ 45 | update_meta "microxrcedds_client" "UCLIENT_PROFILE_TCP=OFF"; \ 46 | update_meta "microxrcedds_client" "UCLIENT_PROFILE_CUSTOM_TRANSPORT=ON"; \ 47 | update_meta "microxrcedds_client" "UCLIENT_PROFILE_STREAM_FRAMING=ON"; \ 48 | update_meta "rmw_microxrcedds" "RMW_UXRCE_TRANSPORT=custom"; 49 | 50 | 51 | configure_toolchain: $(COMPONENT_PATH)/zephyr_toolchain.cmake.in 52 | rm -f $(COMPONENT_PATH)/zephyr_toolchain.cmake; \ 53 | cat $(COMPONENT_PATH)/zephyr_toolchain.cmake.in | \ 54 | sed "s/@CMAKE_C_COMPILER@/$(subst /,\/,$(X_CC))/g" | \ 55 | sed "s/@CMAKE_CXX_COMPILER@/$(subst /,\/,$(X_CXX))/g" | \ 56 | sed "s/@CMAKE_SYSROOT@/$(subst /,\/,$(COMPONENT_PATH))/g" | \ 57 | sed "s/@CFLAGS@/$(subst /,\/,$(CFLAGS_INTERNAL))/g" | \ 58 | sed "s/@CXXFLAGS@/$(subst /,\/,$(CXXFLAGS_INTERNAL))/g" \ 59 | > $(COMPONENT_PATH)/zephyr_toolchain.cmake 60 | 61 | $(COMPONENT_PATH)/micro_ros_dev/install: 62 | rm -rf micro_ros_dev; \ 63 | mkdir micro_ros_dev; cd micro_ros_dev; \ 64 | git clone -b kilted https://github.com/ament/ament_cmake src/ament_cmake; \ 65 | git clone -b kilted https://github.com/ament/ament_lint src/ament_lint; \ 66 | git clone -b kilted https://github.com/ament/ament_package src/ament_package; \ 67 | git clone -b kilted https://github.com/ament/googletest src/googletest; \ 68 | git clone -b kilted https://github.com/ros2/ament_cmake_ros src/ament_cmake_ros; \ 69 | git clone -b kilted https://github.com/ament/ament_index src/ament_index; \ 70 | touch src/ament_cmake_ros/rmw_test_fixture_implementation/COLCON_IGNORE; \ 71 | touch src/ament_cmake_ros/rmw_test_fixture/COLCON_IGNORE; \ 72 | colcon build --cmake-args -DBUILD_TESTING=OFF; 73 | 74 | $(COMPONENT_PATH)/micro_ros_src/src: 75 | @rm -rf micro_ros_src; \ 76 | mkdir micro_ros_src; cd micro_ros_src; \ 77 | git clone -b ros2 https://github.com/eProsima/micro-CDR src/micro-CDR; \ 78 | git clone -b ros2 https://github.com/eProsima/Micro-XRCE-DDS-Client src/Micro-XRCE-DDS-Client; \ 79 | git clone -b kilted https://github.com/micro-ROS/rcl src/rcl; \ 80 | git clone -b kilted https://github.com/ros2/rclc src/rclc; \ 81 | git clone -b kilted https://github.com/micro-ROS/rcutils src/rcutils; \ 82 | git clone -b kilted https://github.com/micro-ROS/micro_ros_msgs src/micro_ros_msgs; \ 83 | git clone -b kilted https://github.com/micro-ROS/rmw-microxrcedds src/rmw-microxrcedds; \ 84 | git clone -b kilted https://github.com/micro-ROS/rosidl_typesupport src/rosidl_typesupport; \ 85 | git clone -b kilted https://github.com/micro-ROS/rosidl_typesupport_microxrcedds src/rosidl_typesupport_microxrcedds; \ 86 | git clone -b kilted https://github.com/ros2/rosidl src/rosidl; \ 87 | git clone -b kilted https://github.com/ros2/rosidl_dynamic_typesupport src/rosidl_dynamic_typesupport; \ 88 | git clone -b kilted https://github.com/ros2/rmw src/rmw; \ 89 | git clone -b kilted https://github.com/ros2/rcl_interfaces src/rcl_interfaces; \ 90 | git clone -b kilted https://github.com/ros2/rosidl_defaults src/rosidl_defaults; \ 91 | git clone -b kilted https://github.com/ros2/unique_identifier_msgs src/unique_identifier_msgs; \ 92 | git clone -b kilted https://github.com/ros2/common_interfaces src/common_interfaces; \ 93 | git clone -b kilted https://github.com/ros2/test_interface_files src/test_interface_files; \ 94 | git clone -b kilted https://github.com/ros2/rmw_implementation src/rmw_implementation; \ 95 | git clone -b kilted https://github.com/ros2/rcl_logging src/rcl_logging; \ 96 | git clone -b kilted https://github.com/ros2/ros2_tracing src/ros2_tracing; \ 97 | git clone -b kilted https://github.com/micro-ROS/micro_ros_utilities src/micro_ros_utilities; \ 98 | git clone -b kilted https://github.com/ros2/rosidl_core src/rosidl_core; \ 99 | touch src/ros2_tracing/test_tracetools/COLCON_IGNORE; \ 100 | touch src/ros2_tracing/lttngpy/COLCON_IGNORE; \ 101 | touch src/rosidl/rosidl_typesupport_introspection_cpp/COLCON_IGNORE; \ 102 | touch src/rclc/rclc_examples/COLCON_IGNORE; \ 103 | touch src/common_interfaces/actionlib_msgs/COLCON_IGNORE; \ 104 | touch src/common_interfaces/std_srvs/COLCON_IGNORE; \ 105 | touch src/rcl/rcl_yaml_param_parser/COLCON_IGNORE; \ 106 | touch src/rcl_logging/rcl_logging_spdlog/COLCON_IGNORE; \ 107 | touch src/rcl_interfaces/test_msgs/COLCON_IGNORE; \ 108 | touch src/rmw/rmw_security_common/COLCON_IGNORE; 109 | 110 | $(COMPONENT_PATH)/micro_ros_src/install: configure_colcon_meta configure_toolchain $(COMPONENT_PATH)/micro_ros_dev/install $(COMPONENT_PATH)/micro_ros_src/src 111 | cd $(UROS_DIR); \ 112 | . ../micro_ros_dev/install/local_setup.sh; \ 113 | colcon build \ 114 | --merge-install \ 115 | --packages-ignore-regex=.*_cpp \ 116 | --metas $(COMPONENT_PATH)/configured_colcon.meta \ 117 | --cmake-args \ 118 | "--no-warn-unused-cli" \ 119 | -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF \ 120 | -DTHIRDPARTY=ON \ 121 | -DBUILD_SHARED_LIBS=OFF \ 122 | -DBUILD_TESTING=OFF \ 123 | -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \ 124 | -DCMAKE_TOOLCHAIN_FILE=$(COMPONENT_PATH)/zephyr_toolchain.cmake \ 125 | -DCMAKE_VERBOSE_MAKEFILE=OFF; \ 126 | 127 | $(COMPONENT_PATH)/libmicroros.a: $(COMPONENT_PATH)/micro_ros_src/install 128 | mkdir -p $(UROS_DIR)/libmicroros; cd $(UROS_DIR)/libmicroros; \ 129 | for file in $$(find $(UROS_DIR)/install/lib/ -name '*.a'); do \ 130 | folder=$$(echo $$file | sed -E "s/(.+)\/(.+).a/\2/"); \ 131 | mkdir -p $$folder; cd $$folder; $(X_AR) x $$file; \ 132 | for f in *; do \ 133 | mv $$f ../$$folder-$$f; \ 134 | done; \ 135 | cd ..; rm -rf $$folder; \ 136 | done ; \ 137 | $(X_AR) rc libmicroros.a *.obj; cp libmicroros.a $(COMPONENT_PATH); ${X_RANLIB} $(COMPONENT_PATH)/libmicroros.a; \ 138 | cd ..; rm -rf libmicroros; \ 139 | cp -R $(UROS_DIR)/install/include $(COMPONENT_PATH)/include; 140 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------