diff --git a/CMakeLists.txt b/CMakeLists.txt index e4a9a1b..bcec558 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,9 +22,18 @@ else() set(CMAKE_CXX_STANDARD 17) # Enable c++11 standard set(CMAKE_POSITION_INDEPENDENT_CODE ON) + include_directories( + . + LinearAlgebra + ) + add_library(RoboidControl STATIC ${srcs}) + project(RoboidControl) add_subdirectory(LinearAlgebra) - add_subdirectory(Examples) + + # Examples + option(BUILD_EXAMPLE_BB2A "Build BB2A Example" OFF) + add_subdirectory(examples) add_compile_definitions(GTEST) include(FetchContent) @@ -38,12 +47,6 @@ else() set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) - include_directories( - . - LinearAlgebra - ) - add_library(RoboidControl STATIC ${srcs}) - enable_testing() file(GLOB_RECURSE test_srcs test/*_test.cc) diff --git a/DoxyGen/Doxyfile b/DoxyGen/Doxyfile index 853c02a..d551ef0 100644 --- a/DoxyGen/Doxyfile +++ b/DoxyGen/Doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = "Roboid Control for C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = 0.4 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/Participant.cpp b/Participant.cpp index b8e0d16..dc02a15 100644 --- a/Participant.cpp +++ b/Participant.cpp @@ -67,7 +67,7 @@ bool Participant::Send(IMessage* msg) { #if defined(_WIN32) || defined(_WIN64) Windows::ParticipantUDP* thisWindows = static_cast(this); - return thisWindows->Send(remoteParticipant, bufferSize); + return thisWindows->Send(this, bufferSize); #elif defined(__unix__) || defined(__APPLE__) Posix::ParticipantUDP* thisPosix = static_cast(this); return thisPosix->Send(this, bufferSize); diff --git a/Participants/ParticipantUDP.cpp b/Participants/ParticipantUDP.cpp index fc99aae..06d3fed 100644 --- a/Participants/ParticipantUDP.cpp +++ b/Participants/ParticipantUDP.cpp @@ -232,7 +232,9 @@ void ParticipantUDP::SendThingInfo(Participant* remoteParticipant, bool ParticipantUDP::Send(IMessage* msg) { if (this->remoteSite != nullptr) - this->remoteSite->Send(msg); + return this->remoteSite->Send(msg); + + return true; } void ParticipantUDP::PublishThingInfo(Thing* thing) { diff --git a/README.md b/README.md index e0a3c1a..876fdf2 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,56 @@ Supporting: # Basic components - RoboidControl::Thing -- RoboidControl::Participant \ No newline at end of file +- RoboidControl::Participant + +# Installation + +## Core code + +The repository uses cmake for building. You can place it in a subfolder of your project and include it in you `CMakeLists.txt`. +For example if the library is placed in the subfolder `roboidcontrol`: +``` +add_subdirectory(roboidcontrol) + +add_executable(my_executable main.cpp) # Your source files/executable +target_link_libraries(my_executable RoboidControl) +``` + +## Arduino (PlatformIO) + +Arduino is only supported in combination with PlatformIO. The Arduino IDE is not (yet?) supported. + +The best way to include support for Roboid Control in PlatformIO is +to clone the Roboid Control for C++ repository into a subfolder of the /lib folder. +Alternatively you can download the zip file and unpack it as a subfolder of the /lib folder. + +## ESP-IDF + +The best way to include support for Roboid Control in PlatformIO is +to clone the Roboid Control for C++ repository into a subfolder of the /components folder. +Alternatively you can download the zip file and unpack it as a subfolder of the /components folder. + +Make sure you have included RoboidControl as a component in your top-level CMakeLists.txt, for example: +``` +list(APPEND EXTRA_COMPONENT_DIRS + components/RoboidControl + ) +``` + +# Get Started + +## Core C++ Examples + +This repository contains examples in the `examples` folder. You can build these using cmake. + +For example, to build the BB2A example: +``` +cmake -B build -D BUILD_EXAMPLE_BB2A=ON +cmake --build build +``` +The resulting executable is then `build/examples/Debug/BB2A.exe` + +## Arduino (PlatformIO) Examples + +Specific examples for the Arduino platform are found in the `Arduino\examples` folder. +To use them you should create a new project in PlatformIO and then copy the example code to your project. \ No newline at end of file diff --git a/examples/BB2B.cpp b/examples/BB2A/main.cpp similarity index 100% rename from examples/BB2B.cpp rename to examples/BB2A/main.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 00282a2..0cd9d2a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,25 +1,8 @@ # examples/CMakeLists.txt -# Specify the minimum CMake version -cmake_minimum_required(VERSION 3.10) +# Check if the options are enabled and add the corresponding examples +if(BUILD_EXAMPLE_BB2A) + add_executable(BB2A BB2A/main.cpp) # Adjust the path as necessary -# Specify the path to the main project directory -set(MAIN_PROJECT_DIR "${CMAKE_SOURCE_DIR}/..") - -# Set the project name -project(Examples) - -include_directories(..) - -# Add the executable for the main project -#add_executable(MainExecutable ${SOURCES}) -# Find the main project library (assuming it's defined in the root CMakeLists.txt) -#find_package(RoboidControl REQUIRED) # Replace MyLibrary with your actual library name - -# Add example executables -add_executable(BB2B BB2B.cpp) -target_link_libraries( - BB2B - RoboidControl - LinearAlgebra -) + target_link_libraries(BB2A RoboidControl) +endif() diff --git a/examples/README.md b/examples/README.md index b694fe9..bfba240 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1 +1 @@ -Important: this folder has to be names 'examples' exactly to maintain compatibility with Arduino \ No newline at end of file +Important: this folder has to be named 'examples' exactly to maintain compatibility with Arduino \ No newline at end of file