mirror of
https://github.com/BotChain-Robots/control.git
synced 2026-03-10 00:32:26 +01:00
Add more examples
This commit is contained in:
19
examples/bandwidth/CMakeLists.txt
Normal file
19
examples/bandwidth/CMakeLists.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
project(BandwidthExample)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(libcontrol REQUIRED)
|
||||
find_package(spdlog REQUIRED)
|
||||
find_package(librpc REQUIRED)
|
||||
|
||||
add_executable(BandwidthExample main.cpp)
|
||||
|
||||
target_link_libraries(BandwidthExample
|
||||
PRIVATE
|
||||
libcontrol::libcontrol
|
||||
spdlog::spdlog
|
||||
librpc::librpc
|
||||
)
|
||||
9
examples/bandwidth/CMakeUserPresets.json
Normal file
9
examples/bandwidth/CMakeUserPresets.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": 4,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/CMakePresets.json"
|
||||
]
|
||||
}
|
||||
10
examples/bandwidth/README.md
Normal file
10
examples/bandwidth/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Servo Example
|
||||
|
||||
## Compiling
|
||||
```
|
||||
conan install . --build=missing --output-folder=build -s build_type=Release
|
||||
cmake -S . -B "build" -DCMAKE_TOOLCHAIN_FILE="build/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE="Release"
|
||||
cmake --build "./build" --config "Release"
|
||||
|
||||
./build/BandwidthExample
|
||||
```
|
||||
4
examples/bandwidth/build.sh
Executable file
4
examples/bandwidth/build.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
conan install . --build=missing --output-folder=build -s build_type=Release
|
||||
cmake -S . -B "build" -DCMAKE_TOOLCHAIN_FILE="build/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE="Release"
|
||||
cmake --build "./build" --config "Release"
|
||||
|
||||
9
examples/bandwidth/conanfile.txt
Normal file
9
examples/bandwidth/conanfile.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
[requires]
|
||||
libcontrol/1.0.0
|
||||
flatbuffers/24.12.23
|
||||
spdlog/1.16.0
|
||||
librpc/1.1.7
|
||||
|
||||
[generators]
|
||||
CMakeDeps
|
||||
CMakeToolchain
|
||||
31
examples/bandwidth/main.cpp
Normal file
31
examples/bandwidth/main.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
#include <thread>
|
||||
|
||||
#include "libcontrol.h"
|
||||
|
||||
#define TARGET_MODULE 150
|
||||
#define METADATA_TAG 7
|
||||
|
||||
int main() {
|
||||
|
||||
const auto messaging_interface = std::make_unique<MessagingInterface>();
|
||||
|
||||
const auto modules = messaging_interface->find_connected_modules(std::chrono::seconds(3));
|
||||
|
||||
if (!modules.contains(TARGET_MODULE)) {
|
||||
std::cout << "Could not find target module " << TARGET_MODULE << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> vec(1024, 'A');
|
||||
|
||||
while (true) {
|
||||
messaging_interface->send(vec.data(), vec.size(), TARGET_MODULE, METADATA_TAG, false);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user