diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b4f007ae796194dfc9bf4f37f89f9701d2b917b..b8754bb71f1607e1dc206b0037de82aa0ae7c27a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,13 +23,24 @@ include_directories(dependencies/pipo/src/host) # Third party dependencies include_directories(dependencies/third_party/json) -file(GLOB_RECURSE RM_SOURCES "${PROJECT_SOURCE_DIR}/src/*.cpp") +file(GLOB_RECURSE RAPIDMIX_SRC "${PROJECT_SOURCE_DIR}/src/*.cpp") +file(GLOB GVF_SRC "${PROJECT_SOURCE_DIR}/dependencies/GVF/GVF.cpp") +file(GLOB MAXI_SRC "${PROJECT_SOURCE_DIR}/dependencies/Maximilian/maximilian.cpp") +file(GLOB RAPIDLIB_SRC "${PROJECT_SOURCE_DIR}/dependencies/RapidLib/src/*.cpp") +file(GLOB RAPIDLIB_DEP "${PROJECT_SOURCE_DIR}/dependencies/RapidLib/dependencies/libsvm/libsvm.cpp") file(GLOB JSON_SRC "${PROJECT_SOURCE_DIR}/dependencies/third_party/jsoncpp.cpp") + #Set the source for the main library, using the groups defined above -set(RAPIDMIX_SRC ${RM_SOURCES} ${JSON_SRC}) +set(RAPIDMIX_FULL_SRC ${RAPIDMIX_SRC} + ${GVF_SRC} + ${MAXI_SRC} + ${RAPIDLIB_SRC} + ${RAPIDLIB_DEP} + ${JSON_SRC} + ) -add_library(RMIX ${RAPIDMIX_SRC}) +add_library(RMIX ${RAPIDMIX_FULL_SRC}) -add_executable(rapidmix rapidmixCMake.cpp ) +add_executable(rapidmix tests/rapidMixTest.cpp ) target_link_libraries(rapidmix RMIX) diff --git a/rapidmixCMake.cpp b/rapidmixCMake.cpp deleted file mode 100644 index 024fdab906a79b68aa8215ada7f228149726aabc..0000000000000000000000000000000000000000 --- a/rapidmixCMake.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include <cassert> -#include <vector> -#include "rapidmix.h" - -int main() { - - //rapidmix::staticRegression myNN; - rapidmix::trainingData myData; - - std::vector<double> input = { 0.2, 0.7 }; - std::vector<double> output = { 3.0 }; - myData.recordSingleElement("label", input, output); - - input = { 2.0, 44.2 }; - output = { 20.14 }; - myData.recordSingleElement("label", input, output); - - //myNN.train(myData); - - std::vector<double> inputVec = { 1.618, 18.9 }; - //assert(myNN.run(inputVec)[0] == 12.596715279688549); - - return 0; -} diff --git a/tests/rapidMixTest.cpp b/tests/rapidMixTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b4d800058469cff82b43bc47d2b79b0b33dff4ac --- /dev/null +++ b/tests/rapidMixTest.cpp @@ -0,0 +1,58 @@ +#include <cassert> +#include <vector> +#include <iostream> +#include "rapidmix.h" + +int main() { + + ///////////////////////////////////Test GVF + + rapidmix::gvfTemporalVariation gvf; + rapidmix::trainingData myGVFData; + + // Record first gesture + myGVFData.startRecording(); + myGVFData.addElement({ 4.0, 0.7 }); + myGVFData.addElement({ 3.0, 0.8 }); + myGVFData.addElement({ 2.0, 0.9 }); + myGVFData.addElement({ 1.0, 1.0 }); + myGVFData.addElement({ 0.4, 1.2 }); + myGVFData.addElement({ 0.2, 1.4 }); + myGVFData.stopRecording(); + + // Record reverse of first gesture + myGVFData.startRecording(); + myGVFData.addElement({ 0.2, 1.4 }); + myGVFData.addElement({ 0.4, 1.2 }); + myGVFData.addElement({ 1.0, 1.0 }); + myGVFData.addElement({ 2.0, 0.9 }); + myGVFData.addElement({ 3.0, 0.8 }); + myGVFData.addElement({ 4.0, 0.7 }); + myGVFData.stopRecording(); + + // Train + std::cout << "gvf train = " << gvf.train(myGVFData) << std::endl; + + std::cout << "gvf passed." << std::endl; + + //////////////////////////////////////Test RapidLib + + rapidmix::staticRegression myNN; + rapidmix::trainingData myRLData; + + std::vector<double> input = { 0.2, 0.7 }; + std::vector<double> output = { 3.0 }; + myRLData.recordSingleElement("label", input, output); + + input = { 2.0, 44.2 }; + output = { 20.14 }; + myRLData.recordSingleElement("label", input, output); + + std::cout << "staticRegression train = " << myNN.train(myRLData) << std::endl; + + std::vector<double> inputVec = { 1.618, 18.9 }; + assert(myNN.run(inputVec)[0] == 12.596715279688549); + std::cout << "staticRegression passed." << std::endl; + + return 0; +}