Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/build time #16

Merged
merged 6 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:
pull_request:
workflow_dispatch:
jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt install libeigen3-dev libgtest-dev libginac-dev
run: sudo apt install libeigen3-dev libgtest-dev
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -24,8 +24,26 @@ jobs:
working-directory: ${{github.workspace}}
run: |
JOBS=$(($(grep cpu.cores /proc/cpuinfo | sort -u | sed 's/[^0-9]//g') + 1))
cmake -S . -B build -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DBUILD_BENCHMARKS=ON
cmake -S . -B build -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=ON -DBUILD_BENCHMARKS=OFF
cmake --build build -j${JOBS}
cd build
ctest


example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt install libeigen3-dev libgtest-dev
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pip install numpy
pip install matplotlib
- name: Build & Test
working-directory: ${{github.workspace}}
run: |
JOBS=$(($(grep cpu.cores /proc/cpuinfo | sort -u | sed 's/[^0-9]//g') + 1))
cmake -S . -B build -DBUILD_EXAMPLES=ON -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF
cmake --build build -j${JOBS}
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ if(BUILD_TESTS)
find_package(GTest REQUIRED)
enable_testing()
set(test_files
common/lib_test
# common/lib_test
utility/singleton_test
utility/random_test

algorithm/poly_regression_test
algorithm/random_test
algorithm/k_means_test
algorithm/auto_diff_test
algorithm/icp_test
Expand Down Expand Up @@ -129,14 +129,17 @@ if(BUILD_BENCHMARKS)

find_package(Python3 COMPONENTS Development NumPy)

# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftime-report")

set(bench_test_files
build_time
autodiff
eigen_arg_ret
)

foreach(bench_test_file ${bench_test_files})
get_filename_component(bench_test_file benckmark/${bench_test_file}.cpp NAME_WE)
add_executable(bench_${bench_test_file} benckmark/${bench_test_file}.cpp)
get_filename_component(bench_test_file benchmark/${bench_test_file}.cpp NAME_WE)
add_executable(bench_${bench_test_file} benchmark/${bench_test_file}.cpp)
target_include_directories(bench_${bench_test_file} PRIVATE include)
target_link_libraries(bench_${bench_test_file} PRIVATE Eigen3::Eigen Python3::Python Python3::NumPy)
endforeach()
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions benchmark/build_time.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// utility core
#include "cpp_robotics/utility.hpp" // 1.15
#include "cpp_robotics/vector.hpp" // 0.26
#include "cpp_robotics/unit.hpp" // 0.29

#include "cpp_robotics/system.hpp" // 2.4
#include "cpp_robotics/controller.hpp" // 3.0
#include "cpp_robotics/filter.hpp" // 2.0

#include "cpp_robotics/chassis.hpp" // 1.9
#include "cpp_robotics/motor.hpp" // 2.0

int main() {
return 0;
}
File renamed without changes.
4 changes: 2 additions & 2 deletions example/algorithm/icp_sample.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define CR_USE_MATPLOTLIB
#include <iostream>
#include <iomanip>
#include <cpp_robotics/algorithm.hpp>
#include <cpp_robotics/matplotlibcpp.hpp>
#include <cpp_robotics/algorithm/icp.hpp>
#include <cpp_robotics/vector/vector2.hpp>
#include <cpp_robotics/third_party/matplotlib-cpp/matplotlibcpp.h>
#include <Eigen/Geometry>

int main()
Expand Down
2 changes: 1 addition & 1 deletion example/algorithm/random_example.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <iostream>
#include <cpp_robotics/algorithm.hpp>
#include <cpp_robotics/utility.hpp>

double random_std()
{
Expand Down
1 change: 1 addition & 0 deletions example/controller/canonicalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <iomanip>
#include <cpp_robotics/system.hpp>
#include <cpp_robotics/controller.hpp>
#include <cpp_robotics/controller/modern_control.hpp>

#define PRINT_MAT(MAT) \
std::cout << #MAT << std::endl;\
Expand Down
5 changes: 2 additions & 3 deletions example/controller/linear_mpc.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#define CR_USE_MATPLOTLIB
#include <iostream>

#include <cpp_robotics/core.hpp>
#include <cpp_robotics/utility.hpp>
#include <cpp_robotics/controller/linear_mpc.hpp>
#include <cpp_robotics/system/state_space_system.hpp>
#include <limits>
#include <cpp_robotics/matplotlibcpp.hpp>


int main()
Expand Down
5 changes: 3 additions & 2 deletions example/controller/lqr.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#define CR_USE_MATPLOTLIB
#include <iostream>
#include <cpp_robotics/core.hpp>

#include <cpp_robotics/system.hpp>
#include <cpp_robotics/controller/lqr.hpp>
#include <cpp_robotics/matplotlibcpp.hpp>

int main()
{
Expand Down
6 changes: 3 additions & 3 deletions example/controller/motor_pid_control.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define CR_USE_MATPLOTLIB
#include <iostream>
#include <cpp_robotics/core.hpp>
#include <cpp_robotics/motor/dc_motor_list.hpp>
#include <cpp_robotics/motor/motor_tf.hpp>
#include <cpp_robotics/utility.hpp>
#include <cpp_robotics/system.hpp>
#include <cpp_robotics/motor.hpp>

static std::tuple<std::vector<double>, std::vector<double>> ref_trajectory(double time, double dt)
{
Expand Down
7 changes: 4 additions & 3 deletions example/controller/nctf_example.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#define CR_USE_MATPLOTLIB
#include <iostream>
#include <cpp_robotics/core.hpp>
#include <cpp_robotics/motor/dc_motor_list.hpp>
#include <cpp_robotics/motor/motor_tf.hpp>
#include <cpp_robotics/utility.hpp>
#include <cpp_robotics/motor.hpp>
#include <cpp_robotics/controller.hpp>
#include <cpp_robotics/system.hpp>

static std::tuple<std::vector<double>, std::vector<double>> ref_trajectory(double time, double dt)
{
Expand Down
7 changes: 4 additions & 3 deletions example/controller/pid_vs_nctf.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#define CR_USE_MATPLOTLIB
#include <iostream>
#include <cpp_robotics/core.hpp>
#include <cpp_robotics/motor/dc_motor_list.hpp>
#include <cpp_robotics/motor/motor_tf.hpp>
#include <cpp_robotics/utility.hpp>
#include <cpp_robotics/system.hpp>
#include <cpp_robotics/controller.hpp>
#include <cpp_robotics/motor.hpp>

static std::tuple<std::vector<double>, std::vector<double>> ref_trajectory(double time, double dt)
{
Expand Down
1 change: 1 addition & 0 deletions example/controller/place.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iomanip>
#include <cpp_robotics/system.hpp>
#include <cpp_robotics/controller.hpp>
#include <cpp_robotics/controller/modern_control.hpp>

#define PRINT_MAT(MAT) \
std::cout << #MAT << std::endl;\
Expand Down
Loading
Loading