From ce335377e0f552b0c232ec9530f675fabcc40302 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:28:28 +0000 Subject: [PATCH 01/19] Update CMakeLists.txt --- CMakeLists.txt | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cbff70..625ac5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,3 @@ - set(sourcedirs . VectorAlgebra/src @@ -14,3 +13,38 @@ idf_component_register( INCLUDE_DIRS ${includedirs} REQUIRES arduino ) + +project(RoboidControl) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +add_compile_definitions(GTEST) +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/heads/main.zip +) + +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +add_library(RoboidControl STATIC + "Roboid.cpp" +) + +enable_testing() + +add_executable( + RoboidControlTest + "test/Dummy_test.cc" +) +target_link_libraries( + RoboidControlTest + gtest_main + RoboidControl +) + +include(GoogleTest) +gtest_discover_tests(RoboidControlTest) From 871dc4849e3b3fcf8d0bc2099bece8e0a8d58a84 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:28:48 +0000 Subject: [PATCH 02/19] Add new directory --- test/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/.gitkeep diff --git a/test/.gitkeep b/test/.gitkeep new file mode 100644 index 0000000..e69de29 From ff68de638b32be7cea9eeb59e826f641ac729add Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:29:12 +0000 Subject: [PATCH 03/19] Add new file --- test/Dummy_test.cc | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 test/Dummy_test.cc diff --git a/test/Dummy_test.cc b/test/Dummy_test.cc new file mode 100644 index 0000000..5c29d53 --- /dev/null +++ b/test/Dummy_test.cc @@ -0,0 +1,6 @@ +#if GTEST +#include + +TEST(Dummy, Foo) { + +} From 8a86e4e223e5108a62236079b0c200f749c70ff0 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:30:12 +0000 Subject: [PATCH 04/19] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..09dc1c2 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,58 @@ +# This file is a template, and might need editing before it works on your project. +# This is a sample GitLab CI/CD configuration file that should run without any modifications. +# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts, +# it uses echo commands to simulate the pipeline execution. +# +# A pipeline is composed of independent jobs that run scripts, grouped into stages. +# Stages run in sequential order, but jobs within stages run in parallel. +# +# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages +# +# You can copy and paste this template into a new `.gitlab-ci.yml` file. +# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. +# +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml + +# This file is a template, and might need editing before it works on your project. +# This is a sample GitLab CI/CD configuration file that should run without any modifications. +# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts, +# it uses echo commands to simulate the pipeline execution. +# +# A pipeline is composed of independent jobs that run scripts, grouped into stages. +# Stages run in sequential order, but jobs within stages run in parallel. +# +# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages +# +# You can copy and paste this template into a new `.gitlab-ci.yml` file. +# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. +# +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml + +default: + image: rikorose/gcc-cmake +stages: +- test +unit-test-job: + stage: test + script: + - mkdir build + - cd build + - cmake .. + - cmake --build . + - export GTEST_OUTPUT="xml:report.xml" + - ls -la + - "./RoboidControlTest" + artifacts: + when: always + reports: + junit: build/report.xml +sast: + stage: test +include: +- template: Security/SAST.gitlab-ci.yml From 80d062b3fbe24d0c57abe47e38ac6be225f5b0fc Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:32:19 +0000 Subject: [PATCH 05/19] Update CMakeLists.txt --- CMakeLists.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 625ac5f..2c228eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,20 @@ -set(sourcedirs - . - VectorAlgebra/src -) +if(ESP_PLATFORM) + set(sourcedirs + . + VectorAlgebra/src + ) -set(includedirs - . - VectorAlgebra/include -) + set(includedirs + . + VectorAlgebra/include + ) -idf_component_register( - SRC_DIRS ${sourcedirs} - INCLUDE_DIRS ${includedirs} - REQUIRES arduino -) + idf_component_register( + SRC_DIRS ${sourcedirs} + INCLUDE_DIRS ${includedirs} + REQUIRES arduino + ) +endif() project(RoboidControl) From 393bb8f2617b38fb9d7f56dcbf0653825c2dd961 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:38:20 +0000 Subject: [PATCH 06/19] Update CMakeLists.txt --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c228eb..b779474 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ if(ESP_PLATFORM) endif() project(RoboidControl) +add_subdirectory(VectorAlgebra) set(CMAKE_CXX_STANDARD 11) set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -31,7 +32,7 @@ FetchContent_Declare( # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) - + add_library(RoboidControl STATIC "Roboid.cpp" ) From ed3456a5ef997e3d3edacbb8d15c382af374e6fb Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:39:51 +0000 Subject: [PATCH 07/19] Update CMakeLists.txt --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b779474..e3dca53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,11 @@ FetchContent_Declare( set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) +include_directories( + . + VectorAlgebra/include +) + add_library(RoboidControl STATIC "Roboid.cpp" ) From 46de37b77277787ce8165def7cca995094629be4 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:43:37 +0000 Subject: [PATCH 08/19] Update .gitlab-ci.yml --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09dc1c2..b5f7549 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,8 @@ # This specific template is located at: # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml +variables: + GIT_SUBMODULE_STRATEGY: recursive default: image: rikorose/gcc-cmake stages: From 7c960d2c07deb14fdc5b8bc684a9860c5955023e Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sat, 30 Dec 2023 14:45:01 +0000 Subject: [PATCH 09/19] Update Dummy_test.cc --- test/Dummy_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Dummy_test.cc b/test/Dummy_test.cc index 5c29d53..dc843bb 100644 --- a/test/Dummy_test.cc +++ b/test/Dummy_test.cc @@ -4,3 +4,4 @@ TEST(Dummy, Foo) { } +#endif From 393a6643fd9e12831e0013d783dfd968170764aa Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 08:37:29 +0100 Subject: [PATCH 10/19] Updated doxygen style --- doxygen/Doxyfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 4d8f3c1..a4ff993 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -1420,7 +1420,7 @@ HTML_EXTRA_FILES = # The default value is: AUTO_LIGHT. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE = AUTO_LIGHT +HTML_COLORSTYLE = LIGHT # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to From b55c7d5725ad0d0e216636781f295d3573d0d09e Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 08:42:06 +0100 Subject: [PATCH 11/19] Extended dummy test --- test/Dummy_test.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/Dummy_test.cc b/test/Dummy_test.cc index dc843bb..3cff9b3 100644 --- a/test/Dummy_test.cc +++ b/test/Dummy_test.cc @@ -2,6 +2,20 @@ #include TEST(Dummy, Foo) { + Motor motorLeft = Motor(); + Motor motorRight = Motor(); + DistanceSensor sensorLeft = DistanceSensor(); + DistanceSensor sensorRight = DisteanceSensor(); + + Placement sensors[] = {Placement(&sensorLeft, -30), + Placement(&sensorRight, 30)}; + Perception *perception = new Perception(sensors); + + DifferentialDrive *propulsion = + new DifferentialDrive(Placement(&motorLeft, Vector3::Left), + Placement(&motorRight, Vector3::Right)); + + Roboid *roboid = new Roboid(perception, propulsion); } #endif From 14f162c67fe36271a5c0a1adc0bb1c972686f0af Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 08:42:56 +0100 Subject: [PATCH 12/19] Added include --- test/Dummy_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Dummy_test.cc b/test/Dummy_test.cc index 3cff9b3..fd3a01e 100644 --- a/test/Dummy_test.cc +++ b/test/Dummy_test.cc @@ -1,6 +1,8 @@ #if GTEST #include +#include "Roboid.h" + TEST(Dummy, Foo) { Motor motorLeft = Motor(); Motor motorRight = Motor(); From f559566ef47655544b62abf036f382eff9a5889e Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 08:46:39 +0100 Subject: [PATCH 13/19] Fixed includes --- test/Dummy_test.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Dummy_test.cc b/test/Dummy_test.cc index fd3a01e..2c6e589 100644 --- a/test/Dummy_test.cc +++ b/test/Dummy_test.cc @@ -1,6 +1,8 @@ #if GTEST #include +#include "DifferentialDrive.h" +#include "DistanceSensor.h" #include "Roboid.h" TEST(Dummy, Foo) { From 9384995e1213288188e37a762cdaabcb2632612e Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 08:53:50 +0100 Subject: [PATCH 14/19] Typo --- test/Dummy_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Dummy_test.cc b/test/Dummy_test.cc index 2c6e589..41444ff 100644 --- a/test/Dummy_test.cc +++ b/test/Dummy_test.cc @@ -10,7 +10,7 @@ TEST(Dummy, Foo) { Motor motorRight = Motor(); DistanceSensor sensorLeft = DistanceSensor(); - DistanceSensor sensorRight = DisteanceSensor(); + DistanceSensor sensorRight = DistanceSensor(); Placement sensors[] = {Placement(&sensorLeft, -30), Placement(&sensorRight, 30)}; From 50999805cdf43c13d43724b11e22de9e7abb61bb Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 09:00:29 +0100 Subject: [PATCH 15/19] Replace vector left/right with direct values --- test/Dummy_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Dummy_test.cc b/test/Dummy_test.cc index 41444ff..abba183 100644 --- a/test/Dummy_test.cc +++ b/test/Dummy_test.cc @@ -17,8 +17,8 @@ TEST(Dummy, Foo) { Perception *perception = new Perception(sensors); DifferentialDrive *propulsion = - new DifferentialDrive(Placement(&motorLeft, Vector3::Left), - Placement(&motorRight, Vector3::Right)); + new DifferentialDrive(Placement(&motorLeft, Vector3(-1, 0, 0)), + Placement(&motorRight, Vector3(1, 0, 0))); Roboid *roboid = new Roboid(perception, propulsion); } From 7f37a0b3e7bfea73fad88d5a94c3292e5dcedcfc Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 09:08:39 +0100 Subject: [PATCH 16/19] Add VectorAlgebra to makefiles --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3dca53..286335c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.13) # CMake version check if(ESP_PLATFORM) set(sourcedirs . @@ -18,6 +19,7 @@ endif() project(RoboidControl) add_subdirectory(VectorAlgebra) +#add_subdirectory(test) set(CMAKE_CXX_STANDARD 11) set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -52,6 +54,7 @@ target_link_libraries( RoboidControlTest gtest_main RoboidControl + VectorAlgebra ) include(GoogleTest) From 2c4f857e2d96cc9422fe1ec0498da0cf10120244 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 09:18:17 +0100 Subject: [PATCH 17/19] Updated gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 186f843..b3abcf6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ doxygen/html doxygen/DoxyWarnLogfile.txt +build \ No newline at end of file From 3de05ae621434e728a7fe3ca79123d57fd4f400a Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 09:34:06 +0100 Subject: [PATCH 18/19] Fixed testing (I think) --- CMakeLists.txt | 9 +++++++++ RoboidControl.code-workspace | 8 ++++++++ test/CMakeLists_disabled.txt | 30 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 RoboidControl.code-workspace create mode 100644 test/CMakeLists_disabled.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 286335c..ee14052 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,15 @@ include_directories( add_library(RoboidControl STATIC "Roboid.cpp" + "Perception.cpp" + "Propulsion.cpp" + "Motor.cpp" + "DifferentialDrive.cpp" + "DistanceSensor.cpp" + "Placement.cpp" + "Sensor.cpp" + "Switch.cpp" + "Thing.cpp" ) enable_testing() diff --git a/RoboidControl.code-workspace b/RoboidControl.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/RoboidControl.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/test/CMakeLists_disabled.txt b/test/CMakeLists_disabled.txt new file mode 100644 index 0000000..5cf6e5a --- /dev/null +++ b/test/CMakeLists_disabled.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.13) # CMake version check +Project(test) + +set(CMAKE_CXX_STANDARD 11) # Enable c++11 standard +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +add_compile_definitions(GTEST) +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/heads/main.zip +) + +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) +include_directories(include) + +enable_testing() + +add_executable( + VectorAlgebraTest + "test/Angle_test.cc" + "test/FloatSingle_test.cc" + "test/Vector2_test.cc" + "test/Vector3_test.cc" + "test/Quaternion_test.cc" +) + +include(GoogleTest) \ No newline at end of file From aad76d318a4c90b068a72af2b77bd2d2a3f24794 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 31 Dec 2023 09:34:31 +0100 Subject: [PATCH 19/19] Update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b3abcf6..2134aae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ doxygen/html doxygen/DoxyWarnLogfile.txt -build \ No newline at end of file +build +.vscode