### Conditional Installation of Examples Source: https://github.com/eprosima/fast-dds/blob/master/CMakeLists.txt Installs example code if the INSTALL_EXAMPLES option is enabled. Excludes CMakeLists.txt from examples directory. ```cmake option(INSTALL_EXAMPLES "Install example" OFF) if(INSTALL_EXAMPLES) # Install examples install(DIRECTORY ${PROJECT_SOURCE_DIR}/examples/cpp DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples COMPONENT ${DATA_INSTALL_DIR}/fastdds/examples PATTERN "examples/CMakeLists.txt" EXCLUDE ) endif() ``` -------------------------------- ### Navigate to Fast DDS Examples Source: https://github.com/eprosima/fast-dds/blob/master/README.md Use this command to navigate to the directory containing all Fast DDS examples. ```bash $ goToExamples ``` -------------------------------- ### XML File Discovery and Installation Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/CMakeLists.txt Finds all .xml files in the current source directory, copies them to the build directory, and installs them to the specified destination. ```cmake # Copy the XML files over to the build directory file(GLOB_RECURSE XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.xml) # for each xml file detected foreach(XML_FILE_COMPLETE_PATH ${XML_FILES}) # obtain the file name get_filename_component(XML_FILE ${XML_FILE_COMPLETE_PATH} NAME_WE) # copy the file from src to build folders configure_file( ${XML_FILE_COMPLETE_PATH} # from full src path ${CMAKE_CURRENT_BINARY_DIR}/${XML_FILE}.xml # to relative build path COPYONLY) install(FILES ${XML_FILE_COMPLETE_PATH} DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/hello_world/${BIN_INSTALL_DIR}) endforeach() ``` -------------------------------- ### Run Hello World Example (Publisher/Subscriber) Source: https://github.com/eprosima/fast-dds/blob/master/README.md Launches the 'Hello World' example, which includes a publisher and subscriber, within a single terminal session using tmux. This demonstrates basic Fast DDS communication. ```bash $ goToExamples $ cd hello_world/bin $ tmux new-session "./hello_world publisher" \; \ split-window "./hello_world subscriber" \; select-layout even-vertical ``` -------------------------------- ### Define Installation Paths Source: https://github.com/eprosima/fast-dds/blob/master/CMakeLists.txt Configures installation directories for various project artifacts like binaries, headers, libraries, data, and documentation. Includes platform-specific logic for Windows. ```cmake option(APPEND_PROJECT_NAME_TO_INCLUDEDIR "When ON headers are installed to a path ending with a folder called ${PROJECT_NAME}. This avoids include directory search order issues when overriding this package from a merged catkin, ament, or colcon workspace." OFF) set(BIN_INSTALL_DIR bin/ CACHE PATH "Installation directory for binaries") set(_include_dir "include/") if(APPEND_PROJECT_NAME_TO_INCLUDEDIR) string(APPEND _include_dir "${PROJECT_NAME}/") endif() set(INCLUDE_INSTALL_DIR "${_include_dir}" CACHE PATH "Installation directory for C++ headers") unset(_include_dir) set(LIB_INSTALL_DIR lib${LIB_SUFFIX}/ CACHE PATH "Installation directory for libraries") set(DATA_INSTALL_DIR share/ CACHE PATH "Installation directory for data") if(WIN32) set(DOC_DIR "doc") else() set(DOC_DIR "${DATA_INSTALL_DIR}/doc") endif() set(DOC_INSTALL_DIR ${DOC_DIR} CACHE PATH "Installation directory for documentation") set(LICENSE_INSTALL_DIR ${DATA_INSTALL_DIR}/${PROJECT_NAME} CACHE PATH "Installation directory for licenses") ``` -------------------------------- ### Copy and Install XML Configuration Files Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/rtps/CMakeLists.txt Locates all XML files in the current source directory, copies them to the build directory, and installs them to the runtime destination. This ensures that necessary configuration files are available for the RTPS examples. ```cmake file(GLOB_RECURSE XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.xml) # for each xml file detected foreach(XML_FILE_COMPLETE_PATH ${XML_FILES}) # obtain the file name get_filename_component(XML_FILE ${XML_FILE_COMPLETE_PATH} NAME_WE) # copy the file from src to build folders configure_file( ${XML_FILE_COMPLETE_PATH} # from full src path ${CMAKE_CURRENT_BINARY_DIR}/${XML_FILE}.xml # to relative build path COPYONLY) install(FILES ${XML_FILE_COMPLETE_PATH} DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/rtps/${BIN_INSTALL_DIR}) endforeach() ``` -------------------------------- ### Copy and Install XML Configuration Files Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/benchmark/CMakeLists.txt Finds all XML files in the current source directory and its subdirectories, copies them to the build directory, and installs them to the runtime destination. ```cmake file(GLOB_RECURSE XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.xml) # for each xml file detected foreach(XML_FILE_COMPLETE_PATH ${XML_FILES}) # obtain the file name get_filename_component(XML_FILE ${XML_FILE_COMPLETE_PATH} NAME_WE) # copy the file from src to build folders configure_file( ${XML_FILE_COMPLETE_PATH} # from full src path ${CMAKE_CURRENT_BINARY_DIR}/${XML_FILE}.xml # to relative build path COPYONLY) install(FILES ${XML_FILE_COMPLETE_PATH} DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/benchmark/${BIN_INSTALL_DIR}) endforeach() ``` -------------------------------- ### Install Executable Source: https://github.com/eprosima/fast-dds/blob/master/tools/fds/CMakeLists.txt Installs the discovery server executable to the configured runtime destination. It's assigned to the 'discovery' component. ```cmake install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_INSTALL_DIR}${MSVCARCH_DIR_EXTENSION} COMPONENT discovery ) ``` -------------------------------- ### Install License File Source: https://github.com/eprosima/fast-dds/blob/master/CMakeLists.txt Installs the project's LICENSE file to the specified installation directory. ```cmake install(FILES ${PROJECT_SOURCE_DIR}/LICENSE DESTINATION ${LICENSE_INSTALL_DIR} COMPONENT licenses ) ``` -------------------------------- ### Run Hello World Publisher Source: https://github.com/eprosima/fast-dds/blob/master/README.md Executes the 'Hello World' publisher example. This is useful for testing communication between multiple container instances. ```bash $ goToExamples $ cd hello_world/bin $ ./hello_world publisher ``` -------------------------------- ### Linking Libraries and Installation Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/CMakeLists.txt Links the 'hello_world' executable against the Fast DDS and Fast CDR libraries and specifies the installation directory for the executable. ```cmake target_link_libraries(hello_world fastdds fastcdr) install(TARGETS hello_world RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/hello_world/${BIN_INSTALL_DIR}) ``` -------------------------------- ### Copy and Install XML Configuration Files Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/topic_instances/CMakeLists.txt This snippet finds all XML files in the current source directory, copies them to the build directory, and installs them to the runtime destination. ```cmake # Copy the XML files over to the build directory file(GLOB_RECURSE XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.xml) # for each xml file detected foreach(XML_FILE_COMPLETE_PATH ${XML_FILES}) # obtain the file name get_filename_component(XML_FILE ${XML_FILE_COMPLETE_PATH} NAME_WE) # copy the file from src to build folders configure_file( ${XML_FILE_COMPLETE_PATH} # from full src path ${CMAKE_CURRENT_BINARY_DIR}/${XML_FILE}.xml # to relative build path COPYONLY) install(FILES ${XML_FILE_COMPLETE_PATH} DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/topic_instances/${BIN_INSTALL_DIR}) endforeach() ``` -------------------------------- ### Install Benchmark Executable Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/benchmark/CMakeLists.txt Installs the compiled benchmark executable to the specified runtime destination directory. ```cmake install(TARGETS benchmark RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/benchmark/${BIN_INSTALL_DIR}) ``` -------------------------------- ### Install RTPS Executable Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/rtps/CMakeLists.txt Installs the compiled 'rtps' executable to a specified runtime destination. This makes the example runnable after installation. ```cmake install(TARGETS rtps RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/rtps/${BIN_INSTALL_DIR} ) ``` -------------------------------- ### Run X-Types Publisher (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/xtypes/README.md Launches the X-Types publisher application. Ensure you are in the example directory. ```shell user@machine:example_path$ ./xtypes publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Configure Topic Instances Example Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/topic_instances/CMakeLists.txt This snippet configures the build for the topic instances example, finding dependencies, checking C++11 support, and setting the default build type. ```cmake cmake_minimum_required(VERSION 3.22) # TODO 3.28 project(fastdds_topic_instances_example VERSION 1 LANGUAGES CXX) # Find requirements if(NOT fastcdr_FOUND) find_package(fastcdr 2 REQUIRED) endif() if(NOT fastdds_FOUND) find_package(fastdds 3 REQUIRED) endif() #Check C++11 include(CheckCXXCompilerFlag) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11) check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11) if(NOT SUPPORTS_CXX11) message(FATAL_ERROR "Compiler doesn't support C++11") endif() endif() # Set CMAKE_BUILD_TYPE to Release by default. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() message(STATUS "Configuring topic instances example...") ``` -------------------------------- ### Run X-Types Subscriber (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/xtypes/README.md Launches the X-Types subscriber application. Ensure you are in the example directory. ```shell user@machine:example_path$ ./xtypes subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Copy and Install XML Configuration Files Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/flow_control/CMakeLists.txt Finds all XML files in the current source directory and its subdirectories, copies them to the build directory, and installs them to the runtime destination. This ensures that necessary configuration files are available at runtime. ```cmake # Copy the XML files over to the build directory file(GLOB_RECURSE XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.xml) # for each xml file detected foreach(XML_FILE_COMPLETE_PATH ${XML_FILES}) # obtain the file name get_filename_component(XML_FILE ${XML_FILE_COMPLETE_PATH} NAME_WE) # copy the file from src to build folders configure_file( ${XML_FILE_COMPLETE_PATH} # from full src path ${CMAKE_CURRENT_BINARY_DIR}/${XML_FILE}.xml # to relative build path COPYONLY) install(FILES ${XML_FILE_COMPLETE_PATH} DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/flow_control/${BIN_INSTALL_DIR}) endforeach() ``` -------------------------------- ### Run Hello World Publisher (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/README.md Execute the publisher application in a terminal. This command starts the DDS publisher. ```shell user@machine:example_path$ ./hello_world publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Install Flow Control Executable Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/flow_control/CMakeLists.txt Installs the compiled 'flow_control' executable to the specified runtime directory. This makes the example runnable after installation. ```cmake install(TARGETS flow_control RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/flow_control/${BIN_INSTALL_DIR}) ``` -------------------------------- ### Install Topic Instances Executable Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/topic_instances/CMakeLists.txt Installs the compiled topic instances executable to the specified runtime destination. ```cmake install(TARGETS topic_instances RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/topic_instances/${BIN_INSTALL_DIR}) ``` -------------------------------- ### Run Hello World Subscriber Source: https://github.com/eprosima/fast-dds/blob/master/README.md Executes the 'Hello World' subscriber example. This is useful for testing communication between multiple container instances. ```bash $ goToExamples $ cd hello_world/bin $ ./hello_world subscriber ``` -------------------------------- ### Run Configuration Publisher (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/configuration/README.md Execute the publisher application on Ubuntu or MacOS. Ensure you are in the example directory. ```shell user@machine:example_path$ ./configuration publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Hello World Publisher (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/README.md Execute the publisher application in a Windows command prompt. This command starts the DDS publisher. ```shell example_path> hello_world.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Benchmark Publisher Output Example Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/benchmark/README.md Example output from the benchmark publisher, showing sample transmission, reception, and final throughput results. This output is generated after the specified number of samples or duration. ```shell Publisher running for 500 samples. Please press Ctrl+C to stop the Publisher at any time. Subscriber matched. Publisher matched. First Sample with index: '0' (Array 8388608 Bytes) SENT Sample with index: '1' (Array 8388608 Bytes) RECEIVED Sample with index: '2' (Array 8388608 Bytes) SENT Sample with index: '3' (Array 8388608 Bytes) RECEIVED Sample with index: '4' (Array 8388608 Bytes) SENT Sample with index: '5' (Array 8388608 Bytes) RECEIVED ... Sample with index: '499' (Array 8388608 Bytes) RECEIVED Sample with index: '500' (Array 8388608 Bytes) SENT Publisher unmatched. Subscriber unmatched. RESULTS after 1206 milliseconds: COUNT: 500 SAMPLES: 41,46,44,42,44,42,52,46,48,44,48,4, THROUGHPUT BPS(Bytes per Second): 3.48482 Gbps ... ``` -------------------------------- ### Install Docker Source: https://github.com/eprosima/fast-dds/blob/master/README.md Command to install Docker on Ubuntu systems. Ensure Docker is installed before proceeding with Docker image operations. ```bash $ sudo apt-get install docker.io ``` -------------------------------- ### Configure Example Type Profile XML Source: https://github.com/eprosima/fast-dds/blob/master/test/dds/communication/CMakeLists.txt Copies the example type profile XML file to the build directory. This file is necessary for certain DDS communication configurations. ```cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/example_type_profile.xml ${CMAKE_CURRENT_BINARY_DIR}/example_type_profile.xml COPYONLY) ``` -------------------------------- ### Run Configuration Publisher (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/configuration/README.md Execute the publisher application on Windows. Ensure you are in the example directory. ```powershell example_path> configuration.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Wait-Set Subscriber (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/README.md Launches the subscriber example using the wait-set approach instead of a listening callback. This is useful for specific synchronization patterns. ```shell user@machine:example_path$ ./hello_world subscriber --waitset ``` -------------------------------- ### Configure Fast DDS Content Filter Example Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/content_filter/CMakeLists.txt Sets up the CMake build for the content filter example. It finds required packages, configures the build type, and adds source files. ```cmake cmake_minimum_required(VERSION 3.22) # TODO 3.28 project(fastdds_content_filter_example VERSION 1 LANGUAGES CXX) # Find requirements if(NOT fastcdr_FOUND) find_package(fastcdr 2 REQUIRED) endif() if(NOT fastdds_FOUND) find_package(fastdds 3 REQUIRED) endif() # Set CMAKE_BUILD_TYPE to Release by default. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() message(STATUS "Configuring content filter example...") file(GLOB CONTENT_FILTER_SOURCES_CXX "*.cxx") file(GLOB CONTENT_FILTER_SOURCES_CPP "*.cpp") add_executable(content_filter ${CONTENT_FILTER_SOURCES_CXX} ${CONTENT_FILTER_SOURCES_CPP}) target_compile_definitions(content_filter PRIVATE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) target_compile_features(content_filter PRIVATE cxx_std_11) target_link_libraries(content_filter fastdds fastcdr fastdds::optionparser) install(TARGETS content_filter RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/content_filter/${BIN_INSTALL_DIR}) ``` -------------------------------- ### Run Hello World Subscriber (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/README.md Execute the subscriber application in a terminal. This command starts the DDS subscriber. ```shell user@machine:example_path$ ./hello_world subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Install AllocationTest Executable Source: https://github.com/eprosima/fast-dds/blob/master/test/profiling/allocations/CMakeLists.txt Installs the AllocationTest executable to the specified runtime destination. ```cmake install(TARGETS AllocationTest RUNTIME DESTINATION test/profiling/allocations/${BIN_INSTALL_DIR}) ``` -------------------------------- ### Installation Directory Configuration Source: https://github.com/eprosima/fast-dds/blob/master/tools/fds/CMakeLists.txt Sets the installation directory for the discovery server binary. It differs based on whether the build is isolated or part of the main Fast DDS project. ```cmake # If not isolated integrate if(CMAKE_PROJECT_NAME STREQUAL "fastdds" ) set(BIN_INSTALL_DIR tools/fds/${BIN_INSTALL_DIR} CACHE PATH "Installation directory for binaries within Fast DDS") else() set(BIN_INSTALL_DIR bin/ CACHE PATH "Installation directory for binaries") endif() ``` -------------------------------- ### Conditional Installation of Documentation Source: https://github.com/eprosima/fast-dds/blob/master/CMakeLists.txt Installs Doxygen API reference and manual documentation if BUILD_DOCUMENTATION is enabled. Manual documentation is skipped if CHECK_DOCUMENTATION is not set. ```cmake if(BUILD_DOCUMENTATION) # Instalation of doxygen files install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/api_reference DESTINATION ${DOC_INSTALL_DIR} COMPONENT documentation ) if(NOT CHECK_DOCUMENTATION) install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/manual DESTINATION ${DOC_INSTALL_DIR} COMPONENT documentation ) endif() endif() ``` -------------------------------- ### Run Static EDP Discovery Publisher (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/static_edp_discovery/README.md Execute the publisher application in a Linux or macOS environment. Ensure you are in the example's directory. ```shell user@machine:example_path$ ./static_edp_discovery publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run X-Types Publisher (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/xtypes/README.md Launches the X-Types publisher application on Windows. Ensure you are in the example directory. ```shell example_path> xtypes.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Benchmark Subscriber Output Example Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/benchmark/README.md Example output from the benchmark subscriber, showing sample reception and transmission acknowledgments. This output reflects the data received from the publisher. ```shell Publisher matched. Subscriber matched. Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. Sample with index: '0' (Array 8388608 Bytes) RECEIVED Sample with index: '1' (Array 8388608 Bytes) SENT Sample with index: '2' (Array 8388608 Bytes) RECEIVED Sample with index: '3' (Array 8388608 Bytes) SENT Sample with index: '4' (Array 8388608 Bytes) RECEIVED Sample with index: '5' (Array 8388608 Bytes) SENT ... Sample with index: '499' (Array 8388608 Bytes) SENT Sample with index: '500' (Array 8388608 Bytes) RECEIVED ... ``` -------------------------------- ### Run Configuration Subscriber (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/configuration/README.md Execute the subscriber application on Ubuntu or MacOS. Ensure you are in the example directory. ```shell user@machine:example_path$ ./configuration subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run Wait-Set Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/README.md Launches the subscriber example using the wait-set approach on Windows. This method is an alternative to standard callback listening. ```batch example_path> hello_world.exe subscriber --waitset ``` -------------------------------- ### Run Static EDP Discovery Publisher (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/static_edp_discovery/README.md Execute the publisher application in a Windows environment. Ensure you are in the example's directory. ```powershell example_path> static_edp_discovery.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Hello World Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/README.md Execute the subscriber application in a Windows command prompt. This command starts the DDS subscriber. ```shell example_path> hello_world.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run X-Types Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/xtypes/README.md Launches the X-Types subscriber application on Windows. Ensure you are in the example directory. ```shell example_path> xtypes.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run Discovery Server Publisher (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/discovery_server/README.md Launches the Discovery Server publisher client on Ubuntu or macOS. Ensure the Discovery Server is running before starting clients. ```shell user@machine:example_path$ ./discovery_server publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Benchmark Publisher (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/benchmark/README.md Execute the benchmark publisher application on Ubuntu or macOS. This command starts the publisher, which will run for a specified duration or until interrupted. ```shell user@machine:example_path$ ./benchmark publisher Publisher running for 10000 milliseconds. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Delivery Mechanisms Publisher (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/delivery_mechanisms/README.md Launches the publisher application for the delivery mechanisms example on Ubuntu or MacOS systems. Ensure the executable is in the current directory. ```shell user@machine:example_path$ ./delivery_mechanisms publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Discovery Server Publisher (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/discovery_server/README.md Launches the Discovery Server publisher client on Windows. Ensure the Discovery Server is running before starting clients. ```shell example_path> discovery_server.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Install QNX Test Binaries Source: https://github.com/eprosima/fast-dds/blob/master/test/CMakeLists.txt Installs test binaries to the QNX target environment, excluding specific file types like CMake files, object files, and build artifacts. This ensures only necessary executable components are deployed. ```cmake if(EPROSIMA_BUILD_TESTS AND QNX) install(DIRECTORY ${PROJECT_BINARY_DIR}/test/ DESTINATION bin/Fast-DDS_test PATTERN "*.cmake" EXCLUDE PATTERN "*.d" EXCLUDE PATTERN "*.dir" EXCLUDE PATTERN "*.internal" EXCLUDE PATTERN "*.make" EXCLUDE PATTERN "*.marks" EXCLUDE PATTERN "*.o" EXCLUDE PATTERN "*.ts" EXCLUDE PATTERN "*.txt" EXCLUDE PATTERN "CMakeFiles" EXCLUDE PATTERN "Makefile" EXCLUDE PATTERN "cmake" EXCLUDE ) install(DIRECTORY ${PROJECT_SOURCE_DIR}/test/certs DESTINATION bin/Fast-DDS_test ) ``` -------------------------------- ### Run Configuration Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/configuration/README.md Execute the subscriber application on Windows. Ensure you are in the example directory. ```powershell example_path> configuration.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Configuration Publisher Expected Output Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/configuration/README.md This is the expected output for the publisher when running the configuration example, showing matched status and sent samples. ```shell Publisher running. Please press Ctrl+C to stop the Publisher at any time. Publisher matched. Sample: 'Configuration' with index: '1' (10 Bytes) SENT Sample: 'Configuration' with index: '2' (10 Bytes) SENT Sample: 'Configuration' with index: '3' (10 Bytes) SENT ... ``` -------------------------------- ### Run Static EDP Discovery Subscriber (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/static_edp_discovery/README.md Execute the subscriber application in a Linux or macOS environment. Ensure you are in the example's directory. ```shell user@machine:example_path$ ./static_edp_discovery subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### X-Types Publisher Expected Output Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/xtypes/README.md Example output from the X-Types publisher, showing it running and sending messages. ```shell Publisher running for 10 samples. Please press Ctrl+C to stop the Publisher at any time. Publisher matched. Message sent: - index: 1 - message: 'Hello xtypes world' Message sent: - index: 2 - message: 'Hello xtypes world' Message sent: - index: 3 - message: 'Hello xtypes world' ... ``` -------------------------------- ### Run Benchmark Subscriber (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/benchmark/README.md Execute the benchmark subscriber application on Ubuntu or macOS. This command starts the subscriber, which will listen for messages from the publisher. ```shell user@machine:example_path$ ./benchmark subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run Delivery Mechanisms PubSub (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/delivery_mechanisms/README.md Launches the pubsub application for the delivery mechanisms example on Windows systems. Ensure the executable is in the current directory. ```powershell example_path> delivery_mechanisms.exe pubsub PubSub running. Please press Ctrl+C to stop the PubSub at any time. ``` -------------------------------- ### Run Delivery Mechanisms Publisher (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/delivery_mechanisms/README.md Launches the publisher application for the delivery mechanisms example on Windows systems. Ensure the executable is in the current directory. ```powershell example_path> delivery_mechanisms.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Discovery Server Subscriber (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/discovery_server/README.md Launches the Discovery Server subscriber client on Ubuntu or macOS. Ensure the Discovery Server is running before starting clients. ```shell user@machine:example_path$ ./discovery_server subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run Static EDP Discovery Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/static_edp_discovery/README.md Execute the subscriber application in a Windows environment. Ensure you are in the example's directory. ```powershell example_path> static_edp_discovery.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run Discovery Server Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/discovery_server/README.md Launches the Discovery Server subscriber client on Windows. Ensure the Discovery Server is running before starting clients. ```shell example_path> discovery_server.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run Delivery Mechanisms PubSub (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/delivery_mechanisms/README.md Launches the pubsub application for the delivery mechanisms example on Ubuntu or MacOS systems. Ensure the executable is in the current directory. ```shell user@machine:example_path$ ./delivery_mechanisms pubsub PubSub running. Please press Ctrl+C to stop the PubSub at any time. ``` -------------------------------- ### Run Benchmark Publisher (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/benchmark/README.md Execute the benchmark publisher application on Windows. This command starts the publisher, which will run for a specified duration or until interrupted. ```powershell example_path> benchmark.exe publisher Publisher running for 10000 milliseconds. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### CMake Minimum Version and Project Setup Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/hello_world/CMakeLists.txt Specifies the minimum required CMake version and defines the project name, version, and language. ```cmake cmake_minimum_required(VERSION 3.22) # TODO 3.28 project(fastdds_hello_world_example VERSION 1 LANGUAGES CXX) ``` -------------------------------- ### Run Delivery Mechanisms Subscriber (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/delivery_mechanisms/README.md Launches the subscriber application for the delivery mechanisms example on Ubuntu or MacOS systems. Ensure the executable is in the current directory. ```shell user@machine:example_path$ ./delivery_mechanisms subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### LatencyTest publisher node example Source: https://github.com/eprosima/fast-dds/blob/master/test/performance/latency/README.md Command to run the LatencyTest utility as a publisher node. It configures reliability, domain, shared memory, and specifies a demands file. ```bash LatenchTest publisher --reliability=besteffort --domain 0 --shared_memory=off --file=demands.csv ``` -------------------------------- ### Run Benchmark Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/benchmark/README.md Execute the benchmark subscriber application on Windows. This command starts the subscriber, which will listen for messages from the publisher. ```powershell example_path> benchmark.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run Delivery Mechanisms Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/delivery_mechanisms/README.md Launches the subscriber application for the delivery mechanisms example on Windows systems. Ensure the executable is in the current directory. ```powershell example_path> delivery_mechanisms.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Install Public Headers in CMake Source: https://github.com/eprosima/fast-dds/blob/master/src/cpp/CMakeLists.txt Installs public header files for the project. It specifies the source directory, destination, component, and file patterns to match for installation. ```cmake install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME} DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT headers FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "*.ipp" ) # Install config.hpp header install(FILES ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/config.hpp DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME} COMPONENT headers ) ``` -------------------------------- ### Batch Testing with Demands Source: https://github.com/eprosima/fast-dds/blob/master/test/performance/throughput/README.md Illustrates batch testing with a file specifying different demands. This example executes four tests with varying sample sizes and burst counts. ```bash 16;100;1000 32;100;1000 ``` -------------------------------- ### Install XML Validators Source: https://github.com/eprosima/fast-dds/blob/master/CMakeLists.txt Installs XML schema files for Fast DDS profiles and static discovery. ```cmake install(FILES ${PROJECT_SOURCE_DIR}/resources/xsd/fastdds_profiles.xsd DESTINATION ${DATA_INSTALL_DIR}/fastdds COMPONENT xsd ) ``` ```cmake install(FILES ${PROJECT_SOURCE_DIR}/resources/xsd/fastdds_static_discovery.xsd DESTINATION ${DATA_INSTALL_DIR}/fastdds COMPONENT xsd ) ``` -------------------------------- ### LatencyTest subscriber node example Source: https://github.com/eprosima/fast-dds/blob/master/test/performance/latency/README.md Command to run the LatencyTest utility as a subscriber node. It mirrors the publisher configuration for reliability, domain, shared memory, and demands file. ```bash LatenchTest subscriber --reliability=besteffort --domain 0 --shared_memory=off --file=demands.csv ``` -------------------------------- ### Conditional Installation of Tools Source: https://github.com/eprosima/fast-dds/blob/master/CMakeLists.txt Installs project tools if the INSTALL_TOOLS option is enabled. Excludes CMakeLists.txt from tools directory. ```cmake option(INSTALL_TOOLS "Install tools" OFF) if(INSTALL_TOOLS) # Install tools install(DIRECTORY ${PROJECT_SOURCE_DIR}/tools/ DESTINATION tools COMPONENT tools PATTERN "tools/CMakeLists.txt" EXCLUDE ) endif() ``` -------------------------------- ### Run Secure Hello World Publisher (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/security/README.md Launches the secure publisher application. The publisher will not send data until a subscriber is discovered. ```shell user@machine:example_path$ ./security publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Secure Hello World Subscriber (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/security/README.md Launches the secure subscriber application. It will wait for a publisher to send data. ```shell user@machine:example_path$ ./security subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Throughput Test Results Example Source: https://github.com/eprosima/fast-dds/blob/master/test/performance/throughput/README.md An example of the tabular output from the throughput test utility, displaying performance metrics for publisher and subscriber nodes. ```text [ TEST ][ PUBLISHER ][ SUBSCRIBER ] [ Bytes,Demand,Recovery Time][Sent Samples,Send Time(us), Packs/sec, MBits/sec][Rec Samples,Lost Samples,Rec Time(us), Packs/sec, MBits/sec] [------,------,-------------][------------,-------------,------------,-----------][-----------,------------,------------,------------,-----------] 1024, 10000, 5, 410000, 1015633, 403689.138, 3307.021, 410000, 0, 1022114, 401129.377, 3286.052 ``` -------------------------------- ### Configure Android Test Installation Source: https://github.com/eprosima/fast-dds/blob/master/test/CMakeLists.txt Sets up an option to install Android tests to a device and conditionally executes a script to prepare the testing environment. This involves modifying CTest configuration files and pushing test binaries via ADB. ```cmake if (ANDROID) option(INSTALL_ANDROID_TESTS "Install Built Tests to Device" OFF) if (INSTALL_ANDROID_TESTS) install(CODE "set(ANDROID \"${ANDROID}\") set(ANDROID_TESTING_ROOT \"${ANDROID_TESTING_ROOT}\") set(CMAKE_BINARY_DIR \"${CMAKE_BINARY_DIR}\") message(STATUS \"Android testing ROOT is '${ANDROID_TESTING_ROOT}'\") if(ANDROID_TESTING_ROOT) file(GLOB_RECURSE CTEST_GENERATED_FILES RELATIVE \"${CMAKE_BINARY_DIR}\" \"CTestTestfile.cmake\") foreach(CTEST_FILE ${CTEST_GENERATED_FILES}) file(READ ${CTEST_FILE} contents) message(STATUS \"Processing file ${CTEST_FILE}\") string(REGEX REPLACE "${CMAKE_BINARY_DIR}" "${ANDROID_TESTING_ROOT}" contents ${contents}) file(REMOVE ${CTEST_FILE}) file(WRITE ${CTEST_FILE} ${contents}) endforeach() endif() execute_process(COMMAND adb push \"${CMAKE_BINARY_DIR}/test\" \"${ANDROID_TESTING_ROOT}\") ") endif() endif() ``` -------------------------------- ### Run Secure Hello World Publisher (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/security/README.md Launches the secure publisher application. The publisher will not send data until a subscriber is discovered. ```powershell example_path> security.exe publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### X-Types Publisher Output After Subscriber Stops Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/xtypes/README.md Example output from the X-Types publisher when the subscriber application is stopped. ```shell ... Message sent: - index: 5 - message: 'Hello xtypes world' Message sent: - index: 6 - message: 'Hello xtypes world' Publisher unmatched. ``` -------------------------------- ### X-Types Subscriber Expected Output Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/xtypes/README.md Example output from the X-Types subscriber, showing it running and receiving messages. ```shell Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. Subscriber matched. Message received: - index: 1 - message: 'Hello xtypes world' Message received: - index: 2 - message: 'Hello xtypes world' Message received: - index: 3 - message: 'Hello xtypes world' ... ``` -------------------------------- ### Topic Instances Publisher (Ubuntu/MacOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/topic_instances/README.md Launches the publisher application on Ubuntu or MacOS. It registers instances for different shapes and sends samples. Press Ctrl+C to stop. ```shell user@machine:example_path$ ./topic_instances publisher Registering instance for RED shape Registering instance for BLUE shape Registering instance for GREEN shape Registering instance for YELLOW shape Publisher running. Please press Ctrl+C to stop the Publisher at any time. ``` -------------------------------- ### Run Secure Hello World Subscriber (Windows) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/security/README.md Launches the secure subscriber application. It will wait for a publisher to send data. ```powershell example_path> security.exe subscriber Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. ``` -------------------------------- ### Run Content Filter Publisher Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/content_filter/README.md Execute the content filter publisher application. It will start sending data once a subscriber is discovered. ```shell user@machine:example_path$ ./content_filter publisher Publisher running. Please press Ctrl+C to stop the Publisher at any time. Publisher matched. Message: 'Hello world' with index: '1' SENT Message: 'Hello world' with index: '2' SENT Message: 'Hello world' with index: '3' SENT ... ``` -------------------------------- ### Add Throughput Test Source: https://github.com/eprosima/fast-dds/blob/master/test/performance/throughput/CMakeLists.txt Configures a basic throughput test case using a Python script. This is the fundamental test setup. ```cmake add_test( NAME performance.throughput.${throughput_test_name} COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/throughput_tests.py --xml_file ${CMAKE_CURRENT_SOURCE_DIR}/xml/${throughput_test_name}.xml --recoveries_file ${CMAKE_CURRENT_SOURCE_DIR}/recoveries.csv --demands_file ${CMAKE_CURRENT_SOURCE_DIR}/payloads_demands.csv ${interproces_flag} ${reliability_flag} ) ``` -------------------------------- ### Configuration Subscriber Expected Output Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/configuration/README.md This is the expected output for the subscriber when running the configuration example, showing matched status and received samples. ```shell Subscriber running. Please press Ctrl+C to stop the Subscriber at any time. Subscriber matched. Sample: 'Configuration' with index: '1' (10 Bytes) RECEIVED Sample: 'Configuration' with index: '2' (10 Bytes) RECEIVED Sample: 'Configuration' with index: '3' (10 Bytes) RECEIVED ... ``` -------------------------------- ### Run LatencyTest with both roles Source: https://github.com/eprosima/fast-dds/blob/master/test/performance/latency/README.md Execute the LatencyTest utility with both publisher and subscriber roles simultaneously. This is a basic command to start a test node. ```bash LatencyTest both ``` -------------------------------- ### Configure Python Example Tests Source: https://github.com/eprosima/fast-dds/blob/master/test/examples/CMakeLists.txt Iterates through Python files to configure and add tests. It handles different compose file naming conventions and conditionally adds tests based on file existence. ```cmake file(GLOB examples_python_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.py) # Add security test only if security is enabled if (NOT SECURITY) list(FILTER examples_python_tests EXCLUDE REGEX "security") endif() # Configure the pytest files, and add a test for each one foreach(example_test ${examples_python_tests}) get_filename_component(example_name ${example_test} NAME_WE) string(REPLACE "test_" "" example_name "${example_name}") message(STATUS " Configuring example test: ${example_name}") configure_file(${example_test} ${CMAKE_CURRENT_BINARY_DIR}/${example_name}/${example_test} @ONLY) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${example_name}.compose.yml") configure_file(${example_name}.compose.yml ${CMAKE_CURRENT_BINARY_DIR}/${example_name}/${example_name}.compose.yml @ONLY) else() # Get base example name without suffix (e.g., -I) string(REGEX REPLACE "-.*$" "" base_example_name "${example_name}") if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${base_example_name}.compose.yml") configure_file(${base_example_name}.compose.yml ${CMAKE_CURRENT_BINARY_DIR}/${example_name}/${base_example_name}.compose.yml @ONLY) endif() endif() add_test(NAME example_tests.${example_name} COMMAND ${Python3_EXECUTABLE} -m pytest -vrP WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example_name}) endforeach() ``` -------------------------------- ### Python Launcher Setup Source: https://github.com/eprosima/fast-dds/blob/master/test/performance/throughput/README.md Set the THROUGHPUT_TEST_BIN environment variable to point to the location of the ThroughputTest utility executable when using the Python launcher. ```batch # Indicate where is the utility executable export THROUGHPUT_TEST_BIN=build/fastdds/test/performance/throughtput/ThroughputTest ``` -------------------------------- ### Run Discovery Server Server (Ubuntu/macOS) Source: https://github.com/eprosima/fast-dds/blob/master/examples/cpp/discovery_server/README.md Launches the Discovery Server application on Ubuntu or macOS. This acts as the central discovery hub. ```shell user@machine:example_path$ ./discovery_server server Subscriber running. Please press Ctrl+C to stop the Server at any time. ```