├── messages └── complex_msg │ ├── msg │ ├── MultiStringTest.msg │ └── NestedMsgTest.msg │ ├── CHANGELOG.rst │ ├── CMakeLists.txt │ └── package.xml ├── 3rd-party-licenses.txt ├── .vscode └── settings.json ├── rclc ├── int32_multinode │ ├── CMakeLists.txt │ └── main.c ├── addtwoints_client │ ├── CMakeLists.txt │ └── main.c ├── addtwoints_server │ ├── CMakeLists.txt │ └── main.c ├── timer │ ├── CMakeLists.txt │ └── main.c ├── int32_publisher │ ├── CMakeLists.txt │ └── main.c ├── int32_subscriber │ ├── CMakeLists.txt │ └── main.c ├── ping_uros_agent │ ├── CMakeLists.txt │ └── main.c ├── string_publisher │ ├── CMakeLists.txt │ └── main.c ├── string_subscriber │ ├── CMakeLists.txt │ └── main.c ├── epoch_synchronization │ ├── CMakeLists.txt │ └── main.c ├── fragmented_publication │ ├── CMakeLists.txt │ └── main.c ├── fragmented_subscription │ ├── CMakeLists.txt │ └── main.c ├── ping_pong │ ├── CMakeLists.txt │ └── main.c ├── complex_msg_publisher │ ├── CMakeLists.txt │ └── main.c ├── graph_introspection │ ├── graph_visualizer │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── publisher_count │ │ ├── CMakeLists.txt │ │ └── main.c │ └── subscription_count │ │ ├── CMakeLists.txt │ │ └── main.c ├── int32_publisher_subscriber │ ├── CMakeLists.txt │ └── main.c ├── complex_msg_subscriber │ ├── CMakeLists.txt │ └── main.c ├── fibonacci_action_client │ ├── CMakeLists.txt │ └── main.c ├── fibonacci_action_server │ ├── CMakeLists.txt │ └── main.c ├── parameter_server │ ├── CMakeLists.txt │ └── main.c ├── configuration_example │ ├── configured_publisher │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── configured_subscriber │ │ ├── CMakeLists.txt │ │ └── main.c │ └── custom_transports │ │ ├── CMakeLists.txt │ │ └── main.c ├── static_type_handling │ ├── CMakeLists.txt │ └── main.c ├── multithread_publisher_subscriber │ ├── CMakeLists.txt │ └── main.c ├── autodiscover_agent │ ├── CMakeLists.txt │ └── main.c ├── package.xml ├── CMakeLists.txt └── CHANGELOG.rst ├── .github ├── ISSUE_TEMPLATE │ └── general-issue.md └── workflows │ └── ci.yml ├── NOTICE ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE └── README.md /messages/complex_msg/msg/MultiStringTest.msg: -------------------------------------------------------------------------------- 1 | string data1 2 | string data2 3 | string data3 4 | string data4 -------------------------------------------------------------------------------- /3rd-party-licenses.txt: -------------------------------------------------------------------------------- 1 | Third Party Licenses 2 | ==================== 3 | 4 | This repository does not directly contain 3rd party source code. 5 | 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "array": "c", 4 | "string": "c", 5 | "string_view": "c" 6 | } 7 | } -------------------------------------------------------------------------------- /messages/complex_msg/msg/NestedMsgTest.msg: -------------------------------------------------------------------------------- 1 | bool data1 2 | byte data2 3 | char data3 4 | float32 data4 5 | float64 data5 6 | int8 data6 7 | uint8 data7 8 | int16 data8 9 | uint16 data9 10 | int32 data10 11 | uint32 data11 12 | int64 data12 13 | uint64 data13 14 | MultiStringTest data14 -------------------------------------------------------------------------------- /messages/complex_msg/CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | Changelog for package complex_msgs 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | 6.0.0 (2024-05-31) 6 | ------------------ 7 | 8 | 5.0.0 (2023-06-12) 9 | ------------------ 10 | 11 | 4.0.0 (2022-05-25) 12 | ------------------ 13 | * Foxy migration (`#25 `_) 14 | -------------------------------------------------------------------------------- /rclc/int32_multinode/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(int32_multinode LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | 10 | add_executable(${PROJECT_NAME} main.c) 11 | 12 | ament_target_dependencies(${PROJECT_NAME} 13 | rcl 14 | rclc 15 | std_msgs 16 | ) 17 | 18 | install(TARGETS ${PROJECT_NAME} 19 | DESTINATION ${PROJECT_NAME} 20 | ) 21 | -------------------------------------------------------------------------------- /rclc/addtwoints_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(addtwoints_client LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(example_interfaces REQUIRED) 9 | 10 | add_executable(${PROJECT_NAME} main.c) 11 | 12 | ament_target_dependencies(${PROJECT_NAME} 13 | rcl 14 | rclc 15 | example_interfaces 16 | ) 17 | 18 | install(TARGETS ${PROJECT_NAME} 19 | DESTINATION ${PROJECT_NAME} 20 | ) 21 | -------------------------------------------------------------------------------- /rclc/addtwoints_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(addtwoints_server LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(example_interfaces REQUIRED) 9 | 10 | add_executable(${PROJECT_NAME} main.c) 11 | 12 | ament_target_dependencies(${PROJECT_NAME} 13 | rcl 14 | rclc 15 | example_interfaces 16 | ) 17 | 18 | install(TARGETS ${PROJECT_NAME} 19 | DESTINATION ${PROJECT_NAME} 20 | ) 21 | -------------------------------------------------------------------------------- /rclc/timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(timer LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/int32_publisher/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(int32_publisher LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/int32_subscriber/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(int32_subscriber LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/ping_uros_agent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(ping_uros_agent LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(rmw_microxrcedds REQUIRED) 9 | find_package(std_msgs REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | rmw_microxrcedds 17 | std_msgs 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/string_publisher/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(string_publisher LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/string_subscriber/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(string_subscriber LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/epoch_synchronization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(epoch_synchronization LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/fragmented_publication/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(fragmented_publication LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/fragmented_subscription/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(fragmented_subscription LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/ping_pong/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(ping_pong LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | builtin_interfaces 18 | rmw_microxrcedds 19 | ) 20 | 21 | install(TARGETS ${PROJECT_NAME} 22 | DESTINATION ${PROJECT_NAME} 23 | ) 24 | -------------------------------------------------------------------------------- /rclc/complex_msg_publisher/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(complex_msg_publisher LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(complex_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | complex_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/graph_introspection/graph_visualizer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(graph_visualizer LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/int32_publisher_subscriber/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(int32_publisher_subscriber LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | std_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/complex_msg_subscriber/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(complex_msg_subscriber LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(complex_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | complex_msgs 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | 24 | -------------------------------------------------------------------------------- /rclc/graph_introspection/publisher_count/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(publisher_count LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(rcl_interfaces REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | rcl_interfaces 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/graph_introspection/subscription_count/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(subscription_count LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(rcl_interfaces REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | 13 | ament_target_dependencies(${PROJECT_NAME} 14 | rcl 15 | rclc 16 | rcl_interfaces 17 | rmw_microxrcedds 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/fibonacci_action_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(fibonacci_action_client LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(example_interfaces REQUIRED) 9 | find_package(Threads REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | target_link_libraries(${PROJECT_NAME} Threads::Threads) 13 | 14 | ament_target_dependencies(${PROJECT_NAME} 15 | rcl 16 | rclc 17 | example_interfaces 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/fibonacci_action_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(fibonacci_action_server LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(example_interfaces REQUIRED) 9 | find_package(Threads REQUIRED) 10 | 11 | add_executable(${PROJECT_NAME} main.c) 12 | target_link_libraries(${PROJECT_NAME} Threads::Threads) 13 | 14 | ament_target_dependencies(${PROJECT_NAME} 15 | rcl 16 | rclc 17 | example_interfaces 18 | ) 19 | 20 | install(TARGETS ${PROJECT_NAME} 21 | DESTINATION ${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rclc/parameter_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(parameter_server LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rclc_parameter REQUIRED) 10 | find_package(rmw_microxrcedds REQUIRED) 11 | 12 | add_executable(${PROJECT_NAME} main.c) 13 | 14 | ament_target_dependencies(${PROJECT_NAME} 15 | rcl 16 | rclc 17 | rclc_parameter 18 | rmw_microxrcedds 19 | std_msgs 20 | ) 21 | 22 | install(TARGETS ${PROJECT_NAME} 23 | DESTINATION ${PROJECT_NAME} 24 | ) 25 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /rclc/configuration_example/configured_publisher/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(configured_publisher LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(microxrcedds_client REQUIRED) 10 | find_package(rmw_microxrcedds REQUIRED) 11 | 12 | add_executable(${PROJECT_NAME} main.c) 13 | 14 | target_link_libraries(${PROJECT_NAME} 15 | microxrcedds_client 16 | ) 17 | 18 | ament_target_dependencies(${PROJECT_NAME} 19 | rcl 20 | rclc 21 | std_msgs 22 | microxrcedds_client 23 | rmw_microxrcedds 24 | ) 25 | 26 | install(TARGETS ${PROJECT_NAME} 27 | DESTINATION ${PROJECT_NAME} 28 | ) 29 | -------------------------------------------------------------------------------- /rclc/configuration_example/configured_subscriber/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(configured_subscriber LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | find_package(microxrcedds_client REQUIRED) 11 | 12 | add_executable(${PROJECT_NAME} main.c) 13 | 14 | target_link_libraries(${PROJECT_NAME} 15 | microxrcedds_client 16 | ) 17 | 18 | ament_target_dependencies(${PROJECT_NAME} 19 | rcl 20 | rclc 21 | std_msgs 22 | microxrcedds_client 23 | rmw_microxrcedds 24 | ) 25 | 26 | install(TARGETS ${PROJECT_NAME} 27 | DESTINATION ${PROJECT_NAME} 28 | ) 29 | -------------------------------------------------------------------------------- /rclc/static_type_handling/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(static_type_handling LANGUAGES C) 4 | 5 | set (CMAKE_C_STANDARD 11) 6 | 7 | find_package(ament_cmake REQUIRED) 8 | find_package(rcl REQUIRED) 9 | find_package(rclc REQUIRED) 10 | find_package(visualization_msgs REQUIRED) 11 | find_package(rmw_microxrcedds REQUIRED) 12 | find_package(micro_ros_utilities REQUIRED) 13 | find_package(sensor_msgs REQUIRED) 14 | 15 | add_executable(${PROJECT_NAME} main.c) 16 | 17 | ament_target_dependencies(${PROJECT_NAME} 18 | rcl 19 | rclc 20 | sensor_msgs 21 | visualization_msgs 22 | rmw_microxrcedds 23 | micro_ros_utilities 24 | ) 25 | 26 | install(TARGETS ${PROJECT_NAME} 27 | DESTINATION ${PROJECT_NAME} 28 | ) 29 | -------------------------------------------------------------------------------- /rclc/multithread_publisher_subscriber/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(multithread_publisher_subscriber LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | find_package(micro_ros_utilities REQUIRED) 11 | find_package(Threads REQUIRED) 12 | 13 | add_executable(${PROJECT_NAME} main.c) 14 | target_link_libraries(${PROJECT_NAME} Threads::Threads) 15 | 16 | ament_target_dependencies(${PROJECT_NAME} 17 | rcl 18 | rclc 19 | std_msgs 20 | rmw_microxrcedds 21 | micro_ros_utilities 22 | ) 23 | 24 | install(TARGETS ${PROJECT_NAME} 25 | DESTINATION ${PROJECT_NAME} 26 | ) 27 | -------------------------------------------------------------------------------- /rclc/autodiscover_agent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(autodiscover_agent LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(microxrcedds_client REQUIRED) 10 | find_package(rmw_microxrcedds REQUIRED) 11 | find_package(microxrcedds_client REQUIRED) 12 | 13 | add_executable(${PROJECT_NAME} main.c) 14 | 15 | target_link_libraries(${PROJECT_NAME} 16 | microxrcedds_client 17 | ) 18 | 19 | ament_target_dependencies(${PROJECT_NAME} 20 | rcl 21 | rclc 22 | std_msgs 23 | microxrcedds_client 24 | rmw_microxrcedds 25 | microxrcedds_client 26 | ) 27 | 28 | install(TARGETS ${PROJECT_NAME} 29 | DESTINATION ${PROJECT_NAME} 30 | ) 31 | -------------------------------------------------------------------------------- /rclc/configuration_example/custom_transports/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(custom_transports LANGUAGES C) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rcl REQUIRED) 7 | find_package(rclc REQUIRED) 8 | find_package(std_msgs REQUIRED) 9 | find_package(rmw_microxrcedds REQUIRED) 10 | find_package(microxrcedds_client REQUIRED) 11 | 12 | add_executable(${PROJECT_NAME} main.c) 13 | 14 | target_link_libraries(${PROJECT_NAME} 15 | microxrcedds_client 16 | ) 17 | 18 | ament_target_dependencies(${PROJECT_NAME} 19 | rcl 20 | rclc 21 | std_msgs 22 | rmw_microxrcedds 23 | microxrcedds_client 24 | ) 25 | 26 | set_target_properties(${PROJECT_NAME} PROPERTIES 27 | CXX_STANDARD 28 | 11 29 | CXX_STANDARD_REQUIRED 30 | YES 31 | ) 32 | 33 | install(TARGETS ${PROJECT_NAME} 34 | DESTINATION ${PROJECT_NAME} 35 | ) 36 | -------------------------------------------------------------------------------- /messages/complex_msg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(complex_msgs) 4 | 5 | # Default to C++14 6 | if(NOT CMAKE_CXX_STANDARD) 7 | set(CMAKE_CXX_STANDARD 14) 8 | endif() 9 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 10 | # we dont use add_compile_options with pedantic in message packages 11 | # because the Python C extensions dont comply with it 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") 13 | endif() 14 | 15 | find_package(ament_cmake REQUIRED) 16 | find_package(builtin_interfaces REQUIRED) 17 | find_package(rosidl_default_generators REQUIRED) 18 | 19 | set(msg_files 20 | "msg/MultiStringTest.msg" 21 | "msg/NestedMsgTest.msg" 22 | ) 23 | rosidl_generate_interfaces(${PROJECT_NAME} 24 | ${msg_files} 25 | DEPENDENCIES builtin_interfaces 26 | ADD_LINTER_TESTS 27 | ) 28 | 29 | ament_export_dependencies(rosidl_default_runtime) 30 | 31 | ament_package() 32 | -------------------------------------------------------------------------------- /messages/complex_msg/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | complex_msgs 5 | 6.0.0 6 | Example of a complex msg. 7 | Javier Moreno 8 | Apache-2.0 9 | 10 | ament_cmake 11 | 12 | rosidl_default_generators 13 | 14 | builtin_interfaces 15 | 16 | builtin_interfaces 17 | rosidl_default_runtime 18 | 19 | ament_lint_common 20 | 21 | rosidl_interface_packages 22 | 23 | 24 | ament_cmake 25 | 26 | 27 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | workflow_dispatch: 8 | inputs: 9 | name: 10 | description: "Manual trigger" 11 | 12 | 13 | jobs: 14 | micro_ros_demos: 15 | runs-on: ubuntu-24.04 16 | container: microros/base:kilted 17 | defaults: 18 | run: 19 | shell: bash 20 | 21 | steps: 22 | - name: Download environment 23 | run: | 24 | cd /uros_ws 25 | apt update 26 | rosdep update 27 | source /opt/ros/kilted/setup.bash 28 | source install/local_setup.bash 29 | rosdep update 30 | ros2 run micro_ros_setup create_firmware_ws.sh host 31 | rm -rf src/uros/micro-ROS-demos 32 | - uses: actions/checkout@v3 33 | with: 34 | path: uros_ws/src/uros/micro-ROS-demos 35 | - name: Build 36 | run: | 37 | cd /uros_ws 38 | source /opt/ros/kilted/setup.bash 39 | source install/local_setup.bash 40 | ros2 run micro_ros_setup build_firmware.sh 41 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | 2 | # This is the official list of copyright holders and authors. 3 | # 4 | # Often employers or academic institutions have ownership over code that is 5 | # written in certain circumstances, so please do due diligence to ensure that 6 | # you have the right to submit the code. 7 | # 8 | # When adding J Random Contributor's name to this file, either J's name on its 9 | # own or J's name associated with J's organization's name should be added, 10 | # depending on whether J's employer (or academic institution) has ownership 11 | # over code that is written for this project. 12 | # 13 | # How to add names to this file: 14 | # Individual's name . 15 | # 16 | # If Individual's organization is copyright holder of her contributions add the 17 | # organization's name, optionally also the contributor's name: 18 | # 19 | # Organization's name 20 | # Individual's name 21 | # 22 | # Please keep the list sorted. 23 | 24 | eProsima 25 | Jose Antonio Moral 26 | Pablo Garrido 27 | 28 | Robert Bosch GmbH 29 | Ingo Lütkebohle 30 | Ralph Lange 31 | -------------------------------------------------------------------------------- /rclc/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | micro_ros_demos_rclc 5 | 6.0.0 6 | Examples using RCL+RCLC API 7 | Eugenio Collado 8 | Carlos Espinoza 9 | Apache-2.0 10 | Borja Outerelo 11 | 12 | ament_cmake 13 | 14 | rcl 15 | rclc 16 | rclc_parameter 17 | rcl_interfaces 18 | std_msgs 19 | example_interfaces 20 | complex_msgs 21 | sensor_msgs 22 | visualization_msgs 23 | builtin_interfaces 24 | microxrcedds_client 25 | micro_ros_utilities 26 | 27 | 28 | geometry_msgs 29 | rmw_microxrcedds 30 | 31 | 32 | ament_cmake 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /rclc/timer/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #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); return 1;}} 10 | #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);}} 11 | 12 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 13 | { 14 | if (timer != NULL) { 15 | printf("Timer callback executed. Last time %ld\n", last_call_time); 16 | } 17 | } 18 | 19 | int main() 20 | { 21 | rcl_allocator_t allocator = rcl_get_default_allocator(); 22 | rclc_support_t support; 23 | 24 | // create init_options 25 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 26 | 27 | // create node 28 | rcl_node_t node; 29 | RCCHECK(rclc_node_init_default(&node, "timer_node", "", &support)); 30 | 31 | // create timer, 32 | rcl_timer_t timer; 33 | const unsigned int timer_timeout = 1000; 34 | RCCHECK(rclc_timer_init_default( 35 | &timer, 36 | &support, 37 | RCL_MS_TO_NS(timer_timeout), 38 | timer_callback)); 39 | 40 | // create executor 41 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 42 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 43 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 44 | 45 | rclc_executor_spin(&executor); 46 | 47 | RCCHECK(rcl_node_fini(&node)); 48 | } -------------------------------------------------------------------------------- /rclc/int32_subscriber/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #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); return 1;}} 11 | #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);}} 12 | 13 | rcl_subscription_t subscriber; 14 | std_msgs__msg__Int32 msg; 15 | 16 | void subscription_callback(const void * msgin) 17 | { 18 | const std_msgs__msg__Int32 * msg = (const std_msgs__msg__Int32 *)msgin; 19 | printf("Received: %d\n", msg->data); 20 | } 21 | 22 | int main() 23 | { 24 | rcl_allocator_t allocator = rcl_get_default_allocator(); 25 | rclc_support_t support; 26 | 27 | // create init_options 28 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 29 | 30 | // create node 31 | rcl_node_t node; 32 | RCCHECK(rclc_node_init_default(&node, "int32_subscriber_rclc", "", &support)); 33 | 34 | // create subscriber 35 | RCCHECK(rclc_subscription_init_default( 36 | &subscriber, 37 | &node, 38 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 39 | "std_msgs_msg_Int32")); 40 | 41 | // create executor 42 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 43 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 44 | RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &msg, &subscription_callback, ON_NEW_DATA)); 45 | 46 | rclc_executor_spin(&executor); 47 | 48 | RCCHECK(rcl_subscription_fini(&subscriber, &node)); 49 | RCCHECK(rcl_node_fini(&node)); 50 | } 51 | -------------------------------------------------------------------------------- /rclc/int32_publisher/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #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); return 1;}} 12 | #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);}} 13 | 14 | rcl_publisher_t publisher; 15 | std_msgs__msg__Int32 msg; 16 | 17 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 18 | { 19 | (void) last_call_time; 20 | if (timer != NULL) { 21 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 22 | printf("Sent: %d\n", msg.data); 23 | msg.data++; 24 | } 25 | } 26 | 27 | int main() 28 | { 29 | rcl_allocator_t allocator = rcl_get_default_allocator(); 30 | rclc_support_t support; 31 | 32 | // create init_options 33 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 34 | 35 | // create node 36 | rcl_node_t node; 37 | RCCHECK(rclc_node_init_default(&node, "int32_publisher_rclc", "", &support)); 38 | 39 | // create publisher 40 | RCCHECK(rclc_publisher_init_default( 41 | &publisher, 42 | &node, 43 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 44 | "std_msgs_msg_Int32")); 45 | 46 | // create timer, 47 | rcl_timer_t timer; 48 | const unsigned int timer_timeout = 1000; 49 | RCCHECK(rclc_timer_init_default( 50 | &timer, 51 | &support, 52 | RCL_MS_TO_NS(timer_timeout), 53 | timer_callback)); 54 | 55 | // create executor 56 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 57 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 58 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 59 | 60 | msg.data = 0; 61 | 62 | rclc_executor_spin(&executor); 63 | 64 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 65 | RCCHECK(rcl_node_fini(&node)); 66 | } 67 | -------------------------------------------------------------------------------- /rclc/string_subscriber/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #define ARRAY_LEN 200 11 | 12 | #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); return 1;}} 13 | #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);}} 14 | 15 | rcl_subscription_t subscriber; 16 | std_msgs__msg__String msg; 17 | char test_array[ARRAY_LEN]; 18 | 19 | void subscription_callback(const void * msgin) 20 | { 21 | const std_msgs__msg__String * msg = (const std_msgs__msg__String *)msgin; 22 | printf("I have heard: \"%s\"\n", msg->data.data); 23 | } 24 | 25 | int main(int argc, const char * const * argv) 26 | { 27 | memset(test_array,'z',ARRAY_LEN); 28 | 29 | rcl_allocator_t allocator = rcl_get_default_allocator(); 30 | rclc_support_t support; 31 | 32 | // create init_options 33 | RCCHECK(rclc_support_init(&support, argc, argv, &allocator)); 34 | 35 | // create node 36 | rcl_node_t node; 37 | RCCHECK(rclc_node_init_default(&node, "string_node", "", &support)); 38 | 39 | // create subscriber 40 | RCCHECK(rclc_subscription_init_default( 41 | &subscriber, 42 | &node, 43 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), 44 | "/string_publisher")); 45 | 46 | // create executor 47 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 48 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 49 | RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &msg, &subscription_callback, ON_NEW_DATA)); 50 | 51 | msg.data.data = (char * ) malloc(ARRAY_LEN * sizeof(char)); 52 | msg.data.size = 0; 53 | msg.data.capacity = ARRAY_LEN; 54 | 55 | rclc_executor_spin(&executor); 56 | 57 | RCCHECK(rcl_subscription_fini(&subscriber, &node)); 58 | RCCHECK(rcl_node_fini(&node)); 59 | } -------------------------------------------------------------------------------- /rclc/addtwoints_server/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "example_interfaces/srv/add_two_ints.h" 7 | 8 | #include 9 | #include 10 | 11 | #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);}} 12 | #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);}} 13 | 14 | void service_callback(const void * req, void * res){ 15 | example_interfaces__srv__AddTwoInts_Request * req_in = (example_interfaces__srv__AddTwoInts_Request *) req; 16 | example_interfaces__srv__AddTwoInts_Response * res_in = (example_interfaces__srv__AddTwoInts_Response *) res; 17 | 18 | printf("Service request value: %d + %d.\n", (int) req_in->a, (int) req_in->b); 19 | 20 | res_in->sum = req_in->a + req_in->b; 21 | } 22 | 23 | void main(void) 24 | { 25 | rcl_allocator_t allocator = rcl_get_default_allocator(); 26 | 27 | // create init_options 28 | rclc_support_t support; 29 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 30 | 31 | // create node 32 | rcl_node_t node; 33 | RCCHECK(rclc_node_init_default(&node, "add_twoints_server_rclc", "", &support)); 34 | 35 | // create service 36 | rcl_service_t service; 37 | RCCHECK(rclc_service_init_default(&service, &node, ROSIDL_GET_SRV_TYPE_SUPPORT(example_interfaces, srv, AddTwoInts), "/addtwoints")); 38 | 39 | // create executor 40 | rclc_executor_t executor; 41 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 42 | 43 | example_interfaces__srv__AddTwoInts_Response res; 44 | example_interfaces__srv__AddTwoInts_Request req; 45 | RCCHECK(rclc_executor_add_service(&executor, &service, &req, &res, service_callback)); 46 | 47 | rclc_executor_spin(&executor); 48 | 49 | RCCHECK(rcl_service_fini(&service, &node)); 50 | RCCHECK(rcl_node_fini(&node)); 51 | } 52 | -------------------------------------------------------------------------------- /rclc/epoch_synchronization/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #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); return 1;}} 13 | #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);}} 14 | 15 | rcl_publisher_t publisher; 16 | std_msgs__msg__Int32 msg; 17 | 18 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 19 | { 20 | (void) last_call_time; 21 | (void) timer; 22 | 23 | RCSOFTCHECK(rmw_uros_sync_session(1000)); 24 | int64_t time = rmw_uros_epoch_millis(); 25 | msg.data = time; 26 | 27 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 28 | printf("UNIX time: %ld ms\n", time); 29 | } 30 | 31 | int main() 32 | { 33 | rcl_allocator_t allocator = rcl_get_default_allocator(); 34 | rclc_support_t support; 35 | 36 | // create init_options 37 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 38 | 39 | // create node 40 | rcl_node_t node; 41 | RCCHECK(rclc_node_init_default(&node, "micro_ros_node", "", &support)); 42 | 43 | // create publisher 44 | RCCHECK(rclc_publisher_init_default( 45 | &publisher, 46 | &node, 47 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 48 | "micro_ros_pub")); 49 | 50 | // create timer, 51 | rcl_timer_t timer; 52 | const unsigned int timer_timeout = 1000; 53 | RCCHECK(rclc_timer_init_default( 54 | &timer, 55 | &support, 56 | RCL_MS_TO_NS(timer_timeout), 57 | timer_callback)); 58 | 59 | // create executor 60 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 61 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 62 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 63 | 64 | rclc_executor_spin(&executor); 65 | 66 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 67 | RCCHECK(rcl_node_fini(&node)); 68 | } 69 | -------------------------------------------------------------------------------- /rclc/fragmented_subscription/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #define ARRAY_LEN 4096 11 | 12 | #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); return 1;}} 13 | #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);}} 14 | 15 | rcl_subscription_t subscriber; 16 | std_msgs__msg__String msg; 17 | char test_array[ARRAY_LEN]; 18 | 19 | void subscription_callback(const void * msgin) 20 | { 21 | const std_msgs__msg__String * msg = (const std_msgs__msg__String *)msgin; 22 | bool pass_test = strncmp(test_array, msg->data.data, msg->data.size) == 0; 23 | printf("I received an %ld array. Test: [%s]\n", msg->data.size, (pass_test) ? "OK" : "FAIL"); 24 | } 25 | 26 | int main(int argc, const char * const * argv) 27 | { 28 | memset(test_array,'z',ARRAY_LEN); 29 | 30 | rcl_allocator_t allocator = rcl_get_default_allocator(); 31 | rclc_support_t support; 32 | 33 | // create init_options 34 | RCCHECK(rclc_support_init(&support, argc, argv, &allocator)); 35 | 36 | // create node 37 | rcl_node_t node; 38 | RCCHECK(rclc_node_init_default(&node, "char_long_sequence_subscriber_rcl", "", &support)); 39 | 40 | // create subscriber 41 | RCCHECK(rclc_subscription_init_default( 42 | &subscriber, 43 | &node, 44 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), 45 | "/char_long_sequence")); 46 | 47 | // create executor 48 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 49 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 50 | RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &msg, &subscription_callback, ON_NEW_DATA)); 51 | 52 | msg.data.data = (char * ) malloc(ARRAY_LEN * sizeof(char)); 53 | msg.data.size = 0; 54 | msg.data.capacity = ARRAY_LEN; 55 | 56 | rclc_executor_spin(&executor); 57 | 58 | RCCHECK(rcl_subscription_fini(&subscriber, &node)); 59 | RCCHECK(rcl_node_fini(&node)); 60 | } -------------------------------------------------------------------------------- /rclc/addtwoints_client/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "example_interfaces/srv/add_two_ints.h" 7 | 8 | #include 9 | #include 10 | 11 | #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); return 1;}} 12 | #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);}} 13 | 14 | example_interfaces__srv__AddTwoInts_Request req; 15 | example_interfaces__srv__AddTwoInts_Response res; 16 | 17 | void client_callback(const void * msg){ 18 | example_interfaces__srv__AddTwoInts_Response * msgin = (example_interfaces__srv__AddTwoInts_Response * ) msg; 19 | printf("Received service response %ld + %ld = %ld\n", req.a, req.b, msgin->sum); 20 | } 21 | 22 | int main(int argc, const char * const * argv) 23 | { 24 | RCLC_UNUSED(argc); 25 | RCLC_UNUSED(argv); 26 | rcl_allocator_t allocator = rcl_get_default_allocator(); 27 | rclc_support_t support; 28 | 29 | // create init_options 30 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 31 | 32 | // create node 33 | rcl_node_t node; 34 | RCCHECK(rclc_node_init_default(&node, "add_twoints_client_rclc", "", &support)); 35 | 36 | // create client 37 | rcl_client_t client; 38 | RCCHECK(rclc_client_init_default(&client, &node, ROSIDL_GET_SRV_TYPE_SUPPORT(example_interfaces, srv, AddTwoInts), "/addtwoints")); 39 | 40 | // create executor 41 | rclc_executor_t executor; 42 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 43 | RCCHECK(rclc_executor_add_client(&executor, &client, &res, client_callback)); 44 | 45 | int64_t seq; 46 | example_interfaces__srv__AddTwoInts_Request__init(&req); 47 | req.a = 24; 48 | req.b = 42; 49 | 50 | sleep(2); // Sleep a while to ensure DDS matching before sending request 51 | 52 | RCCHECK(rcl_send_request(&client, &req, &seq)) 53 | printf("Send service request %ld + %ld. Seq %ld\n",req.a, req.b, seq); 54 | 55 | rclc_executor_spin(&executor); 56 | 57 | RCCHECK(rcl_client_fini(&client, &node)); 58 | RCCHECK(rcl_node_fini(&node)); 59 | } 60 | -------------------------------------------------------------------------------- /rclc/fragmented_publication/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #define ARRAY_LEN 4096 12 | 13 | #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); return 1;}} 14 | #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);}} 15 | 16 | rcl_publisher_t publisher; 17 | std_msgs__msg__String msg; 18 | 19 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 20 | { 21 | (void) last_call_time; 22 | if (timer != NULL) { 23 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 24 | printf("I sent an %ld array\n", msg.data.size); 25 | } 26 | } 27 | 28 | int main(int argc, const char * const * argv) 29 | { 30 | rcl_allocator_t allocator = rcl_get_default_allocator(); 31 | rclc_support_t support; 32 | 33 | // create init_options 34 | RCCHECK(rclc_support_init(&support, argc, argv, &allocator)); 35 | 36 | // create node 37 | rcl_node_t node; 38 | RCCHECK(rclc_node_init_default(&node, "char_long_sequence_publisher_rcl", "", &support)); 39 | 40 | // create publisher 41 | RCCHECK(rclc_publisher_init_default( 42 | &publisher, 43 | &node, 44 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), 45 | "/char_long_sequence")); 46 | 47 | // create timer, 48 | rcl_timer_t timer; 49 | const unsigned int timer_timeout = 1000; 50 | RCCHECK(rclc_timer_init_default( 51 | &timer, 52 | &support, 53 | RCL_MS_TO_NS(timer_timeout), 54 | timer_callback)); 55 | 56 | // create executor 57 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 58 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 59 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 60 | 61 | // Fill the array with a known sequence 62 | msg.data.data = (char * ) malloc(ARRAY_LEN * sizeof(char)); 63 | msg.data.size = 0; 64 | msg.data.capacity = ARRAY_LEN; 65 | 66 | memset(msg.data.data,'z',3500); 67 | msg.data.data[3500] = '\0'; 68 | msg.data.size = 3501; 69 | 70 | rclc_executor_spin(&executor); 71 | 72 | RCCHECK(rcl_publisher_fini(&publisher, &node)) 73 | RCCHECK(rcl_node_fini(&node)) 74 | } 75 | -------------------------------------------------------------------------------- /rclc/string_publisher/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #define ARRAY_LEN 200 12 | 13 | #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); return 1;}} 14 | #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);}} 15 | 16 | rcl_publisher_t publisher; 17 | std_msgs__msg__String msg; 18 | 19 | int counter = 0; 20 | 21 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 22 | { 23 | (void) last_call_time; 24 | if (timer != NULL) { 25 | sprintf(msg.data.data, "Hello from micro-ROS #%d", counter++); 26 | msg.data.size = strlen(msg.data.data); 27 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 28 | printf("I have publish: \"%s\"\n", msg.data.data); 29 | } 30 | } 31 | 32 | int main(int argc, const char * const * argv) 33 | { 34 | rcl_allocator_t allocator = rcl_get_default_allocator(); 35 | rclc_support_t support; 36 | 37 | // create init_options 38 | RCCHECK(rclc_support_init(&support, argc, argv, &allocator)); 39 | 40 | // create node 41 | rcl_node_t node; 42 | RCCHECK(rclc_node_init_default(&node, "string_node", "", &support)); 43 | 44 | // create publisher 45 | RCCHECK(rclc_publisher_init_default( 46 | &publisher, 47 | &node, 48 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), 49 | "/string_publisher")); 50 | 51 | // create timer, 52 | rcl_timer_t timer; 53 | const unsigned int timer_timeout = 1000; 54 | RCCHECK(rclc_timer_init_default( 55 | &timer, 56 | &support, 57 | RCL_MS_TO_NS(timer_timeout), 58 | timer_callback)); 59 | 60 | // create executor 61 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 62 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 63 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 64 | 65 | // Fill the array with a known sequence 66 | msg.data.data = (char * ) malloc(ARRAY_LEN * sizeof(char)); 67 | msg.data.size = 0; 68 | msg.data.capacity = ARRAY_LEN; 69 | 70 | rclc_executor_spin(&executor); 71 | 72 | RCCHECK(rcl_publisher_fini(&publisher, &node)) 73 | RCCHECK(rcl_node_fini(&node)) 74 | } 75 | -------------------------------------------------------------------------------- /rclc/graph_introspection/publisher_count/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #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); return 1;}} 13 | #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);}} 14 | 15 | rcl_subscription_t subscription; 16 | rcl_node_t node; 17 | 18 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 19 | { 20 | (void) last_call_time; 21 | printf("Publisher count for subscription '/parameter_events':\n"); 22 | size_t publisher_count = 0; 23 | RCSOFTCHECK(rcl_subscription_get_publisher_count(&subscription, &publisher_count)); 24 | printf(" * Using 'rcl_subscription_get_publisher_count': %lu\n", publisher_count); 25 | RCSOFTCHECK(rcl_count_publishers(&node, "/parameter_events", &publisher_count)); 26 | printf(" * Using 'rcl_count_publishers': %lu\n", publisher_count); 27 | } 28 | 29 | int main(int argc, const char * const * argv) 30 | { 31 | printf("***Hint: test this example using 'ros2 run demo_nodes_cpp talker/listener' in another terminal***\n"); 32 | rcl_allocator_t allocator = rcl_get_default_allocator(); 33 | rclc_support_t support; 34 | 35 | // create init options 36 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 37 | 38 | // create_node 39 | RCCHECK(rclc_node_init_default(&node, "publisher_count_node", "", &support)); 40 | 41 | // create subscription 42 | RCCHECK(rclc_subscription_init_best_effort( 43 | &subscription, 44 | &node, 45 | ROSIDL_GET_MSG_TYPE_SUPPORT(rcl_interfaces, msg, ParameterEvent), 46 | "parameter_events")); 47 | 48 | // create timer 49 | rcl_timer_t timer; 50 | const unsigned int timer_timeout = 1000; 51 | RCCHECK(rclc_timer_init_default( 52 | &timer, 53 | &support, 54 | RCL_MS_TO_NS(timer_timeout), 55 | timer_callback)); 56 | 57 | // create executor 58 | rclc_executor_t executor; 59 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 60 | 61 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 62 | 63 | rclc_executor_spin(&executor); 64 | 65 | RCCHECK(rcl_subscription_fini(&subscription, &node)); 66 | RCCHECK(rcl_node_fini(&node)); 67 | } 68 | -------------------------------------------------------------------------------- /rclc/graph_introspection/subscription_count/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #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); return 1;}} 13 | #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);}} 14 | 15 | rcl_publisher_t publisher; 16 | rcl_node_t node; 17 | 18 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 19 | { 20 | (void) last_call_time; 21 | printf("Subscriptions count for publisher '/parameter_events':\n"); 22 | size_t subscription_count = 0; 23 | RCSOFTCHECK(rcl_publisher_get_subscription_count(&publisher, &subscription_count)); 24 | printf(" * Using 'rcl_publisher_get_subscription_count': %lu\n", subscription_count); 25 | RCSOFTCHECK(rcl_count_subscribers(&node, "/parameter_events", &subscription_count)); 26 | printf(" * Using 'rcl_count_subscribers': %lu\n", subscription_count); 27 | } 28 | 29 | int main(int argc, const char * const * argv) 30 | { 31 | printf("***Hint: test this example using 'ros2 run demo_nodes_cpp talker/listener' in another terminal***\n"); 32 | rcl_allocator_t allocator = rcl_get_default_allocator(); 33 | rclc_support_t support; 34 | 35 | // create init options 36 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 37 | 38 | // create_node 39 | RCCHECK(rclc_node_init_default(&node, "subscription_count_node", "", &support)); 40 | 41 | // create publisher 42 | RCCHECK(rclc_publisher_init_best_effort( 43 | &publisher, 44 | &node, 45 | ROSIDL_GET_MSG_TYPE_SUPPORT(rcl_interfaces, msg, ParameterEvent), 46 | "parameter_events")); 47 | 48 | // create timer 49 | rcl_timer_t timer; 50 | const unsigned int timer_timeout = 1000; 51 | RCCHECK(rclc_timer_init_default( 52 | &timer, 53 | &support, 54 | RCL_MS_TO_NS(timer_timeout), 55 | timer_callback)); 56 | 57 | // create executor 58 | rclc_executor_t executor; 59 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 60 | 61 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 62 | 63 | rclc_executor_spin(&executor); 64 | 65 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 66 | RCCHECK(rcl_node_fini(&node)); 67 | } 68 | -------------------------------------------------------------------------------- /rclc/autodiscover_agent/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #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); return 1;}} 14 | #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);}} 15 | 16 | rcl_publisher_t publisher; 17 | std_msgs__msg__Int32 msg; 18 | 19 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 20 | { 21 | (void) last_call_time; 22 | if (timer != NULL) { 23 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 24 | printf("Sent: %d\n", msg.data); 25 | msg.data++; 26 | } 27 | } 28 | 29 | int main() 30 | { 31 | rcl_allocator_t allocator = rcl_get_default_allocator(); 32 | rclc_support_t support; 33 | 34 | rcl_init_options_t init_options = rcl_get_zero_initialized_init_options(); 35 | RCCHECK(rcl_init_options_init(&init_options, allocator)); 36 | rmw_init_options_t* rmw_options = rcl_init_options_get_rmw_init_options(&init_options); 37 | 38 | // Auto discover micro-ROS agent 39 | if(rmw_uros_discover_agent(rmw_options) != RCL_RET_OK){ 40 | printf("micro-ROS agent not found\n"); 41 | return 1; 42 | } 43 | 44 | // create init_options 45 | RCCHECK(rclc_support_init_with_options(&support, 0, NULL, &init_options, &allocator)); 46 | 47 | // create node 48 | rcl_node_t node; 49 | RCCHECK(rclc_node_init_default(&node, "int32_publisher_rclc", "", &support)); 50 | 51 | // create publisher 52 | RCCHECK(rclc_publisher_init_default( 53 | &publisher, 54 | &node, 55 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 56 | "std_msgs_msg_Int32")); 57 | 58 | // create timer, 59 | rcl_timer_t timer; 60 | const unsigned int timer_timeout = 1000; 61 | RCCHECK(rclc_timer_init_default( 62 | &timer, 63 | &support, 64 | RCL_MS_TO_NS(timer_timeout), 65 | timer_callback)); 66 | 67 | // create executor 68 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 69 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 70 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 71 | 72 | msg.data = 0; 73 | 74 | rclc_executor_spin(&executor); 75 | 76 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 77 | RCCHECK(rcl_node_fini(&node)); 78 | } 79 | -------------------------------------------------------------------------------- /rclc/int32_publisher_subscriber/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #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); return 1;}} 11 | #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);}} 12 | 13 | rcl_publisher_t publisher; 14 | rcl_subscription_t subscriber; 15 | std_msgs__msg__Int32 send_msg; 16 | std_msgs__msg__Int32 recv_msg; 17 | 18 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 19 | { 20 | (void) last_call_time; 21 | if (timer != NULL) { 22 | RCSOFTCHECK(rcl_publish(&publisher, &send_msg, NULL)); 23 | printf("Sent: %d\n", send_msg.data); 24 | send_msg.data++; 25 | } 26 | } 27 | 28 | void subscription_callback(const void * msgin) 29 | { 30 | const std_msgs__msg__Int32 * msg = (const std_msgs__msg__Int32 *)msgin; 31 | printf("Received: %d\n", msg->data); 32 | } 33 | 34 | int main(int argc, const char * const * argv) 35 | { 36 | rcl_allocator_t allocator = rcl_get_default_allocator(); 37 | rclc_support_t support; 38 | 39 | // create init_options 40 | RCCHECK(rclc_support_init(&support, argc, argv, &allocator)); 41 | 42 | // create node 43 | rcl_node_t node; 44 | RCCHECK(rclc_node_init_default(&node, "int32_publisher_subscriber_rclc", "", &support)); 45 | 46 | // create publisher 47 | RCCHECK(rclc_publisher_init_default( 48 | &publisher, 49 | &node, 50 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 51 | "int32_publisher")); 52 | 53 | // create subscriber 54 | RCCHECK(rclc_subscription_init_default( 55 | &subscriber, 56 | &node, 57 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 58 | "int32_subscriber")); 59 | 60 | // create timer, 61 | rcl_timer_t timer; 62 | const unsigned int timer_timeout = 1000; 63 | RCCHECK(rclc_timer_init_default( 64 | &timer, 65 | &support, 66 | RCL_MS_TO_NS(timer_timeout), 67 | timer_callback)); 68 | 69 | // create executor 70 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 71 | RCCHECK(rclc_executor_init(&executor, &support.context, 2, &allocator)); 72 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 73 | RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &recv_msg, &subscription_callback, ON_NEW_DATA)); 74 | 75 | send_msg.data = 0; 76 | 77 | rclc_executor_spin(&executor); 78 | 79 | RCCHECK(rcl_subscription_fini(&subscriber, &node)); 80 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 81 | RCCHECK(rcl_node_fini(&node)); 82 | } 83 | -------------------------------------------------------------------------------- /rclc/configuration_example/configured_subscriber/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | #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); return 1;}} 13 | #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);}} 14 | 15 | rcl_subscription_t subscriber; 16 | std_msgs__msg__Int32 msg; 17 | 18 | void subscription_callback(const void * msgin) 19 | { 20 | const std_msgs__msg__Int32 * msg = (const std_msgs__msg__Int32 *)msgin; 21 | printf("Received: %d\n", msg->data); 22 | } 23 | 24 | int main(int argc, const char * const * argv) 25 | { 26 | if (argc < 3 || argc > 4) 27 | { 28 | printf("Usage: configured_subscriber \n"); 29 | return 1; 30 | } 31 | 32 | rcl_allocator_t allocator = rcl_get_default_allocator(); 33 | rclc_support_t support; 34 | rcl_init_options_t init_options = rcl_get_zero_initialized_init_options(); 35 | 36 | printf("Connecting to agent %s:%d\n",argv[1],atoi(argv[2])); 37 | RCCHECK(rcl_init_options_init(&init_options, allocator)); 38 | rmw_init_options_t* rmw_options = rcl_init_options_get_rmw_init_options(&init_options); 39 | RCCHECK(rmw_uros_options_set_udp_address(argv[1], argv[2], rmw_options)) 40 | RCCHECK(rmw_uros_options_set_client_key(0xCAFEBABE, rmw_options)) 41 | 42 | size_t domain_id = (size_t)(argc == 4 ? atoi(argv[3]) : 0); 43 | const char * node_name = "int32_configured_subscriber_rclc"; 44 | 45 | RCCHECK(rcl_init_options_set_domain_id(&init_options, domain_id)); 46 | printf("Initializing RCL '%s' with ROS Domain ID %ld...\n", node_name, domain_id); 47 | 48 | // create init_options 49 | RCCHECK(rclc_support_init_with_options(&support, 0, NULL, &init_options, &allocator)); 50 | 51 | // create node 52 | rcl_node_t node; 53 | RCCHECK(rclc_node_init_default(&node, node_name, "", &support)); 54 | 55 | // create subscriber 56 | RCCHECK(rclc_subscription_init_default( 57 | &subscriber, 58 | &node, 59 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 60 | "std_msgs_msg_Int32")); 61 | 62 | // create executor 63 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 64 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 65 | RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &msg, &subscription_callback, ON_NEW_DATA)); 66 | 67 | rclc_executor_spin(&executor); 68 | 69 | RCCHECK(rcl_subscription_fini(&subscriber, &node)); 70 | RCCHECK(rcl_node_fini(&node)); 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /rclc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(micro_ros_demos_rclc) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | 7 | include(ExternalProject) 8 | include(CMakeParseArguments) 9 | 10 | if(ANDROID) 11 | set(CROSS_CMAKE_ARGS 12 | -DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE} 13 | -DCMAKE_SYSTEM_VERSION:STRING=${CMAKE_SYSTEM_VERSION} 14 | -DCMAKE_ANDROID_ARCH_ABI:STRING=${CMAKE_ANDROID_ARCH_ABI} 15 | -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE:STRING=BOTH 16 | ) 17 | endif() 18 | 19 | function(export_executable) 20 | set(subtree "") 21 | foreach(arg IN LISTS ARGN) 22 | set(subtree ${subtree}/${arg}) 23 | endforeach() 24 | get_filename_component(leaf ${subtree} NAME) 25 | ExternalProject_Add(${leaf} 26 | PREFIX 27 | ${PROJECT_BINARY_DIR}${subtree} 28 | SOURCE_DIR 29 | ${PROJECT_SOURCE_DIR}${subtree} 30 | INSTALL_DIR 31 | ${PROJECT_BINARY_DIR}/temp_install 32 | BUILD_ALWAYS 1 33 | CMAKE_CACHE_ARGS 34 | -DCMAKE_INSTALL_PREFIX:PATH= 35 | -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} 36 | -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} 37 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 38 | ${CROSS_CMAKE_ARGS} 39 | ) 40 | endfunction() 41 | 42 | export_executable(graph_introspection graph_visualizer) 43 | export_executable(graph_introspection subscription_count) 44 | export_executable(graph_introspection publisher_count) 45 | export_executable(int32_publisher) 46 | export_executable(int32_subscriber) 47 | export_executable(configuration_example configured_publisher) 48 | export_executable(configuration_example configured_subscriber) 49 | export_executable(addtwoints_server) 50 | export_executable(addtwoints_client) 51 | export_executable(fibonacci_action_server) 52 | export_executable(fibonacci_action_client) 53 | export_executable(int32_multinode) 54 | export_executable(int32_publisher_subscriber) 55 | export_executable(ping_pong) 56 | export_executable(ping_uros_agent) 57 | export_executable(fragmented_publication) 58 | export_executable(fragmented_subscription) 59 | export_executable(complex_msg_publisher) 60 | export_executable(complex_msg_subscriber) 61 | export_executable(timer) 62 | export_executable(string_publisher) 63 | export_executable(string_subscriber) 64 | export_executable(autodiscover_agent) 65 | export_executable(static_type_handling) 66 | export_executable(epoch_synchronization) 67 | export_executable(parameter_server) 68 | # export_executable(configuration_example custom_transports) 69 | export_executable(multithread_publisher_subscriber) 70 | 71 | if(EXISTS ${CMAKE_BINARY_DIR}/temp_install/) 72 | install( 73 | DIRECTORY 74 | ${CMAKE_BINARY_DIR}/temp_install/ 75 | DESTINATION 76 | lib/${PROJECT_NAME} 77 | USE_SOURCE_PERMISSIONS 78 | ) 79 | endif() 80 | 81 | ament_package() 82 | -------------------------------------------------------------------------------- /rclc/configuration_example/configured_publisher/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | #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); return 1;}} 13 | #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);}} 14 | 15 | rcl_publisher_t publisher; 16 | std_msgs__msg__Int32 msg; 17 | 18 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 19 | { 20 | (void) last_call_time; 21 | if (timer != NULL) { 22 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 23 | printf("Sent: %d\n", msg.data); 24 | msg.data++; 25 | } 26 | } 27 | 28 | int main(int argc, char * const argv[]) 29 | { 30 | if (argc < 3 || argc > 4) 31 | { 32 | printf("Usage: configured_publisher \n"); 33 | return 1; 34 | } 35 | 36 | rcl_allocator_t allocator = rcl_get_default_allocator(); 37 | rclc_support_t support; 38 | rcl_init_options_t init_options = rcl_get_zero_initialized_init_options(); 39 | 40 | printf("Connecting to agent %s:%d\n",argv[1],atoi(argv[2])); 41 | RCCHECK(rcl_init_options_init(&init_options, allocator)); 42 | rmw_init_options_t* rmw_options = rcl_init_options_get_rmw_init_options(&init_options); 43 | RCCHECK(rmw_uros_options_set_udp_address(argv[1], argv[2], rmw_options)) 44 | RCCHECK(rmw_uros_options_set_client_key(0xCAFEBABA, rmw_options)) 45 | 46 | size_t domain_id = (size_t)(argc == 4 ? atoi(argv[3]) : 0); 47 | const char * node_name = "int32_configured_publisher_rclc"; 48 | 49 | RCCHECK(rcl_init_options_set_domain_id(&init_options, domain_id)); 50 | printf("Initializing RCL '%s' with ROS Domain ID %ld...\n", node_name, domain_id); 51 | 52 | // create init_options 53 | RCCHECK(rclc_support_init_with_options(&support, 0, NULL, &init_options, &allocator)); 54 | 55 | // create node 56 | rcl_node_t node; 57 | RCCHECK(rclc_node_init_default(&node, node_name, "", &support)); 58 | 59 | // create publisher 60 | RCCHECK(rclc_publisher_init_default( 61 | &publisher, 62 | &node, 63 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 64 | "std_msgs_msg_Int32")); 65 | 66 | // create timer, 67 | rcl_timer_t timer; 68 | const unsigned int timer_timeout = 1000; 69 | RCCHECK(rclc_timer_init_default( 70 | &timer, 71 | &support, 72 | RCL_MS_TO_NS(timer_timeout), 73 | timer_callback)); 74 | 75 | // create executor 76 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 77 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 78 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 79 | 80 | msg.data = 0; 81 | 82 | rclc_executor_spin(&executor); 83 | 84 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 85 | RCCHECK(rcl_node_fini(&node)); 86 | 87 | return 0; 88 | } 89 | -------------------------------------------------------------------------------- /rclc/CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | Changelog for package micro_ros_demos_rclc 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | 6.0.0 (2024-05-31) 6 | ------------------ 7 | * addtwoints_server: correct node name (`#75 `_) (`#77 `_) 8 | (cherry picked from commit 70f3cbf27ce12dc9e57e5095b4233553e207d866) 9 | Co-authored-by: G.A. vd. Hoorn 10 | * Contributors: mergify[bot] 11 | 12 | 5.0.0 (2023-06-12) 13 | ------------------ 14 | 15 | 4.0.0 (2022-05-25) 16 | ------------------ 17 | * Update rclc parameter demo (`#62 `_) 18 | * Fix ping demo (`#58 `_) (`#60 `_) 19 | * Add pthreads to cmake (`#55 `_) 20 | * Add actions to examples (`#53 `_) 21 | * Add basic support for rclc demos to support Android (`#51 `_) (`#52 `_) 22 | * Add multithread example (`#47 `_) 23 | * Fix Package (`#46 `_) 24 | * Add epoch example and param example (`#45 `_) 25 | * Fix comment 26 | * Add example on static type handling (`#44 `_) 27 | * Initial Rolling support 28 | * Modify RMW API include (`#41 `_) 29 | * multichange tool (`#42 `_) 30 | * Ping demo: fix indent (`#40 `_) 31 | * Fix external transport example (`#39 `_) 32 | * Add client-to-agent ping example (`#38 `_) 33 | * Add external transport example (`#37 `_) 34 | * Fix service server demo (`#36 `_) 35 | * Rework demos and add CI (`#33 `_) 36 | * Add some examples for graph introspection (`#34 `_) 37 | * Rework demos (`#32 `_) 38 | * Fix indentation 39 | * Update Services examples (`#31 `_) 40 | * Add configured examples with domain ID (`#30 `_) 41 | * Add autodiscover micro-ROS agent example (`#29 `_) 42 | * fix spin time (`#28 `_) 43 | * Fix warning 44 | * Fix warnings 45 | * Foxy migration (`#25 `_) 46 | * Dashing migration (`#11 `_) 47 | -------------------------------------------------------------------------------- /rclc/complex_msg_subscriber/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | 11 | #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); return 1;}} 12 | #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);}} 13 | 14 | void subscription_callback(const void * msgin) 15 | { 16 | const complex_msgs__msg__NestedMsgTest * msg = (const complex_msgs__msg__NestedMsgTest *)msgin; 17 | printf("Complex message received:\n"); 18 | printf("\tBool: %u\n", msg->data1); 19 | printf("\tuint8_t: %u\n", msg->data2); 20 | printf("\tsigned char: %u\n", msg->data3); 21 | printf("\tfloat: %f\n", msg->data4); 22 | printf("\tdouble: %lf\n", msg->data5); 23 | printf("\tint8_t: %i\n", msg->data6); 24 | printf("\tuint8_t: %u\n", msg->data7); 25 | printf("\tint16_t: %i\n", msg->data8); 26 | printf("\tuint16_t: %u\n", msg->data9); 27 | printf("\tint32_t: %i\n", msg->data10); 28 | printf("\tuint32_t: %u\n", msg->data11); 29 | printf("\tint64_t: %li\n", msg->data12); 30 | printf("\tuint64_t: %lu\n", msg->data13); 31 | printf("\tstring 1: %s\n", msg->data14.data1.data); 32 | printf("\tstring 2: %s\n", msg->data14.data2.data); 33 | printf("\tstring 3: %s\n", msg->data14.data3.data); 34 | printf("\tstring 4: %s\n", msg->data14.data4.data); 35 | printf("\n\n"); 36 | } 37 | 38 | int main(void) 39 | { 40 | rcl_allocator_t allocator = rcl_get_default_allocator(); 41 | rclc_support_t support; 42 | 43 | // create init_options 44 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 45 | 46 | // create node 47 | rcl_node_t node; 48 | RCCHECK(rclc_node_init_default(&node, "complex_message_node", "", &support)); 49 | 50 | // create subscriber 51 | rcl_subscription_t subscriber = rcl_get_zero_initialized_subscription(); 52 | complex_msgs__msg__NestedMsgTest msg; 53 | 54 | char buff1[30]; 55 | msg.data14.data1.data = buff1; 56 | msg.data14.data1.size = 0; 57 | msg.data14.data1.capacity = sizeof(buff1); 58 | 59 | char buff2[30]; 60 | msg.data14.data2.data = buff2; 61 | msg.data14.data2.size = 0; 62 | msg.data14.data2.capacity = sizeof(buff1); 63 | 64 | char buff3[30]; 65 | msg.data14.data3.data = buff3; 66 | msg.data14.data3.size = 0; 67 | msg.data14.data3.capacity = sizeof(buff1); 68 | 69 | char buff4[30]; 70 | msg.data14.data4.data = buff4; 71 | msg.data14.data4.size = 0; 72 | msg.data14.data4.capacity = sizeof(buff1); 73 | 74 | RCCHECK(rclc_subscription_init_default( 75 | &subscriber, 76 | &node, 77 | ROSIDL_GET_MSG_TYPE_SUPPORT(complex_msgs, msg, NestedMsgTest), 78 | "complex_message") 79 | ); 80 | 81 | // create executor 82 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 83 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 84 | 85 | unsigned int rcl_wait_timeout = 1000; // in ms 86 | RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &msg, &subscription_callback, ON_NEW_DATA)); 87 | 88 | rclc_executor_spin(&executor); 89 | 90 | RCCHECK(rcl_subscription_fini(&subscriber, &node)); 91 | RCCHECK(rcl_node_fini(&node)); 92 | } 93 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/c,qt,c++,ros,cmake,qtcreator 2 | # Edit at https://www.gitignore.io/?templates=c,qt,c++,ros,cmake,qtcreator 3 | 4 | ### C ### 5 | # Prerequisites 6 | *.d 7 | 8 | # Object files 9 | *.o 10 | *.ko 11 | *.obj 12 | *.elf 13 | 14 | # Linker output 15 | *.ilk 16 | *.map 17 | *.exp 18 | 19 | # Precompiled Headers 20 | *.gch 21 | *.pch 22 | 23 | # Libraries 24 | *.lib 25 | *.a 26 | *.la 27 | *.lo 28 | 29 | # Shared objects (inc. Windows DLLs) 30 | *.dll 31 | *.so 32 | *.so.* 33 | *.dylib 34 | 35 | # Executables 36 | *.exe 37 | *.out 38 | *.app 39 | *.i*86 40 | *.x86_64 41 | *.hex 42 | 43 | # Debug files 44 | *.dSYM/ 45 | *.su 46 | *.idb 47 | *.pdb 48 | 49 | # Kernel Module Compile Results 50 | *.mod* 51 | *.cmd 52 | .tmp_versions/ 53 | modules.order 54 | Module.symvers 55 | Mkfile.old 56 | dkms.conf 57 | 58 | ### C++ ### 59 | # Prerequisites 60 | 61 | # Compiled Object files 62 | *.slo 63 | 64 | # Precompiled Headers 65 | 66 | # Compiled Dynamic libraries 67 | 68 | # Fortran module files 69 | *.mod 70 | *.smod 71 | 72 | # Compiled Static libraries 73 | *.lai 74 | 75 | # Executables 76 | 77 | ### CMake ### 78 | CMakeLists.txt.user 79 | CMakeCache.txt 80 | CMakeFiles 81 | CMakeScripts 82 | Testing 83 | Makefile 84 | cmake_install.cmake 85 | install_manifest.txt 86 | compile_commands.json 87 | CTestTestfile.cmake 88 | _deps 89 | 90 | ### CMake Patch ### 91 | # External projects 92 | *-prefix/ 93 | 94 | ### Qt ### 95 | # C++ objects and libs 96 | 97 | # Qt-es 98 | object_script.*.Release 99 | object_script.*.Debug 100 | *_plugin_import.cpp 101 | /.qmake.cache 102 | /.qmake.stash 103 | *.pro.user 104 | *.pro.user.* 105 | *.qbs.user 106 | *.qbs.user.* 107 | *.moc 108 | moc_*.cpp 109 | moc_*.h 110 | qrc_*.cpp 111 | ui_*.h 112 | *.qmlc 113 | *.jsc 114 | Makefile* 115 | *build-* 116 | 117 | # Qt unit tests 118 | target_wrapper.* 119 | 120 | # QtCreator 121 | *.autosave 122 | 123 | # QtCreator Qml 124 | *.qmlproject.user 125 | *.qmlproject.user.* 126 | 127 | # QtCreator CMake 128 | CMakeLists.txt.user* 129 | 130 | # QtCreator 4.8< compilation database 131 | 132 | # QtCreator local machine specific files for imported projects 133 | *creator.user* 134 | 135 | ### QtCreator ### 136 | # gitignore for Qt Creator like IDE for pure C/C++ project without Qt 137 | # 138 | # Reference: http://doc.qt.io/qtcreator/creator-project-generic.html 139 | 140 | 141 | 142 | # Qt Creator autogenerated files 143 | 144 | 145 | # A listing of all the files included in the project 146 | *.files 147 | 148 | # Include directories 149 | *.includes 150 | 151 | # Project configuration settings like predefined Macros 152 | *.config 153 | 154 | # Qt Creator settings 155 | *.creator 156 | 157 | # User project settings 158 | *.creator.user* 159 | 160 | # Qt Creator backups 161 | 162 | ### ROS ### 163 | devel/ 164 | logs/ 165 | build/ 166 | bin/ 167 | lib/ 168 | msg_gen/ 169 | srv_gen/ 170 | msg/*Action.msg 171 | msg/*ActionFeedback.msg 172 | msg/*ActionGoal.msg 173 | msg/*ActionResult.msg 174 | msg/*Feedback.msg 175 | msg/*Goal.msg 176 | msg/*Result.msg 177 | msg/_*.py 178 | build_isolated/ 179 | devel_isolated/ 180 | 181 | # Generated by dynamic reconfigure 182 | *.cfgc 183 | /cfg/cpp/ 184 | /cfg/*.py 185 | 186 | # Ignore generated docs 187 | *.dox 188 | *.wikidoc 189 | 190 | # eclipse stuff 191 | .project 192 | .cproject 193 | 194 | # qcreator stuff 195 | 196 | srv/_*.py 197 | *.pcd 198 | *.pyc 199 | qtcreator-* 200 | *.user 201 | 202 | /planning/cfg 203 | /planning/docs 204 | /planning/src 205 | 206 | *~ 207 | 208 | # Emacs 209 | .#* 210 | 211 | # Catkin custom files 212 | CATKIN_IGNORE 213 | 214 | # Colcon custom files 215 | COLCON_IGNORE 216 | 217 | # End of https://www.gitignore.io/api/c,qt,c++,ros,cmake,qtcreator 218 | -------------------------------------------------------------------------------- /rclc/complex_msg_publisher/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #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); return 1;}} 12 | #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);}} 13 | 14 | 15 | int main() 16 | { 17 | rcl_allocator_t allocator = rcl_get_default_allocator(); 18 | rclc_support_t support; 19 | 20 | // create init_options 21 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 22 | 23 | // create node 24 | rcl_node_t node; 25 | RCCHECK(rclc_node_init_default(&node, "complex_message_node", "", &support)); 26 | 27 | // create publisher 28 | rcl_publisher_t publisher; 29 | RCCHECK(rclc_publisher_init_default( 30 | &publisher, 31 | &node, 32 | ROSIDL_GET_MSG_TYPE_SUPPORT(complex_msgs, msg, NestedMsgTest), 33 | "complex_message") 34 | ); 35 | 36 | complex_msgs__msg__NestedMsgTest msg; 37 | char buff1[30]; 38 | msg.data14.data1.data = buff1; 39 | msg.data14.data1.size = 0; 40 | msg.data14.data1.capacity = sizeof(buff1); 41 | 42 | char buff2[30]; 43 | msg.data14.data2.data = buff2; 44 | msg.data14.data2.size = 0; 45 | msg.data14.data2.capacity = sizeof(buff1); 46 | 47 | char buff3[30]; 48 | msg.data14.data3.data = buff3; 49 | msg.data14.data3.size = 0; 50 | msg.data14.data3.capacity = sizeof(buff1); 51 | 52 | char buff4[30]; 53 | msg.data14.data4.data = buff4; 54 | msg.data14.data4.size = 0; 55 | msg.data14.data4.capacity = sizeof(buff1); 56 | 57 | 58 | int num = 0; 59 | while (true) { 60 | msg.data1 = (bool) (num & 0x01); 61 | msg.data2 = (uint8_t) num; 62 | msg.data3 = (signed char) num; 63 | msg.data4 = (float) num; 64 | msg.data5 = (double) num; 65 | msg.data6 = (int8_t) num; 66 | msg.data7 = (uint8_t) num; 67 | msg.data8 = (int16_t) num; 68 | msg.data9 = (uint16_t) num; 69 | msg.data10 = (int32_t) num; 70 | msg.data11 = (uint32_t) num; 71 | msg.data12 = (int64_t) num; 72 | msg.data13 = (uint64_t) num; 73 | msg.data14.data1.size = snprintf(msg.data14.data1.data, msg.data14.data1.capacity, "Msg A - %i", num); 74 | msg.data14.data2.size = snprintf(msg.data14.data2.data, msg.data14.data2.capacity, "Msg B - %i", num); 75 | msg.data14.data3.size = snprintf(msg.data14.data3.data, msg.data14.data3.capacity, "Msg C - %i", num); 76 | msg.data14.data4.size = snprintf(msg.data14.data4.data, msg.data14.data4.capacity, "Msg D - %i", num); 77 | 78 | num++; 79 | 80 | rcl_ret_t ret = rcl_publish(&publisher, &msg, NULL); 81 | 82 | if (ret == RCL_RET_OK) { 83 | printf("Complex message sent:\n"); 84 | printf("\tBool: %u\n", msg.data1); 85 | printf("\tuint8_t: %u\n", msg.data2); 86 | printf("\tsigned char: %u\n", msg.data3); 87 | printf("\tfloat: %f\n", msg.data4); 88 | printf("\tdouble: %lf\n", msg.data5); 89 | printf("\tint8_t: %i\n", msg.data6); 90 | printf("\tuint8_t: %u\n", msg.data7); 91 | printf("\tint16_t: %i\n", msg.data8); 92 | printf("\tuint16_t: %u\n", msg.data9); 93 | printf("\tint32_t: %i\n", msg.data10); 94 | printf("\tuint32_t: %u\n", msg.data11); 95 | printf("\tint64_t: %li\n", msg.data12); 96 | printf("\tuint64_t: %lu\n", msg.data13); 97 | printf("\tstring 1: %s\n", msg.data14.data1.data); 98 | printf("\tstring 2: %s\n", msg.data14.data2.data); 99 | printf("\tstring 3: %s\n", msg.data14.data3.data); 100 | printf("\tstring 4: %s\n", msg.data14.data4.data); 101 | printf("\n\n"); 102 | } 103 | 104 | sleep(1); 105 | } 106 | 107 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 108 | RCCHECK(rcl_node_fini(&node)); 109 | } 110 | -------------------------------------------------------------------------------- /rclc/parameter_server/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #define RCCHECK(fn) {rcl_ret_t temp_rc = fn; if ((temp_rc != RCL_RET_OK)) {printf( \ 13 | "Failed status on line %d: %d. Aborting.\n", __LINE__, (int)temp_rc); return 1;}} 14 | #define RCSOFTCHECK(fn) {rcl_ret_t temp_rc = fn; if ((temp_rc != RCL_RET_OK)) {printf( \ 15 | "Failed status on line %d: %d. Continuing.\n", __LINE__, (int)temp_rc);}} 16 | 17 | rcl_publisher_t publisher; 18 | rclc_parameter_server_t param_server; 19 | rcl_timer_t timer; 20 | bool publish = true; 21 | std_msgs__msg__Int32 msg; 22 | 23 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 24 | { 25 | (void) last_call_time; 26 | (void) timer; 27 | 28 | if (publish) { 29 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 30 | printf("Sent: %d\n", msg.data); 31 | 32 | msg.data++; 33 | } 34 | } 35 | 36 | bool on_parameter_changed(const Parameter * old_param, const Parameter * new_param, void * context) 37 | { 38 | (void) context; 39 | 40 | if (old_param == NULL && new_param == NULL) { 41 | printf("Callback error, both parameters are NULL\n"); 42 | return false; 43 | } 44 | 45 | bool ret = true; 46 | if (new_param == NULL) { 47 | printf("Delete parameter %s rejected\n", old_param->name.data); 48 | ret = false; 49 | } else if (strcmp( 50 | new_param->name.data, 51 | "publish_toogle") == 0 && new_param->value.type == RCLC_PARAMETER_BOOL) 52 | { 53 | publish = new_param->value.bool_value; 54 | printf("Publish %s\n", (publish) ? "ON" : "OFF"); 55 | } else if (strcmp( 56 | new_param->name.data, 57 | "publish_rate_ms") == 0 && new_param->value.type == RCLC_PARAMETER_INT) 58 | { 59 | int64_t old; 60 | RCSOFTCHECK(rcl_timer_exchange_period(&timer, RCL_MS_TO_NS(new_param->value.integer_value), &old)); 61 | printf("Publish rate %ld ms\n", new_param->value.integer_value); 62 | } 63 | 64 | return ret; 65 | } 66 | 67 | int main() 68 | { 69 | rcl_allocator_t allocator = rcl_get_default_allocator(); 70 | rclc_support_t support; 71 | 72 | // create init_options 73 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 74 | 75 | // create node 76 | rcl_node_t node; 77 | RCCHECK(rclc_node_init_default(&node, "micro_ros_node", "", &support)); 78 | 79 | // create publisher 80 | RCCHECK( 81 | rclc_publisher_init_default( 82 | &publisher, 83 | &node, 84 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 85 | "micro_ros_pub")); 86 | 87 | // Create parameter service 88 | rclc_parameter_server_init_default(¶m_server, &node); 89 | 90 | // create timer, 91 | RCCHECK( 92 | rclc_timer_init_default( 93 | &timer, 94 | &support, 95 | RCL_MS_TO_NS(1000), 96 | timer_callback)); 97 | 98 | // create executor 99 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 100 | RCCHECK( 101 | rclc_executor_init( 102 | &executor, &support.context, 103 | RCLC_EXECUTOR_PARAMETER_SERVER_HANDLES + 1, &allocator)); 104 | RCCHECK(rclc_executor_add_parameter_server(&executor, ¶m_server, on_parameter_changed)); 105 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 106 | 107 | // Add parameters 108 | rclc_add_parameter(¶m_server, "publish_toogle", RCLC_PARAMETER_BOOL); 109 | rclc_add_parameter(¶m_server, "publish_rate_ms", RCLC_PARAMETER_INT); 110 | 111 | // Add parameters constraints 112 | rclc_add_parameter_description(¶m_server, "publish_toogle", "Publish ON/OFF parameter", ""); 113 | rclc_add_parameter_description( 114 | ¶m_server, "publish_rate_ms", "Publish rate parameter", 115 | "Unit: milliseconds"); 116 | 117 | // Set parameter initial values 118 | rclc_parameter_set_bool(¶m_server, "publish_toogle", true); 119 | rclc_parameter_set_int(¶m_server, "publish_rate_ms", 1000); 120 | 121 | rclc_executor_spin(&executor); 122 | 123 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 124 | RCCHECK(rcl_node_fini(&node)); 125 | } 126 | -------------------------------------------------------------------------------- /rclc/int32_multinode/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #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); return 1;}} 11 | #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);}} 12 | 13 | rcl_publisher_t publisher_1; 14 | rcl_subscription_t subscriber_1; 15 | std_msgs__msg__Int32 send_msg_1; 16 | std_msgs__msg__Int32 recv_msg_1; 17 | 18 | rcl_publisher_t publisher_2; 19 | rcl_subscription_t subscriber_2; 20 | std_msgs__msg__Int32 send_msg_2; 21 | std_msgs__msg__Int32 recv_msg_2; 22 | 23 | void timer_callback_1(rcl_timer_t * timer, int64_t last_call_time) 24 | { 25 | (void) last_call_time; 26 | if (timer != NULL) { 27 | RCSOFTCHECK(rcl_publish(&publisher_1, &send_msg_1, NULL)); 28 | printf("Node 1 -- Sent: %d\n", send_msg_1.data); 29 | send_msg_1.data++; 30 | } 31 | } 32 | 33 | void subscription_callback_1(const void * msgin) 34 | { 35 | const std_msgs__msg__Int32 * msg = (const std_msgs__msg__Int32 *)msgin; 36 | printf("Node 1 --Received: %d\n", msg->data); 37 | } 38 | 39 | void timer_callback_2(rcl_timer_t * timer, int64_t last_call_time) 40 | { 41 | (void) last_call_time; 42 | if (timer != NULL) { 43 | RCSOFTCHECK(rcl_publish(&publisher_2, &send_msg_2, NULL)); 44 | printf("Node 2 -- Sent: %d\n", send_msg_2.data); 45 | send_msg_2.data++; 46 | } 47 | } 48 | 49 | void subscription_callback_2(const void * msgin) 50 | { 51 | const std_msgs__msg__Int32 * msg = (const std_msgs__msg__Int32 *)msgin; 52 | printf("Node 2 --Received: %d\n", msg->data); 53 | } 54 | 55 | 56 | int main(int argc, const char * const * argv) 57 | { 58 | rcl_allocator_t allocator = rcl_get_default_allocator(); 59 | rclc_support_t support; 60 | 61 | // create init_options 62 | RCCHECK(rclc_support_init(&support, argc, argv, &allocator)); 63 | 64 | // ----- NODE 1 ----- 65 | // create node 66 | rcl_node_t node_1; 67 | RCCHECK(rclc_node_init_default(&node_1, "int32_node_1", "", &support)); 68 | 69 | // create publisher 70 | RCCHECK(rclc_publisher_init_default( 71 | &publisher_1, 72 | &node_1, 73 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 74 | "node_1_to_2")); 75 | 76 | // create subscriber 77 | RCCHECK(rclc_subscription_init_default( 78 | &subscriber_1, 79 | &node_1, 80 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 81 | "node_2_to_1")); 82 | 83 | // create timer, 84 | rcl_timer_t timer_1; 85 | RCCHECK(rclc_timer_init_default( 86 | &timer_1, 87 | &support, 88 | RCL_MS_TO_NS(1000), 89 | timer_callback_1)); 90 | 91 | // create executor 92 | rclc_executor_t executor_1 = rclc_executor_get_zero_initialized_executor(); 93 | RCCHECK(rclc_executor_init(&executor_1, &support.context, 2, &allocator)); 94 | RCCHECK(rclc_executor_add_timer(&executor_1, &timer_1)); 95 | RCCHECK(rclc_executor_add_subscription(&executor_1, &subscriber_1, &recv_msg_1, &subscription_callback_1, ON_NEW_DATA)); 96 | 97 | // ----- NODE 2 ----- 98 | // create node 99 | rcl_node_t node_2; 100 | RCCHECK(rclc_node_init_default(&node_2, "int32_node_2", "", &support)); 101 | 102 | // create publisher 103 | RCCHECK(rclc_publisher_init_default( 104 | &publisher_2, 105 | &node_2, 106 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 107 | "node_2_to_1")); 108 | 109 | // create subscriber 110 | RCCHECK(rclc_subscription_init_default( 111 | &subscriber_2, 112 | &node_2, 113 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 114 | "node_1_to_2")); 115 | 116 | // create timer, 117 | rcl_timer_t timer_2; 118 | RCCHECK(rclc_timer_init_default( 119 | &timer_2, 120 | &support, 121 | RCL_MS_TO_NS(1000), 122 | timer_callback_2)); 123 | 124 | // create executor 125 | rclc_executor_t executor_2 = rclc_executor_get_zero_initialized_executor(); 126 | RCCHECK(rclc_executor_init(&executor_2, &support.context, 2, &allocator)); 127 | RCCHECK(rclc_executor_add_timer(&executor_2, &timer_2)); 128 | RCCHECK(rclc_executor_add_subscription(&executor_2, &subscriber_2, &recv_msg_2, &subscription_callback_2, ON_NEW_DATA)); 129 | 130 | // ----- MAIN LOOP ----- 131 | send_msg_1.data = 0; 132 | send_msg_2.data = 100; 133 | 134 | while (1) 135 | { 136 | rclc_executor_spin_some(&executor_1, RCL_MS_TO_NS(100)); 137 | rclc_executor_spin_some(&executor_2, RCL_MS_TO_NS(100)); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /rclc/ping_uros_agent/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #define RCCHECK(fn) \ 16 | {\ 17 | rcl_ret_t temp_rc = fn;\ 18 | if (RCL_RET_OK != temp_rc) {\ 19 | printf("Failed status on line %d: %d. Aborting.\n", __LINE__, (int)temp_rc);\ 20 | return 1;\ 21 | }\ 22 | } 23 | 24 | #define RCSOFTCHECK(fn) \ 25 | {\ 26 | rcl_ret_t temp_rc = fn;\ 27 | if(RCL_RET_OK != temp_rc) {\ 28 | printf("Failed status on line %d: %d. Continuing.\n", __LINE__, (int)temp_rc);\ 29 | }\ 30 | } 31 | 32 | rcl_publisher_t publisher; 33 | std_msgs__msg__String msg; 34 | 35 | int usage() 36 | { 37 | printf("Usage: ping_uros_agent \nModes:\n"); 38 | printf("\t* 'basic': checks that the micro-ROS Agent is up or down, and exits\n"); 39 | printf("\t* 'interactive': starts a basic micro-ROS application "); 40 | printf("if the Agent is up, or waits for the user to start it in a loop\n"); 41 | return 1; 42 | } 43 | 44 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 45 | { 46 | (void) last_call_time; 47 | if (NULL != timer) { 48 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 49 | printf("Sent: '%s'\n", msg.data.data); 50 | 51 | /** 52 | * If agent suddently goes down, we will exit the application. 53 | * This proves that `rmw_uros_ping_agent` functionality can be used 54 | * also when a micro-ROS node is already up and running (and hence, the 55 | * transport has been initialized in the RMW context). 56 | */ 57 | printf("\nPinging agent again...\n"); 58 | if (RMW_RET_OK != rmw_uros_ping_agent(100, 1)) { 59 | printf("micro-ROS agent has stopped. Exiting...\n"); 60 | exit(1); 61 | } else { 62 | printf("Agent is still up!\n\n"); 63 | } 64 | } 65 | } 66 | 67 | int main(int argc, char ** argv) 68 | { 69 | /** 70 | * Parse arguments 71 | */ 72 | if (2 != argc) { 73 | return usage(); 74 | } 75 | 76 | const char * mode = argv[1]; 77 | 78 | // Init data 79 | msg.data.data = "This is a message sent after pinging micro-ROS Agent"; 80 | msg.data.size = strlen(msg.data.data); 81 | msg.data.capacity = msg.data.size + 1; 82 | 83 | /** 84 | * Basic mode 85 | */ 86 | if (0 == strcmp("basic", mode)) { 87 | /** 88 | * Ping should work even without a micro-ROS node active. 89 | */ 90 | rmw_ret_t ping_result = rmw_uros_ping_agent(1000, 5); 91 | 92 | if (RMW_RET_OK == ping_result) { 93 | printf("Success! micro-ROS Agent is up.\n"); 94 | return 0; 95 | } else { 96 | printf("Sorry, the micro-ROS Agent is not available.\n"); 97 | return 1; 98 | } 99 | } else if (0 == strcmp("interactive", mode)) { 100 | /** 101 | * Loop until micro-ROS Agent is up 102 | */ 103 | while (RMW_RET_OK != rmw_uros_ping_agent(1000, 1)) { 104 | printf("Please, start your micro-ROS Agent first\n"); 105 | } 106 | 107 | /** 108 | * Start the micro-ROS basic application 109 | */ 110 | rcl_allocator_t allocator = rcl_get_default_allocator(); 111 | rclc_support_t support; 112 | 113 | // Create init options 114 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 115 | 116 | // Create node 117 | rcl_node_t node; 118 | RCCHECK(rclc_node_init_default( 119 | &node, "ping_uros_agent_publisher", "", &support)); 120 | 121 | // Create publisher 122 | RCCHECK(rclc_publisher_init_default( 123 | &publisher, 124 | &node, 125 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, String), 126 | "ping_uros_agent_topic")); 127 | 128 | // Create timer 129 | rcl_timer_t timer; 130 | const unsigned int timer_timeout = 1000; 131 | RCCHECK(rclc_timer_init_default( 132 | &timer, 133 | &support, 134 | RCL_MS_TO_NS(timer_timeout), 135 | timer_callback)); 136 | 137 | // Create executor 138 | rclc_executor_t executor; 139 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 140 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 141 | 142 | // Spin executor 143 | rclc_executor_spin(&executor); 144 | 145 | (void)! rcl_publisher_fini(&publisher, &node); 146 | (void)! rcl_timer_fini(&timer); 147 | (void)! rclc_executor_fini(&executor); 148 | (void)! rcl_node_fini(&node); 149 | (void)! rclc_support_fini(&support); 150 | 151 | } else { 152 | return usage(); 153 | } 154 | 155 | return 0; 156 | } 157 | -------------------------------------------------------------------------------- /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 | 28 | By making a contribution to this project, I certify that: 29 | 30 | (a) The contribution was created in whole or in part by me and I 31 | have the right to submit it under the "Apache License, Version 2.0" 32 | ("Apache-2.0"); or 33 | 34 | (b) The contribution is based upon previous work that is covered by 35 | an appropriate open source license and I have the right under 36 | that license to submit that work with modifications, whether 37 | created in whole or in part by me, under the Apache-2.0 license; 38 | or 39 | 40 | (c) The contribution was provided directly to me by some other 41 | person who certified (a) or (b) and I have not modified it. 42 | 43 | (d) I understand and agree that this project and the contribution 44 | are public and that a record of the contribution (including all 45 | metadata and personal information I submit with it, including my 46 | sign-off) is maintained indefinitely and may be redistributed 47 | consistent with this project and the requirements of the Apache-2.0 48 | license or any open source license(s) involved, where they are 49 | relevant. 50 | 51 | (e) I am granting the contribution to this project under the terms of 52 | Apache-2.0. 53 | 54 | http://www.apache.org/licenses/LICENSE-2.0 55 | ``` 56 | 57 | With the sign-off in a commit message you certify that you authored the patch 58 | or otherwise have the right to submit it under an open source license. The 59 | procedure is simple: To certify above system_modes Developer's Certificate of 60 | Origin 1.0 for your contribution just append a line 61 | 62 | Signed-off-by: Random J Developer 63 | 64 | to every commit message using your real name or your pseudonym and a valid 65 | email address. 66 | 67 | If you have set your `user.name` and `user.email` git configs you can 68 | automatically sign the commit by running the git-commit command with the `-s` 69 | option. There may be multiple sign-offs if more than one developer was 70 | involved in authoring the contribution. 71 | 72 | For a more detailed description of this procedure, please see 73 | [SubmittingPatches][] which was extracted from the Linux kernel project, and 74 | which is stored in an external repository. 75 | 76 | ### Individual vs. Corporate Contributors 77 | 78 | Often employers or academic institution have ownership over code that is 79 | written in certain circumstances, so please do due diligence to ensure that 80 | you have the right to submit the code. 81 | 82 | If you are a developer who is authorized to contribute to system_modes on 83 | behalf of your employer, then please use your corporate email address in the 84 | Signed-off-by tag. Otherwise please use a personal email address. 85 | 86 | ## Maintain Copyright holder / Contributor list 87 | 88 | Each contributor is responsible for identifying themselves in the 89 | [NOTICE](NOTICE) file, the project's list of copyright holders and authors. 90 | Please add the respective information corresponding to the Signed-off-by tag 91 | as part of your first pull request. 92 | 93 | If you are a developer who is authorized to contribute to system_modes on 94 | behalf of your employer, then add your company / organization to the list of 95 | copyright holders in the [NOTICE](NOTICE) file. As author of a corporate 96 | contribution you can also add your name and corporate email address as in the 97 | Signed-off-by tag. 98 | 99 | If your contribution is covered by this project's DCO's clause "(c) The 100 | contribution was provided directly to me by some other person who certified 101 | (a) or (b) and I have not modified it", please add the appropriate copyright 102 | holder(s) to the [NOTICE](NOTICE) file as part of your contribution. 103 | 104 | 105 | [DCO]: http://web.archive.org/web/20070306195036/http://osdlab.org/newsroom/press_releases/2004/2004_05_24_dco.html 106 | 107 | [SubmittingPatches]: https://github.com/wking/signed-off-by/blob/7d71be37194df05c349157a2161c7534feaf86a4/Documentation/SubmittingPatches 108 | -------------------------------------------------------------------------------- /rclc/multithread_publisher_subscriber/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define STRING_BUFFER_LEN 100 16 | #define PUBLISHER_NUMBER 3 17 | 18 | #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); return 1;}} 19 | #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);}} 20 | 21 | struct arg_struct { 22 | int index; 23 | rcl_publisher_t *publisher; 24 | }; 25 | 26 | rcl_node_t node; 27 | pthread_t pub_thr[PUBLISHER_NUMBER]; 28 | rcl_publisher_t publisher[PUBLISHER_NUMBER]; 29 | rcl_subscription_t subscriber; 30 | std_msgs__msg__Header recv_msg; 31 | static micro_ros_utilities_memory_conf_t conf = {0}; 32 | 33 | volatile bool exit_flag = false; 34 | 35 | // Publish thread 36 | void* publish( 37 | void* args) 38 | { 39 | struct arg_struct *arguments = args; 40 | rcl_publisher_t *publisher = arguments->publisher; 41 | uint8_t id = arguments->index; 42 | 43 | // Create and allocate the publisher message 44 | std_msgs__msg__Header send_msg; 45 | 46 | bool success = micro_ros_utilities_create_message_memory( 47 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), 48 | &send_msg, 49 | conf); 50 | 51 | if (!success) 52 | { 53 | printf("Error allocating message memory for publisher %d", id); 54 | return NULL; 55 | } 56 | 57 | char message[STRING_BUFFER_LEN]; 58 | sprintf(message, "Thread %d", id); 59 | send_msg.frame_id = micro_ros_string_utilities_set(send_msg.frame_id, message); 60 | 61 | uint32_t period_us = 1e6 + ((rand()) % 10) * 1e5; 62 | printf("Thread %d start, publish period: %.1f seconds\n", id, period_us/1000000.0); 63 | 64 | while (!exit_flag) 65 | { 66 | // Fill the message timestamp 67 | struct timespec ts; 68 | clock_gettime(CLOCK_REALTIME, &ts); 69 | send_msg.stamp.sec = ts.tv_sec; 70 | send_msg.stamp.nanosec = ts.tv_nsec; 71 | 72 | RCSOFTCHECK(rcl_publish(publisher, &send_msg, NULL)); 73 | printf("Thread %d sent: %d-%d\n", id, send_msg.stamp.sec, send_msg.stamp.nanosec); 74 | usleep(period_us); 75 | } 76 | } 77 | 78 | void subscription_callback(const void * msgin) 79 | { 80 | const std_msgs__msg__Header * msg = (const std_msgs__msg__Header *)msgin; 81 | printf("Received %d-%d from %s\n", msg->stamp.sec, msg->stamp.nanosec, msg->frame_id.data); 82 | } 83 | 84 | int main(int argc, const char * const * argv) 85 | { 86 | rcl_allocator_t allocator = rcl_get_default_allocator(); 87 | rclc_support_t support; 88 | 89 | // Create init_options 90 | RCCHECK(rclc_support_init(&support, argc, argv, &allocator)); 91 | 92 | // Create node 93 | RCCHECK(rclc_node_init_default(&node, "multithread_node", "", &support)); 94 | 95 | // Create publishers 96 | for (size_t i = 0; i < PUBLISHER_NUMBER; i++) 97 | { 98 | RCCHECK(rclc_publisher_init_default( 99 | &publisher[i], 100 | &node, 101 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), 102 | "multithread_topic")); 103 | } 104 | 105 | // Create subscriber 106 | RCCHECK(rclc_subscription_init_default( 107 | &subscriber, 108 | &node, 109 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), 110 | "multithread_topic")); 111 | 112 | // Configure and allocate the subscriber message 113 | conf.max_string_capacity = STRING_BUFFER_LEN; 114 | 115 | bool success = micro_ros_utilities_create_message_memory( 116 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), 117 | &recv_msg, 118 | conf); 119 | 120 | if (!success) 121 | { 122 | printf("Error allocating message memory for subscriber"); 123 | return 1; 124 | } 125 | 126 | // Create executor 127 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 128 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 129 | RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &recv_msg, &subscription_callback, ON_NEW_DATA)); 130 | 131 | // Start publish threads 132 | for (size_t i = 0; i < PUBLISHER_NUMBER; i++) 133 | { 134 | struct arg_struct *args = malloc(sizeof(struct arg_struct)); 135 | args->publisher = &publisher[i]; 136 | args->index = i; 137 | 138 | pthread_create(&pub_thr[i], NULL, publish, args); 139 | } 140 | 141 | // Set executor timeout to 100 ms to reduce thread locking time 142 | const uint64_t timeout_ns = 100000000; 143 | RCCHECK(rclc_executor_set_timeout(&executor,timeout_ns)); 144 | rclc_executor_spin(&executor); 145 | 146 | exit_flag = true; 147 | 148 | RCCHECK(rcl_subscription_fini(&subscriber, &node)); 149 | 150 | for (size_t i = 0; i < PUBLISHER_NUMBER; i++) 151 | { 152 | pthread_join(pub_thr[i], NULL); 153 | RCCHECK(rcl_publisher_fini(&publisher[i], &node)); 154 | } 155 | 156 | RCCHECK(rcl_node_fini(&node)); 157 | } 158 | -------------------------------------------------------------------------------- /rclc/ping_pong/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define STRING_BUFFER_LEN 100 13 | 14 | #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); return 1;}} 15 | #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);}} 16 | 17 | rcl_publisher_t ping_publisher; 18 | rcl_publisher_t pong_publisher; 19 | rcl_subscription_t ping_subscriber; 20 | rcl_subscription_t pong_subscriber; 21 | 22 | std_msgs__msg__Header incoming_ping; 23 | std_msgs__msg__Header outcoming_ping; 24 | std_msgs__msg__Header incoming_pong; 25 | 26 | int device_id; 27 | int seq_no; 28 | int pong_count; 29 | 30 | void ping_timer_callback(rcl_timer_t * timer, int64_t last_call_time) 31 | { 32 | (void) last_call_time; 33 | 34 | if (timer != NULL) { 35 | 36 | seq_no = rand(); 37 | sprintf(outcoming_ping.frame_id.data, "%d_%d", seq_no, device_id); 38 | outcoming_ping.frame_id.size = strlen(outcoming_ping.frame_id.data); 39 | 40 | // Fill the message timestamp 41 | struct timespec ts; 42 | clock_gettime(CLOCK_REALTIME, &ts); 43 | outcoming_ping.stamp.sec = ts.tv_sec; 44 | outcoming_ping.stamp.nanosec = ts.tv_nsec; 45 | 46 | // Reset the pong count and publish the ping message 47 | pong_count = 0; 48 | RCSOFTCHECK(rcl_publish(&ping_publisher, (const void*)&outcoming_ping, NULL)); 49 | printf("Ping send seq %s\n", outcoming_ping.frame_id.data); 50 | } 51 | } 52 | 53 | void ping_subscription_callback(const void * msgin) 54 | { 55 | const std_msgs__msg__Header * msg = (const std_msgs__msg__Header *)msgin; 56 | 57 | // Dont pong my own pings 58 | if(strcmp(outcoming_ping.frame_id.data, msg->frame_id.data) != 0){ 59 | printf("Ping received with seq %s. Answering.\n", msg->frame_id.data); 60 | RCSOFTCHECK(rcl_publish(&pong_publisher, (const void*)msg, NULL)); 61 | } 62 | } 63 | 64 | 65 | void pong_subscription_callback(const void * msgin) 66 | { 67 | const std_msgs__msg__Header * msg = (const std_msgs__msg__Header *)msgin; 68 | 69 | if(strcmp(outcoming_ping.frame_id.data, msg->frame_id.data) == 0) { 70 | pong_count++; 71 | printf("Pong for seq %s (%d)\n", msg->frame_id.data, pong_count); 72 | } 73 | } 74 | 75 | 76 | int main() 77 | { 78 | rcl_allocator_t allocator = rcl_get_default_allocator(); 79 | rclc_support_t support; 80 | 81 | // create init_options 82 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 83 | 84 | // create node 85 | rcl_node_t node; 86 | RCCHECK(rclc_node_init_default(&node, "pingpong_node", "", &support)); 87 | 88 | // Create a reliable ping publisher 89 | RCCHECK(rclc_publisher_init_default(&ping_publisher, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/ping")); 90 | 91 | // Create a best effort pong publisher 92 | RCCHECK(rclc_publisher_init_best_effort(&pong_publisher, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/pong")); 93 | 94 | // Create a best effort ping subscriber 95 | RCCHECK(rclc_subscription_init_best_effort(&ping_subscriber, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/ping")); 96 | 97 | // Create a best effort pong subscriber 98 | RCCHECK(rclc_subscription_init_best_effort(&pong_subscriber, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Header), "/microROS/pong")); 99 | 100 | 101 | // Create a 3 seconds ping timer timer, 102 | rcl_timer_t timer; 103 | RCCHECK(rclc_timer_init_default(&timer, &support, RCL_MS_TO_NS(2000), ping_timer_callback)); 104 | 105 | 106 | // Create executor 107 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 108 | RCCHECK(rclc_executor_init(&executor, &support.context, 3, &allocator)); 109 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 110 | RCCHECK(rclc_executor_add_subscription(&executor, &ping_subscriber, &incoming_ping, &ping_subscription_callback, ON_NEW_DATA)); 111 | RCCHECK(rclc_executor_add_subscription(&executor, &pong_subscriber, &incoming_pong, &pong_subscription_callback, ON_NEW_DATA)); 112 | 113 | // Create and allocate the pingpong messages 114 | 115 | char outcoming_ping_buffer[STRING_BUFFER_LEN]; 116 | outcoming_ping.frame_id.data = outcoming_ping_buffer; 117 | outcoming_ping.frame_id.capacity = STRING_BUFFER_LEN; 118 | 119 | char incoming_ping_buffer[STRING_BUFFER_LEN]; 120 | incoming_ping.frame_id.data = incoming_ping_buffer; 121 | incoming_ping.frame_id.capacity = STRING_BUFFER_LEN; 122 | 123 | char incoming_pong_buffer[STRING_BUFFER_LEN]; 124 | incoming_pong.frame_id.data = incoming_pong_buffer; 125 | incoming_pong.frame_id.capacity = STRING_BUFFER_LEN; 126 | 127 | device_id = rand(); 128 | 129 | rclc_executor_spin(&executor); 130 | 131 | RCCHECK(rcl_publisher_fini(&ping_publisher, &node)); 132 | RCCHECK(rcl_publisher_fini(&pong_publisher, &node)); 133 | RCCHECK(rcl_subscription_fini(&ping_subscriber, &node)); 134 | RCCHECK(rcl_subscription_fini(&pong_subscriber, &node)); 135 | RCCHECK(rcl_node_fini(&node)); 136 | } 137 | -------------------------------------------------------------------------------- /rclc/fibonacci_action_server/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #define RCCHECK(fn) {rcl_ret_t temp_rc = fn; if ((temp_rc != RCL_RET_OK)) {printf( \ 13 | "Failed status on line %d: %d. Aborting.\n", __LINE__, (int)temp_rc); return 1;}} 14 | #define RCSOFTCHECK(fn) {rcl_ret_t temp_rc = fn; if ((temp_rc != RCL_RET_OK)) {printf( \ 15 | "Failed status on line %d: %d. Continuing.\n", __LINE__, (int)temp_rc);}} 16 | 17 | const char * goalResult[] = 18 | {[GOAL_STATE_SUCCEEDED] = "succeeded", [GOAL_STATE_CANCELED] = "canceled", 19 | [GOAL_STATE_ABORTED] = "aborted"}; 20 | 21 | void * fibonacci_worker(void * args) 22 | { 23 | (void) args; 24 | rclc_action_goal_handle_t * goal_handle = (rclc_action_goal_handle_t *) args; 25 | rcl_action_goal_state_t goal_state; 26 | 27 | example_interfaces__action__Fibonacci_SendGoal_Request * req = 28 | (example_interfaces__action__Fibonacci_SendGoal_Request *) goal_handle->ros_goal_request; 29 | 30 | example_interfaces__action__Fibonacci_GetResult_Response response = {0}; 31 | example_interfaces__action__Fibonacci_FeedbackMessage feedback; 32 | 33 | if (req->goal.order < 2) { 34 | goal_state = GOAL_STATE_ABORTED; 35 | } else { 36 | feedback.feedback.sequence.capacity = req->goal.order; 37 | feedback.feedback.sequence.size = 0; 38 | feedback.feedback.sequence.data = 39 | (int32_t *) malloc(feedback.feedback.sequence.capacity * sizeof(int32_t)); 40 | 41 | feedback.feedback.sequence.data[0] = 0; 42 | feedback.feedback.sequence.data[1] = 1; 43 | feedback.feedback.sequence.size = 2; 44 | 45 | for (size_t i = 2; i < (size_t) req->goal.order && !goal_handle->goal_cancelled; i++) { 46 | feedback.feedback.sequence.data[i] = feedback.feedback.sequence.data[i - 1] + 47 | feedback.feedback.sequence.data[i - 2]; 48 | feedback.feedback.sequence.size++; 49 | 50 | printf("Publishing feedback\n"); 51 | rclc_action_publish_feedback(goal_handle, &feedback); 52 | usleep(500000); 53 | } 54 | 55 | if (!goal_handle->goal_cancelled) { 56 | response.result.sequence.capacity = feedback.feedback.sequence.capacity; 57 | response.result.sequence.size = feedback.feedback.sequence.size; 58 | response.result.sequence.data = feedback.feedback.sequence.data; 59 | goal_state = GOAL_STATE_SUCCEEDED; 60 | } else { 61 | goal_state = GOAL_STATE_CANCELED; 62 | } 63 | } 64 | 65 | printf("Goal %d %s, sending result array\n", req->goal.order, goalResult[goal_state]); 66 | 67 | rcl_ret_t rc; 68 | do { 69 | rc = rclc_action_send_result(goal_handle, goal_state, &response); 70 | usleep(1e6); 71 | } while (rc != RCL_RET_OK); 72 | 73 | free(feedback.feedback.sequence.data); 74 | pthread_exit(NULL); 75 | } 76 | 77 | rcl_ret_t handle_goal(rclc_action_goal_handle_t * goal_handle, void * context) 78 | { 79 | (void) context; 80 | 81 | example_interfaces__action__Fibonacci_SendGoal_Request * req = 82 | (example_interfaces__action__Fibonacci_SendGoal_Request *) goal_handle->ros_goal_request; 83 | 84 | // Too big, rejecting 85 | if (req->goal.order > 200) { 86 | printf("Goal %d rejected\n", req->goal.order); 87 | return RCL_RET_ACTION_GOAL_REJECTED; 88 | } 89 | 90 | printf("Goal %d accepted\n", req->goal.order); 91 | 92 | pthread_t * thread_id = malloc(sizeof(pthread_t)); 93 | pthread_create(thread_id, NULL, fibonacci_worker, goal_handle); 94 | return RCL_RET_ACTION_GOAL_ACCEPTED; 95 | } 96 | 97 | bool handle_cancel(rclc_action_goal_handle_t * goal_handle, void * context) 98 | { 99 | (void) context; 100 | (void) goal_handle; 101 | 102 | return true; 103 | } 104 | 105 | int main(int argc, const char * const * argv) 106 | { 107 | rcl_allocator_t allocator = rcl_get_default_allocator(); 108 | rclc_support_t support; 109 | 110 | // create init_options 111 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 112 | 113 | // create node 114 | rcl_node_t node; 115 | RCCHECK(rclc_node_init_default(&node, "fibonacci_action_server_rcl", "", &support)); 116 | 117 | // Create action service 118 | rclc_action_server_t action_server; 119 | RCCHECK( 120 | rclc_action_server_init_default( 121 | &action_server, 122 | &node, 123 | &support, 124 | ROSIDL_GET_ACTION_TYPE_SUPPORT(example_interfaces, Fibonacci), 125 | "fibonacci" 126 | )); 127 | 128 | // Create executor 129 | rclc_executor_t executor; 130 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 131 | 132 | example_interfaces__action__Fibonacci_SendGoal_Request ros_goal_request[10]; 133 | 134 | RCCHECK( 135 | rclc_executor_add_action_server( 136 | &executor, 137 | &action_server, 138 | 10, 139 | ros_goal_request, 140 | sizeof(example_interfaces__action__Fibonacci_SendGoal_Request), 141 | handle_goal, 142 | handle_cancel, 143 | (void *) &action_server)); 144 | 145 | while (true) { 146 | rclc_executor_spin_some(&executor, RCL_MS_TO_NS(10)); 147 | usleep(100000); 148 | } 149 | 150 | RCCHECK(rclc_action_server_fini(&action_server, &node)) 151 | RCCHECK(rcl_node_fini(&node)) 152 | 153 | return 0; 154 | } 155 | -------------------------------------------------------------------------------- /rclc/configuration_example/custom_transports/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #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); return 1;}} 24 | #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);}} 25 | 26 | // --- micro-ROS Transports --- 27 | 28 | typedef struct { 29 | struct pollfd poll_fd; 30 | } custom_transport_data_t; 31 | 32 | bool custom_transport_open(struct uxrCustomTransport * transport){ 33 | custom_transport_data_t * transport_data = (custom_transport_data_t*) transport->args; 34 | 35 | bool rv = false; 36 | transport_data->poll_fd.fd = socket(AF_INET, SOCK_DGRAM, 0); 37 | 38 | if (-1 != transport_data->poll_fd.fd) 39 | { 40 | struct addrinfo hints; 41 | struct addrinfo* result; 42 | struct addrinfo* ptr; 43 | 44 | memset(&hints, 0, sizeof(hints)); 45 | hints.ai_family = AF_INET; 46 | hints.ai_socktype = SOCK_DGRAM; 47 | 48 | if (0 == getaddrinfo("localhost", "8888", &hints, &result)) 49 | { 50 | for (ptr = result; ptr != NULL; ptr = ptr->ai_next) 51 | { 52 | if (0 == connect(transport_data->poll_fd.fd, ptr->ai_addr, ptr->ai_addrlen)) 53 | { 54 | transport_data->poll_fd.events = POLLIN; 55 | rv = true; 56 | break; 57 | } 58 | } 59 | } 60 | freeaddrinfo(result); 61 | } 62 | return rcutils_vsnprintf; 63 | } 64 | 65 | bool custom_transport_close(struct uxrCustomTransport * transport){ 66 | custom_transport_data_t * transport_data = (custom_transport_data_t*) transport->args; 67 | return (-1 == transport_data->poll_fd.fd) ? true : (0 == close(transport_data->poll_fd.fd)); 68 | } 69 | 70 | size_t custom_transport_write(struct uxrCustomTransport* transport, const uint8_t * buf, size_t len, uint8_t * errcode){ 71 | custom_transport_data_t * transport_data = (custom_transport_data_t*) transport->args; 72 | size_t rv = 0; 73 | ssize_t bytes_sent = send(transport_data->poll_fd.fd, (void*)buf, len, 0); 74 | if (-1 != bytes_sent) 75 | { 76 | rv = (size_t)bytes_sent; 77 | *errcode = 0; 78 | } 79 | else 80 | { 81 | *errcode = 1; 82 | } 83 | return rv; 84 | } 85 | 86 | size_t custom_transport_read(struct uxrCustomTransport* transport, uint8_t* buf, size_t len, int timeout, uint8_t* errcode){ 87 | custom_transport_data_t * transport_data = (custom_transport_data_t*) transport->args; 88 | size_t rv = 0; 89 | int poll_rv = poll(&transport_data->poll_fd, 1, timeout); 90 | if (0 < poll_rv) 91 | { 92 | ssize_t bytes_received = recv(transport_data->poll_fd.fd, (void*)buf, len, 0); 93 | if (-1 != bytes_received) 94 | { 95 | rv = (size_t)bytes_received; 96 | *errcode = 0; 97 | } 98 | else 99 | { 100 | *errcode = 1; 101 | } 102 | } 103 | else 104 | { 105 | *errcode = (0 == poll_rv) ? 0 : 1; 106 | } 107 | return rv; 108 | } 109 | 110 | 111 | // --- micro-ROS App --- 112 | 113 | rcl_publisher_t publisher; 114 | std_msgs__msg__Int32 msg; 115 | 116 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 117 | { 118 | (void) last_call_time; 119 | if (timer != NULL) { 120 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 121 | printf("Sent: %d\n", msg.data); 122 | msg.data++; 123 | } 124 | } 125 | 126 | int main(int argc, char * const argv[]) 127 | { 128 | rcl_allocator_t allocator = rcl_get_default_allocator(); 129 | rclc_support_t support; 130 | rcl_init_options_t init_options = rcl_get_zero_initialized_init_options(); 131 | 132 | RCCHECK(rcl_init_options_init(&init_options, allocator)); 133 | rmw_init_options_t* rmw_options = rcl_init_options_get_rmw_init_options(&init_options); 134 | RCCHECK(rmw_uros_options_set_client_key(0xCAFEBABA, rmw_options)) 135 | 136 | custom_transport_data_t custom_transport_data; 137 | 138 | RCCHECK(rmw_uros_set_custom_transport( 139 | false, 140 | (void*) &custom_transport_data, 141 | custom_transport_open, 142 | custom_transport_close, 143 | custom_transport_write, 144 | custom_transport_read 145 | )) 146 | 147 | // create init_options 148 | RCCHECK(rclc_support_init_with_options(&support, 0, NULL, &init_options, &allocator)); 149 | 150 | // create node 151 | rcl_node_t node; 152 | RCCHECK(rclc_node_init_default(&node, "custom_transport_node", "", &support)); 153 | 154 | // create publisher 155 | RCCHECK(rclc_publisher_init_default( 156 | &publisher, 157 | &node, 158 | ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), 159 | "std_msgs_msg_Int32")); 160 | 161 | // create timer, 162 | rcl_timer_t timer; 163 | const unsigned int timer_timeout = 1000; 164 | RCCHECK(rclc_timer_init_default( 165 | &timer, 166 | &support, 167 | RCL_MS_TO_NS(timer_timeout), 168 | timer_callback)); 169 | 170 | // create executor 171 | rclc_executor_t executor = rclc_executor_get_zero_initialized_executor(); 172 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 173 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 174 | 175 | msg.data = 0; 176 | 177 | rclc_executor_spin(&executor); 178 | 179 | RCCHECK(rcl_publisher_fini(&publisher, &node)); 180 | RCCHECK(rcl_node_fini(&node)); 181 | 182 | return 0; 183 | } 184 | -------------------------------------------------------------------------------- /rclc/fibonacci_action_client/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #define RCCHECK(fn) {rcl_ret_t temp_rc = fn; if ((temp_rc != RCL_RET_OK)) {printf( \ 13 | "Failed status on line %d: %d. Aborting.\n", __LINE__, (int)temp_rc); return 1;}} 14 | #define RCSOFTCHECK(fn) {rcl_ret_t temp_rc = fn; if ((temp_rc != RCL_RET_OK)) {printf( \ 15 | "Failed status on line %d: %d. Continuing.\n", __LINE__, (int)temp_rc);}} 16 | 17 | #define MAX_FIBONACCI_ORDER 500 18 | bool goal_completed = false; 19 | int goal_order = 10; 20 | 21 | void goal_request_callback(rclc_action_goal_handle_t * goal_handle, bool accepted, void * context) 22 | { 23 | (void) context; 24 | 25 | example_interfaces__action__Fibonacci_SendGoal_Request * request = 26 | (example_interfaces__action__Fibonacci_SendGoal_Request *) goal_handle->ros_goal_request; 27 | printf( 28 | "Goal request (order: %d): %s\n", 29 | request->goal.order, 30 | accepted ? "Accepted" : "Rejected" 31 | ); 32 | 33 | if (!accepted) { 34 | goal_completed = true; 35 | } 36 | } 37 | 38 | void feedback_callback(rclc_action_goal_handle_t * goal_handle, void * ros_feedback, void * context) 39 | { 40 | (void) context; 41 | 42 | example_interfaces__action__Fibonacci_SendGoal_Request * request = 43 | (example_interfaces__action__Fibonacci_SendGoal_Request *) goal_handle->ros_goal_request; 44 | 45 | printf( 46 | "Goal Feedback (order: %d) [", 47 | request->goal.order 48 | ); 49 | 50 | example_interfaces__action__Fibonacci_FeedbackMessage * feedback = 51 | (example_interfaces__action__Fibonacci_FeedbackMessage *) ros_feedback; 52 | 53 | for (size_t i = 0; i < feedback->feedback.sequence.size; i++) { 54 | printf("%d ", feedback->feedback.sequence.data[i]); 55 | } 56 | printf("\b]\n"); 57 | } 58 | 59 | void result_request_callback( 60 | rclc_action_goal_handle_t * goal_handle, void * ros_result_response, 61 | void * context) 62 | { 63 | (void) context; 64 | 65 | static size_t goal_count = 1; 66 | 67 | example_interfaces__action__Fibonacci_SendGoal_Request * request = 68 | (example_interfaces__action__Fibonacci_SendGoal_Request *) goal_handle->ros_goal_request; 69 | 70 | printf( 71 | "Goal Result (order: %d) [", 72 | request->goal.order 73 | ); 74 | 75 | example_interfaces__action__Fibonacci_GetResult_Response * result = 76 | (example_interfaces__action__Fibonacci_GetResult_Response *) ros_result_response; 77 | 78 | if (result->status == GOAL_STATE_SUCCEEDED) { 79 | for (size_t i = 0; i < result->result.sequence.size; i++) { 80 | printf("%d ", result->result.sequence.data[i]); 81 | } 82 | } else if (result->status == GOAL_STATE_CANCELED) { 83 | printf("CANCELED "); 84 | } else { 85 | printf("ABORTED "); 86 | } 87 | 88 | printf("\b]\n"); 89 | 90 | goal_completed = true; 91 | } 92 | 93 | void cancel_request_callback( 94 | rclc_action_goal_handle_t * goal_handle, bool cancelled, 95 | void * context) 96 | { 97 | (void) context; 98 | 99 | example_interfaces__action__Fibonacci_SendGoal_Request * request = 100 | (example_interfaces__action__Fibonacci_SendGoal_Request *) goal_handle->ros_goal_request; 101 | 102 | printf( 103 | "Goal cancel request (order: %d): %s\n", 104 | request->goal.order, 105 | cancelled ? "Accepted" : "Rejected"); 106 | 107 | if (cancelled) { 108 | goal_completed = true; 109 | } 110 | } 111 | 112 | int main(int argc, const char * const * argv) 113 | { 114 | rcl_allocator_t allocator = rcl_get_default_allocator(); 115 | rclc_support_t support; 116 | 117 | // create init_options 118 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 119 | 120 | // create node 121 | rcl_node_t node; 122 | RCCHECK(rclc_node_init_default(&node, "fibonacci_action_client_rcl", "", &support)); 123 | 124 | // Create action client 125 | rclc_action_client_t action_client; 126 | RCCHECK( 127 | rclc_action_client_init_default( 128 | &action_client, 129 | &node, 130 | ROSIDL_GET_ACTION_TYPE_SUPPORT(example_interfaces, Fibonacci), 131 | "fibonacci" 132 | )); 133 | 134 | // Create executor 135 | rclc_executor_t executor; 136 | rclc_executor_init(&executor, &support.context, 1, &allocator); 137 | 138 | example_interfaces__action__Fibonacci_FeedbackMessage ros_feedback; 139 | example_interfaces__action__Fibonacci_GetResult_Response ros_result_response; 140 | example_interfaces__action__Fibonacci_SendGoal_Request ros_goal_request; 141 | 142 | // Allocate msg memory 143 | ros_feedback.feedback.sequence.capacity = MAX_FIBONACCI_ORDER; 144 | ros_feedback.feedback.sequence.size = 0; 145 | ros_feedback.feedback.sequence.data = (int32_t *) malloc( 146 | ros_feedback.feedback.sequence.capacity * sizeof(int32_t)); 147 | 148 | ros_result_response.result.sequence.capacity = MAX_FIBONACCI_ORDER; 149 | ros_result_response.result.sequence.size = 0; 150 | ros_result_response.result.sequence.data = (int32_t *) malloc( 151 | ros_result_response.result.sequence.capacity * sizeof(int32_t)); 152 | 153 | RCCHECK( 154 | rclc_executor_add_action_client( 155 | &executor, 156 | &action_client, 157 | 10, 158 | &ros_result_response, 159 | &ros_feedback, 160 | goal_request_callback, 161 | feedback_callback, 162 | result_request_callback, 163 | cancel_request_callback, 164 | (void *) &action_client 165 | )); 166 | 167 | sleep(2); 168 | 169 | // Send goal request 170 | ros_goal_request.goal.order = goal_order; 171 | RCCHECK(rclc_action_send_goal_request(&action_client, &ros_goal_request, NULL)); 172 | 173 | while (!goal_completed) { 174 | rclc_executor_spin_some(&executor, RCL_MS_TO_NS(10)); 175 | usleep(100000); 176 | } 177 | 178 | RCCHECK(rclc_action_client_fini(&action_client, &node)) 179 | RCCHECK(rcl_node_fini(&node)) 180 | 181 | return 0; 182 | } 183 | -------------------------------------------------------------------------------- /rclc/static_type_handling/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | rcl_publisher_t publisher; 13 | sensor_msgs__msg__Image msg; 14 | sensor_msgs__msg__Image msg_static; 15 | rclc_executor_t executor; 16 | rclc_support_t support; 17 | rcl_allocator_t allocator; 18 | rcl_node_t node; 19 | rcl_timer_t timer; 20 | 21 | uint8_t my_buffer[1000]; 22 | 23 | #define LED_PIN 13 24 | 25 | #define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){error_loop();}} 26 | #define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){}} 27 | 28 | 29 | void error_loop(){ 30 | while(1){ 31 | } 32 | } 33 | 34 | void timer_callback(rcl_timer_t * timer, int64_t last_call_time) 35 | { 36 | RCLC_UNUSED(last_call_time); 37 | if (timer != NULL) { 38 | RCSOFTCHECK(rcl_publish(&publisher, &msg, NULL)); 39 | RCSOFTCHECK(rcl_publish(&publisher, &msg_static, NULL)); 40 | } 41 | } 42 | 43 | int main() { 44 | allocator = rcl_get_default_allocator(); 45 | 46 | //create init_options 47 | RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); 48 | 49 | // create node 50 | RCCHECK(rclc_node_init_default(&node, "micro_ros_node", "", &support)); 51 | 52 | // create publisher 53 | RCCHECK(rclc_publisher_init_default( 54 | &publisher, 55 | &node, 56 | ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, Image), 57 | "micro_ros_publisher")); 58 | 59 | // create timer, 60 | const unsigned int timer_timeout = 1000; 61 | RCCHECK(rclc_timer_init_default( 62 | &timer, 63 | &support, 64 | RCL_MS_TO_NS(timer_timeout), 65 | timer_callback)); 66 | 67 | // create executor 68 | RCCHECK(rclc_executor_init(&executor, &support.context, 1, &allocator)); 69 | RCCHECK(rclc_executor_add_timer(&executor, &timer)); 70 | 71 | // INIT MESSAGE MEMORY 72 | 73 | // --- Configuration --- 74 | 75 | // micro-ROS utilities allows to configure the dynamic memory initialization using a micro_ros_utilities_memory_conf_t structure 76 | // If some member of this struct is set to zero, the library will use the default value. 77 | // Check `micro_ros_utilities_memory_conf_default` in `` for those defaults. 78 | 79 | static micro_ros_utilities_memory_conf_t conf = {0}; 80 | 81 | // OPTIONALLY this struct can configure the default size of strings, basic sequences and composed sequences 82 | 83 | conf.max_string_capacity = 50; 84 | conf.max_ros2_type_sequence_capacity = 5; 85 | conf.max_basic_type_sequence_capacity = 5; 86 | 87 | // OPTIONALLY this struct can store rules for specific members 88 | // !! Using the API with rules will use dynamic memory allocations for handling strings !! 89 | 90 | micro_ros_utilities_memory_rule_t rules[] = { 91 | {"header.frame_id", 30}, 92 | {"encoding", 3}, 93 | {"data", 400} 94 | }; 95 | conf.rules = rules; 96 | conf.n_rules = sizeof(rules) / sizeof(rules[0]); 97 | 98 | // --- API --- 99 | // Type can be instrospected using: 100 | 101 | rosidl_runtime_c__String data = micro_ros_utilities_type_info( 102 | ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, Image)); 103 | printf("%s", data.data); 104 | 105 | // It can be calculated the size that will be needed by a msg with a certain configuration 106 | 107 | size_t dynamic_size = micro_ros_utilities_get_dynamic_size( 108 | ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, Image), 109 | conf 110 | ); 111 | 112 | // The total (stack, static & dynamic) memory usage of a packet will be: 113 | 114 | size_t message_total_size = dynamic_size + sizeof(sensor_msgs__msg__Image); 115 | 116 | // The message dynamic memory can be allocated using the following call. 117 | // This will use rcutils default allocators for getting memory. 118 | 119 | bool success = micro_ros_utilities_create_message_memory( 120 | ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, Image), 121 | &msg, 122 | conf 123 | ); 124 | 125 | // The message dynamic memory can also be allocated using a buffer. 126 | // This will NOT use dynamic memory for the allocation. 127 | // If no rules set in the conf, no dynamic allocation is guaranteed. 128 | // This method will use need more memory than dynamic due to alignment 129 | 130 | size_t static_size = micro_ros_utilities_get_static_size( 131 | ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, Image), 132 | conf 133 | ); 134 | 135 | message_total_size = static_size + sizeof(sensor_msgs__msg__Image); 136 | 137 | // my_buffer should have at least static_size Bytes 138 | success &= micro_ros_utilities_create_static_message_memory( 139 | ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, Image), 140 | &msg_static, 141 | conf, 142 | my_buffer, 143 | sizeof(my_buffer) 144 | ); 145 | 146 | // Dynamically allocated messages can be destroyed using: 147 | 148 | // success &= micro_ros_utilities_destroy_message_memory( 149 | // ROSIDL_GET_MSG_TYPE_SUPPORT(control_msgs, msg, JointJog), 150 | // &msg, 151 | // conf 152 | // ); 153 | 154 | // Fill the message 155 | msg.header.frame_id = micro_ros_string_utilities_set(msg.header.frame_id, "myframe"); 156 | msg_static.header.frame_id = micro_ros_string_utilities_set(msg_static.header.frame_id, "myframestatic"); 157 | 158 | msg.height = msg_static.height = 10; 159 | msg.width = msg_static.width = 40; 160 | 161 | msg.encoding = micro_ros_string_utilities_set(msg.encoding, "RGB"); 162 | msg_static.encoding = micro_ros_string_utilities_set(msg_static.encoding, "RGB"); 163 | 164 | msg.data.size = msg_static.data.size = 400; 165 | for (size_t i = 0; i < msg.data.size; i++) 166 | { 167 | msg.data.data[i] = i; 168 | msg_static.data.data[i] = i; 169 | } 170 | 171 | while(1) { 172 | usleep(100000); 173 | RCSOFTCHECK(rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100))); 174 | } 175 | 176 | } 177 | -------------------------------------------------------------------------------- /rclc/graph_introspection/graph_visualizer/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #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); return 1;}} 9 | #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);}} 10 | 11 | int main(int argc, const char * const * argv) 12 | { 13 | rcl_init_options_t options = rcl_get_zero_initialized_init_options(); 14 | rcl_allocator_t allocator = rcl_get_default_allocator(); 15 | RCCHECK(rcl_init_options_init(&options, allocator)); 16 | 17 | rcl_context_t context = rcl_get_zero_initialized_context(); 18 | RCCHECK(rcl_init(argc, argv, &options, &context)); 19 | 20 | rcl_node_options_t node_ops = rcl_node_get_default_options(); 21 | rcl_node_t node = rcl_get_zero_initialized_node(); 22 | RCCHECK(rcl_node_init(&node, "microros_graph_tester", "", &context, &node_ops)); 23 | 24 | rcl_wait_set_t wait_set = rcl_get_zero_initialized_wait_set(); 25 | RCCHECK(rcl_wait_set_init(&wait_set, 0, 1, 0, 0, 0, 0, &context, allocator)); 26 | 27 | const rcl_guard_condition_t * graph_guard_condition = 28 | rcl_node_get_graph_guard_condition(&node); 29 | if (NULL == graph_guard_condition) { 30 | printf("Error: node graph guard condition is invalid\n"); 31 | RCCHECK(rcl_node_fini(&node)); 32 | RCCHECK(rcl_shutdown(&context)); 33 | return 1; 34 | } 35 | 36 | while (true) 37 | { 38 | RCSOFTCHECK(rcl_wait_set_clear(&wait_set)); 39 | 40 | size_t index; 41 | RCCHECK(rcl_wait_set_add_guard_condition( 42 | &wait_set, graph_guard_condition, &index)); 43 | 44 | rcl_ret_t unused = rcl_wait(&wait_set, RCL_MS_TO_NS(100)); 45 | 46 | for (size_t i = 0; i < wait_set.size_of_guard_conditions; ++i) { 47 | if (wait_set.guard_conditions[i]) { 48 | // Topic names and types 49 | rcl_names_and_types_t topic_names_and_types = 50 | rcl_get_zero_initialized_names_and_types(); 51 | RCCHECK(rcl_get_topic_names_and_types(&node, &allocator, false, &topic_names_and_types)); 52 | 53 | printf("\n---------------------------------------------------------------\n"); 54 | printf(" 'rcl_get_topic_names_and_types' result\n"); 55 | printf("---------------------------------------------------------------\n"); 56 | size_t topic_num = topic_names_and_types.names.size; 57 | printf("Current number of ROS 2 and micro-ROS topics: %lu\n", topic_num); 58 | 59 | for (size_t j = 0; j < topic_num; ++j) { 60 | rcutils_string_array_t * topic_types = &topic_names_and_types.types[j]; 61 | printf(" %lu) topic: '%s', types: ", j + 1, topic_names_and_types.names.data[j]); 62 | for (size_t k = 0; k < topic_types->size; ++k) { 63 | printf("%s", topic_types->data[k]); 64 | if (k < (topic_types->size - 1)) { 65 | printf(", "); 66 | } else { 67 | printf("\n"); 68 | } 69 | } 70 | rcl_topic_endpoint_info_array_t publishers_info = 71 | rcl_get_zero_initialized_topic_endpoint_info_array(); 72 | RCCHECK(rcl_get_publishers_info_by_topic(&node, &allocator, 73 | topic_names_and_types.names.data[j], false, &publishers_info)); 74 | printf(" topic endpoint information:\n"); 75 | for (size_t k = 0; k < publishers_info.size; ++k) { 76 | printf(" Node: '%s%s', type: '%s', '%s'\n", 77 | publishers_info.info_array[k].node_namespace, 78 | publishers_info.info_array[k].node_name, 79 | publishers_info.info_array[k].topic_type, 80 | RMW_ENDPOINT_PUBLISHER == publishers_info.info_array[k].endpoint_type ? "publisher" : "error"); 81 | } 82 | rcl_topic_endpoint_info_array_fini(&publishers_info, &allocator); 83 | 84 | rcl_topic_endpoint_info_array_t subscriptions_info = 85 | rcl_get_zero_initialized_topic_endpoint_info_array(); 86 | RCCHECK(rcl_get_subscriptions_info_by_topic(&node, &allocator, 87 | topic_names_and_types.names.data[j], false, &subscriptions_info)); 88 | for (size_t k = 0; k < subscriptions_info.size; ++k) { 89 | printf(" Node: '%s%s', type: '%s', '%s'\n", 90 | subscriptions_info.info_array[k].node_namespace, 91 | subscriptions_info.info_array[k].node_name, 92 | subscriptions_info.info_array[k].topic_type, 93 | RMW_ENDPOINT_SUBSCRIPTION == subscriptions_info.info_array[k].endpoint_type ? "subscription" : "error"); 94 | } 95 | rcl_topic_endpoint_info_array_fini(&subscriptions_info, &allocator); 96 | } 97 | 98 | RCSOFTCHECK(rcl_names_and_types_fini(&topic_names_and_types)); 99 | 100 | // Service names and types 101 | rcl_names_and_types_t service_names_and_types = 102 | rcl_get_zero_initialized_names_and_types(); 103 | RCCHECK(rcl_get_service_names_and_types(&node, &allocator, &service_names_and_types)); 104 | 105 | printf("\n---------------------------------------------------------------\n"); 106 | printf(" 'rcl_get_service_names_and_types' result\n"); 107 | printf("---------------------------------------------------------------\n"); 108 | size_t service_num = service_names_and_types.names.size; 109 | printf("Current number of ROS 2 and micro-ROS services: %lu\n", service_num); 110 | 111 | for (size_t j = 0; j < service_num; ++j) { 112 | rcutils_string_array_t * service_types = &service_names_and_types.types[j]; 113 | printf(" %lu) service: '%s', types: ", j + 1, service_names_and_types.names.data[j]); 114 | for (size_t k = 0; k < service_types->size; ++k) { 115 | printf("%s", service_types->data[k]); 116 | if (k < (service_types->size - 1)) { 117 | printf(", "); 118 | } else { 119 | printf("\n"); 120 | } 121 | } 122 | } 123 | 124 | RCSOFTCHECK(rcl_names_and_types_fini(&service_names_and_types)); 125 | 126 | // Node names 127 | rcutils_string_array_t node_names = rcutils_get_zero_initialized_string_array(); 128 | rcutils_string_array_t node_namespaces = rcutils_get_zero_initialized_string_array(); 129 | RCCHECK(rcl_get_node_names(&node, allocator, &node_names, &node_namespaces)); 130 | 131 | printf("\n---------------------------------------------------------------\n"); 132 | printf(" 'rcl_get_node_names' result\n"); 133 | printf("---------------------------------------------------------------\n"); 134 | size_t node_num = node_names.size; 135 | printf("Current number of ROS 2 and micro-ROS nodes: %lu\n", node_num); 136 | 137 | for (size_t j = 0; j < node_num; ++j) { 138 | printf(" %lu) node: '%s%s'\n", j + 1, node_namespaces.data[j], node_names.data[j]); 139 | printf(" 'rcl_get_publisher_names_and_types_by_node' result for this node:\n"); 140 | rcl_names_and_types_t publisher_names_and_types = rcl_get_zero_initialized_names_and_types(); 141 | RCCHECK(rcl_get_publisher_names_and_types_by_node( 142 | &node, &allocator, false, node_names.data[j], node_namespaces.data[j], 143 | &publisher_names_and_types)); 144 | for (size_t k = 0; k < publisher_names_and_types.names.size; ++k) { 145 | printf(" %lu.%lu) %s, with types: ", j + 1, k + 1, 146 | publisher_names_and_types.names.data[k]); 147 | for (size_t l = 0; l < publisher_names_and_types.types[k].size; ++l) { 148 | printf("%s", publisher_names_and_types.types[k].data[l]); 149 | if (l < (publisher_names_and_types.types[k].size - 1)) { 150 | printf(", "); 151 | } else { 152 | printf("\n"); 153 | } 154 | } 155 | } 156 | RCSOFTCHECK(rcl_names_and_types_fini(&publisher_names_and_types)); 157 | } 158 | 159 | if (RCUTILS_RET_OK != rcutils_string_array_fini(&node_names) || 160 | RCUTILS_RET_OK != rcutils_string_array_fini(&node_namespaces)) { 161 | printf("Error while freeing rcutils resources\n"); 162 | return 1; 163 | } 164 | } 165 | } 166 | } 167 | 168 | RCCHECK(rcl_node_fini(&node)); 169 | RCCHECK(rcl_shutdown(&context)); 170 | return 0; 171 | } 172 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # micro-ROS Demos 2 | 3 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 4 | 5 | ## Overview 6 | 7 | The primary purpose for this repository is to organise all packages for the [Micro-ROS project](https://microros.github.io/) functionalities demonstrations. 8 | All packages contained in this repository are a part of the Micro-ROS project stack. 9 | 10 | ## Previous step 11 | 12 | To run all the demonstrations, you need to set up the ROS2 environment and build all the required packages. 13 | Click [here](https://github.com/micro-ROS/micro_ros_setup?tab=readme-ov-file#building) to read further about how to do this previous step. 14 | 15 | ## Package clusters 16 | 17 | The repository contains the below packages clusters: 18 | 19 | ### Simple message demonstration 20 | 21 | #### Packages 22 | 23 | ##### Int32_publisher 24 | 25 | The purpose of the package is to publish one of the most basic ROS2 messages and demonstrate how Micro-ROS layers (rcl, typesupport and rmw) handle it. 26 | For each publication, the message value increases in one unit order to see in the subscriber side the message variations. 27 | 28 | ##### Int32_subscriber 29 | 30 | The purpose of the package is to subscribe to one of the most basic ROS2 messages and demonstrate how Micro-ROS layers (rcl, typesupport and rmw) handle it. 31 | 32 | #### Run demonstration (Linux) 33 | 34 | Run the micro-ROS Agent. 35 | For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder. 36 | 37 | ```bash 38 | cd ~/agent_ws/install/uros_agent/lib/uros_agent/ 39 | ./uros_agent udp 8888 40 | ``` 41 | 42 | You may prefer to run the Agent in the background and discard all outputs to keep using the same terminal for the next step. 43 | 44 | ```bash 45 | cd ~/agent_ws/install/uros_agent/lib/uros_agent/ 46 | ./uros_agent udp 8888 > /dev/null & 47 | ``` 48 | 49 | Run the publisher. 50 | 51 | ```bash 52 | ~/client_ws/install/int32_publisher_c/lib/int32_publisher_c/./int32_publisher_c 53 | ``` 54 | 55 | You may prefer to run the publisher in the background and discard all outputs to keep using the terminal for the next step. 56 | 57 | ```bash 58 | ~/client_ws/install/int32_publisher_c/lib/int32_publisher_c/./int32_publisher_c > /dev/null & 59 | ``` 60 | 61 | Run the subscriber. 62 | 63 | ```bash 64 | ~/client_ws/install/int32_subscriber_c/lib/int32_subscriber_c/./int32_subscriber_c 65 | ``` 66 | 67 | #### Run demonstration (Windows) 68 | 69 | Run the micro-ROS Agent. 70 | For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder. 71 | 72 | ```bash 73 | cd C:\A\install\Lib\uros_agent\ 74 | uros_agent.exe udp 8888 75 | ``` 76 | 77 | Run the publisher. 78 | 79 | ```bash 80 | cd C:\C\install\Lib\int32_publisher_c\ 81 | int32_publisher_c.exe 82 | ``` 83 | 84 | Run the subscriber. 85 | 86 | ```bash 87 | cd C:\C\install\Lib\int32_subscriber_c\ 88 | int32_subscriber_c.exe 89 | ``` 90 | 91 | 92 | ### String message demonstration 93 | 94 | #### String packages 95 | 96 | ##### String_publisher 97 | 98 | The purpose of the package is to publish a simple string ROS2 message and demonstrate how Micro-ROS layers (rcl, typesupport and rmw) handle it. 99 | For each publication, the message string number increases in one unit order to see in the subscriber side the message variations. 100 | 101 | ##### String_subscriber 102 | 103 | The purpose of the package is to subscribe to a simple string ROS2 message and demonstrate how Micro-ROS layers (rcl, typesupport and rmw) handle it. 104 | 105 | #### Run string demonstration (Linux) 106 | 107 | Run the micro-ROS Agent. 108 | For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder. 109 | 110 | ```bash 111 | cd ~/agent_ws/install/uros_agent/lib/uros_agent/ 112 | ./uros_agent udp 8888 113 | ``` 114 | 115 | You may prefer to run the Agent in the background and discard all outputs to keep using the same terminal for the next step. 116 | 117 | ```bash 118 | cd ~/agent_ws/install/uros_agent/lib/uros_agent/ 119 | ./uros_agent udp 8888 > /dev/null & 120 | ``` 121 | 122 | Run the publisher. 123 | 124 | ```bash 125 | ~/client_ws/install/string_publisher_c/lib/string_publisher_c/./string_publisher_c 126 | ``` 127 | 128 | You may prefer to run the publisher in the background and discard all outputs in order to keep using the terminal for the next step. 129 | 130 | ```bash 131 | ~/client_ws/install/string_publisher_c/lib/string_publisher_c/./string_publisher_c > /dev/null & 132 | ``` 133 | 134 | Run the subscriber. 135 | 136 | ```bash 137 | ~/client_ws/install/string_subscriber_c/lib/string_subscriber_c/./string_subscriber_c 138 | ``` 139 | 140 | #### Run string demonstration (Windows) 141 | 142 | Run the micro-ROS Agent. 143 | For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder. 144 | 145 | ```bash 146 | cd C:\A\install\Lib\uros_agent\ 147 | uros_agent.exe udp 8888 148 | ``` 149 | 150 | Run the publisher. 151 | 152 | ```bash 153 | cd C:\C\install\Lib\string_publisher_c\ 154 | string_publisher_c.exe 155 | ``` 156 | 157 | Run the subscriber. 158 | 159 | ```bash 160 | cd C:\C\install\Lib\string_subscriber_c\ 161 | string_subscriber_c.exe 162 | ``` 163 | 164 | ### Complex message demonstration 165 | 166 | #### Complex packages 167 | 168 | ##### complex_msg 169 | 170 | One of the purposes of the package is to demonstrate how typesupport code is generated for a complex message. 171 | Also, the generation of a complex ROS2 structure message is used to demonstrate how the different layers (rcl, typesupport and rmw) handle it. 172 | The message structure contains the following types: 173 | 174 | - All primitive data types. 175 | - Nested message data. 176 | - Unbonded string data. 177 | 178 | ##### Complex_msg_publisher 179 | 180 | The purpose of the package is to publish a complex ROS2 message and demonstrate how Micro-ROS layers (rcl, typesupport and rmw) handle it. 181 | For each publication, the message values increases in one unit order to see in the subscriber side the message variations. 182 | 183 | ##### Complex_msg_subscriber 184 | 185 | The purpose of the package is to subscribe to a complex ROS2 message and demonstrate how Micro-ROS layers (rcl, typesupport and rmw) handle it. 186 | 187 | #### Run complex demonstration (Linux) 188 | 189 | 190 | Run the micro-ROS Agent 191 | 192 | ```bash 193 | cd ~/agent_ws/install/uros_agent/lib/uros_agent/ 194 | ./uros_agent udp 8888 195 | ``` 196 | 197 | You may prefer to run the Agent in the background and discard all outputs to keep using the same terminal for the next step. 198 | 199 | ```bash 200 | cd ~/agent_ws/install/uros_agent/lib/uros_agent/ 201 | ./uros_agent udp 8888 > /dev/null & 202 | ``` 203 | 204 | Run the publisher. 205 | 206 | ```bash 207 | ~/client_ws/install/complex_msg_publisher_c/lib/complex_msg_publisher_c/./complex_msg_publisher_c 208 | ``` 209 | 210 | You may prefer to run the Agent in the background and discard all outputs to keep using the same terminal for the next step. 211 | 212 | ```bash 213 | ~/client_ws/install/complex_msg_publisher_c/lib/complex_msg_publisher_c/./complex_msg_publisher_c > /dev/null & 214 | ``` 215 | 216 | Run the subscriber. 217 | 218 | ```bash 219 | ~/client_ws/install/complex_msg_subscriber_c/lib/complex_msg_subscriber_c/./complex_msg_subscriber_c 220 | ``` 221 | 222 | #### Run complex demonstration (Windows) 223 | 224 | Run the micro-ROS Agent. 225 | For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder. 226 | 227 | ```bash 228 | cd C:\A\install\Lib\uros_agent\ 229 | uros_agent.exe udp 8888 230 | ``` 231 | 232 | Run the publisher. 233 | 234 | ```bash 235 | cd C:\C\install\Lib\complex_msg_publisher_c\ 236 | complex_msg_publisher_c.exe 237 | ``` 238 | 239 | Run the subscriber. 240 | 241 | ```bash 242 | cd C:\C\install\Lib\complex_msg_subscriber_c\ 243 | complex_msg_subscriber_c.exe 244 | ``` 245 | 246 | 247 | ### Real application demonstration 248 | 249 | This purpose of the packages is to demonstrate Micro-ROS stack can be used in a real application scenario. 250 | In this demonstration, an altitude control system is simulated. 251 | The primary purpose of this is to demonstrate how Micro-ROS communicates with ROS2 nodes. 252 | 253 | #### Real application packages 254 | 255 | ##### rad0_actuator 256 | 257 | The mission of this node is to simulate a dummy engine power actuator. 258 | It receives power increments and publishes the total power amount as a DDS topic. 259 | 260 | The node is built using the Micro-ROS middleware packages (rmw_micro_xrcedds and rosidl_typesupport_microxrcedds). 261 | 262 | It is meant to be running in a microcontroller processor, but for this demonstration, the node runs on the host PC. 263 | The node is connected to the DDS world through a Micro XRCE-DDS Agent. 264 | 265 | ##### rad0_altitude_sensor 266 | 267 | The mission of this node is to simulate a dummy altitude sensor. 268 | It publishes the altitude variations as a DDS topic. 269 | 270 | The node is built using the Micro-ROS middleware packages (rmw_micro_xrcedds and rosidl_typesupport_microxrcedds). 271 | 272 | It is meant to be running in a microcontroller processor, but for this demonstration, the node runs on the host PC. 273 | The node is connected to the DDS world through a Micro XRCE-DDS Agent. 274 | 275 | ##### rad0_control 276 | 277 | The mission of this node is to read altitude values and send to the actuator engine variations. 278 | It also publishes the status (OK, WARNING or FAILURE) as a DDS topic. 279 | The status depends on the altitude value. 280 | 281 | The node is built using the ROS2 middleware packages (rmw_fastrtps and rosidl_typesupport_fastrtps). 282 | 283 | It is meant to be running in on a regular PC, and it is directly connected to de DDS world. 284 | 285 | ##### rad0_display 286 | 287 | The mission of this node is to simulate one LCD screen that prints the critical parameters. 288 | It subscribes to the altitude, power and status messages available as a DDS topic. 289 | 290 | The node is built using the Micro-ROS middleware packages (rmw_micro_xrcedds and rosidl_typesupport_microxrcedds). 291 | 292 | It is meant to be running in a microcontroller processor, but for this demonstration, the node runs on the host PC. 293 | The node is connected to the DDS world through a Micro XRCE-DDS Agent. 294 | 295 | #### Run real application demonstration (Linux) 296 | 297 | ##### Micro-ROS nodes 298 | 299 | Run the micro-ROS Agent. 300 | For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder. 301 | 302 | ```bash 303 | cd ~/uros_WS/install/uros_agent/lib/uros_agent/ 304 | ./uros_agent udp 8888 305 | ``` 306 | 307 | You may prefer to run the Agent in the background and discard all outputs to keep using the same terminal for the next step. 308 | 309 | ```bash 310 | cd ~/uros_WS/install/uros_agent/lib/uros_agent/ 311 | ./uros_agent udp 8888 > /dev/null & 312 | ``` 313 | 314 | Run the altitude_sensor node. 315 | 316 | ```bash 317 | ~/client_ws/install/rad0_altitude_sensor_c/lib/rad0_altitude_sensor_c/./rad0_altitude_sensor_c 318 | ``` 319 | 320 | You may prefer to run the publisher in the background and discard all outputs to keep using the terminal for the next steps. 321 | 322 | ```bash 323 | ~/client_ws/install/rad0_altitude_sensor_c/lib/rad0_altitude_sensor_c/./rad0_altitude_sensor_c > /dev/null & 324 | ``` 325 | 326 | Run the actuator node. 327 | 328 | ```bash 329 | ~/client_ws/install/rad0_actuator_c/lib/rad0_actuator_c/./rad0_actuator_c 330 | ``` 331 | 332 | You may prefer to run the publisher in the background and discard all outputs to keep using the terminal for the next steps. 333 | 334 | ```bash 335 | ~/client_ws/install/rad0_actuator_c/lib/rad0_actuator_c/./rad0_actuator_c > /dev/null & 336 | ``` 337 | 338 | Run the display node. 339 | 340 | ```bash 341 | ~/client_ws/install/rad0_display_c/lib/rad0_display_c/./rad0_display_c 342 | ``` 343 | 344 | ##### ROS2 nodes 345 | 346 | ```bash 347 | ~/agent_ws/install/rad0_display_c/lib/rad0_display_c/./rad0_display_c 348 | ``` 349 | 350 | #### Run real application demonstration (Windows) 351 | 352 | ##### Micro-ROS nodes 353 | 354 | Run the micro-ROS Agent. 355 | For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder. 356 | 357 | ```bash 358 | cd C:\A\install\Lib\uros_agent\ 359 | uros_agent.exe udp 8888 360 | ``` 361 | 362 | Run the altitude_sensor node. 363 | 364 | ```bash 365 | cd C:\C\install\Lib\rad0_altitude_sensor_c 366 | rad0_altitude_sensor_c.exe 367 | ``` 368 | 369 | Run the actuator node. 370 | 371 | ```bash 372 | cd C:\C\install\Lib\rad0_actuator_c 373 | rad0_actuator_c.exe 374 | ``` 375 | 376 | Run the display node. 377 | 378 | ```bash 379 | cd C:\C\install\Lib\rad0_display_c\ 380 | rad0_display_c.exe 381 | ``` 382 | 383 | ##### ROS2 nodes 384 | 385 | ```bash 386 | cd C:\A\install\Lib\rad0_control_cpp\ 387 | rad0_control_cpp.exe 388 | ``` 389 | 390 | 391 | ## Purpose of the Project 392 | 393 | This software is not ready for production use. It has neither been developed nor 394 | tested for a specific use case. However, the license conditions of the 395 | applicable Open Source licenses allow you to adapt the software to your needs. 396 | Before using it in a safety relevant setting, make sure that the software 397 | fulfills your requirements and adjust it according to any applicable safety 398 | standards, e.g., ISO 26262. 399 | 400 | ## License 401 | 402 | This repository is open-sourced under the Apache-2.0 license. See the [LICENSE](LICENSE) file for details. 403 | 404 | 405 | For a list of other open-source components included in this repository, 406 | see the file [3rd-party-licenses.txt](3rd-party-licenses.txt). 407 | 408 | ## Known Issues/Limitations 409 | 410 | There are no known limitations. 411 | --------------------------------------------------------------------------------