From 29d1ee8293ada7965f0ed6eb2fb9dbb4d8fbf452 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 20 Dec 2024 14:15:01 +0100 Subject: [PATCH 1/9] cmake: Fix Windows build cmake: Don't filter define --- CMakeLists.txt | 4 ++++ python/ndcurves/CMakeLists.txt | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52983bbb..8c39dd3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,6 +149,10 @@ if(CURVES_WITH_PINOCCHIO_SUPPORT) INTERFACE -DCURVES_WITH_PINOCCHIO_SUPPORT) endif(CURVES_WITH_PINOCCHIO_SUPPORT) +# Define M_PI constant in +cxx_flags_by_compiler_frontend(MSVC _USE_MATH_DEFINES OUTPUT PUBLIC_DEFINITION) +target_compile_definitions(${PROJECT_NAME} INTERFACE ${PUBLIC_DEFINITION}) + if(NOT INSTALL_PYTHON_INTERFACE_ONLY) install( TARGETS ${PROJECT_NAME} diff --git a/python/ndcurves/CMakeLists.txt b/python/ndcurves/CMakeLists.txt index bed73b37..f11e60b0 100644 --- a/python/ndcurves/CMakeLists.txt +++ b/python/ndcurves/CMakeLists.txt @@ -20,7 +20,9 @@ set_target_properties( PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME} INSTALL_RPATH "${${wrap}_INSTALL_RPATH}") -target_compile_options(${wrap} PRIVATE "-Wno-conversion") +cxx_flags_by_compiler_frontend(GNU -Wno-conversion OUTPUT PRIVATE_OPTIONS + FILTER) +target_compile_options(${wrap} PRIVATE ${PRIVATE_OPTIONS}) target_link_libraries(${wrap} PUBLIC ${PROJECT_NAME} eigenpy::eigenpy) if(GENERATE_PYTHON_STUBS) From a6b31f04f6aeda81acc74181534b544da2b47951 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 20 Dec 2024 14:40:01 +0100 Subject: [PATCH 2/9] core: Fix build with cl compiler --- include/ndcurves/linear_variable.h | 14 ++++++++++++++ tests/Main.cpp | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/ndcurves/linear_variable.h b/include/ndcurves/linear_variable.h index c6fc2aa1..d50e27b6 100644 --- a/include/ndcurves/linear_variable.h +++ b/include/ndcurves/linear_variable.h @@ -220,6 +220,20 @@ struct linear_variable : public serialization::Serializable { return (*this - other).norm() < prec; } + /// \brief Check if actual linear variable and other are equal. + /// \param other : the other linear_variable to check. + /// \return true if the two linear_variable are equals. + virtual bool operator==(const linear_variable& other) const { + return this->B_ == other.B_ && this->c_ == other.c_; + } + + /// \brief Check if actual linear variable and other are different. + /// \param other : the other linear_variable to check. + /// \return true if the two linear_variable are different. + virtual bool operator!=(const linear_variable& other) const { + return !(*this == other); + } + const matrix_x_t& B() const { return B_; } const vector_x_t& c() const { return c_; } bool isZero() const { return zero; } diff --git a/tests/Main.cpp b/tests/Main.cpp index 18812c31..b63e159b 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -1432,7 +1432,7 @@ void piecewiseCurveTest(bool& error) { } // C0 isC0 = pc_C0.is_continuous(0); - if (not isC0) { + if (!isC0) { std::cout << errmsg2 << " pc_C0 " << std::endl; error = true; } @@ -1444,7 +1444,7 @@ void piecewiseCurveTest(bool& error) { } // C1 isC1 = pc_C1.is_continuous(1); - if (not isC1) { + if (!isC1) { std::cout << errmsg3 << " pc_C1 " << std::endl; error = true; } @@ -1456,7 +1456,7 @@ void piecewiseCurveTest(bool& error) { } // C2 isC2 = pc_C2.is_continuous(2); - if (not isC2) { + if (!isC2) { std::cout << errmsg4 << " pc_C2 " << std::endl; error = true; } From 50e03f618de56cd73bc97506a29653038f289175 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 20 Dec 2024 15:05:34 +0100 Subject: [PATCH 3/9] cmake: Setup the right library suffix for bindings --- python/ndcurves/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/python/ndcurves/CMakeLists.txt b/python/ndcurves/CMakeLists.txt index f11e60b0..878c5615 100644 --- a/python/ndcurves/CMakeLists.txt +++ b/python/ndcurves/CMakeLists.txt @@ -18,6 +18,7 @@ get_relative_rpath(${${wrap}_INSTALL_DIR} ${wrap}_INSTALL_RPATH) set_target_properties( ${wrap} PROPERTIES PREFIX "" + SUFFIX ${PYTHON_EXT_SUFFIX} OUTPUT_NAME ${PROJECT_NAME} INSTALL_RPATH "${${wrap}_INSTALL_RPATH}") cxx_flags_by_compiler_frontend(GNU -Wno-conversion OUTPUT PRIVATE_OPTIONS From 624d1c9ab53bb4064946dba281bcdf331e9f8ce9 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 20 Dec 2024 15:40:03 +0100 Subject: [PATCH 4/9] tests: Fix test-so3-smooth.cpp on Windows --- include/ndcurves/serialization/archive.hpp | 4 ++-- tests/test-so3-smooth.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ndcurves/serialization/archive.hpp b/include/ndcurves/serialization/archive.hpp index 4d0b2c6b..3cbcf811 100644 --- a/include/ndcurves/serialization/archive.hpp +++ b/include/ndcurves/serialization/archive.hpp @@ -118,7 +118,7 @@ struct Serializable { /// \brief Loads a Derived object from an binary file. template void loadFromBinary(const std::string& filename) { - std::ifstream ifs(filename.c_str()); + std::ifstream ifs(filename.c_str(), std::ios::binary); if (ifs) { boost::archive::binary_iarchive ia(ifs); ia >> derived(); @@ -132,7 +132,7 @@ struct Serializable { /// \brief Saved a Derived object as an binary file. template void saveAsBinary(const std::string& filename) const { - std::ofstream ofs(filename.c_str()); + std::ofstream ofs(filename.c_str(), std::ios::binary); if (ofs) { boost::archive::binary_oarchive oa(ofs); oa << derived(); diff --git a/tests/test-so3-smooth.cpp b/tests/test-so3-smooth.cpp index 97fc2313..12f08b7a 100644 --- a/tests/test-so3-smooth.cpp +++ b/tests/test-so3-smooth.cpp @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(from_quat_and_time_constructor) { BOOST_AUTO_TEST_CASE(from_quat_and_time_generate) { // Create some start variables. quaternion_t init_quat = quaternion_t::UnitRandom(); - matrix3_t init_rot = init_quat.toRotationMatrix(); + matrix3_t init_rot = init_quat.normalized().toRotationMatrix(); quaternion_t end_quat = quaternion_t::UnitRandom(); matrix3_t end_rot = end_quat.toRotationMatrix(); double t_min = generateRandomNumber(0.0, 100.0); From 86786232b382aa092ae901b29745783218217554 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 20 Dec 2024 22:01:54 +0100 Subject: [PATCH 5/9] tests: Allocate buffer on the heap instead of the stack --- tests/load_problem.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/load_problem.h b/tests/load_problem.h index e202afbf..fc9567f8 100644 --- a/tests/load_problem.h +++ b/tests/load_problem.h @@ -19,7 +19,7 @@ namespace ndcurves { typedef Eigen::Vector3d point_t; -typedef std::vector > t_point_t; +typedef std::vector> t_point_t; typedef Eigen::VectorXd pointX_t; typedef std::pair Waypoint; typedef std::vector T_Waypoint; @@ -41,9 +41,10 @@ typedef quadratic_problem problem_t; #define MAXBUFSIZE ((int)1e6) -Eigen::MatrixXd readMatrix(std::ifstream& infile) { +Eigen::MatrixXd readMatrix(std::ifstream &infile) { int cols = 0, rows = 0; - double buff[MAXBUFSIZE]; + std::vector buff; + buff.resize(MAXBUFSIZE); // Read numbers from file into buffer. // ifstream infile; @@ -54,7 +55,8 @@ Eigen::MatrixXd readMatrix(std::ifstream& infile) { int temp_cols = 0; std::stringstream stream(line); - while (!stream.eof()) stream >> buff[cols * rows + temp_cols++]; + while (!stream.eof()) + stream >> buff[static_cast(cols * rows + temp_cols++)]; if (temp_cols == 0) continue; @@ -73,7 +75,7 @@ Eigen::MatrixXd readMatrix(std::ifstream& infile) { return result; } -problem_definition_t loadproblem(const std::string& filename) { +problem_definition_t loadproblem(const std::string &filename) { problem_definition_t pDef(3); std::ifstream in(filename.c_str()); if (!in.is_open()) throw std::runtime_error("cant open filename"); From ea0a50bc141df7f6f4eb44ba5a81e02933243608 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 20 Dec 2024 23:06:00 +0100 Subject: [PATCH 6/9] tests: Fix uninitialized value error tests: uninit value --- tests/Main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Main.cpp b/tests/Main.cpp index b63e159b..c6d98103 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -2737,7 +2737,7 @@ void BezierLinearProblemsetup_control_pointsVarCombinatorialInit(bool& error) { void BezierLinearProblemsetup_control_pointsVarCombinatorialEnd(bool& error) { constraint_flag flag = optimization::END_POS; point3_t init_pos = point3_t(1., 1., 1.); - var_pair_t res = setup_control_points(5, flag, init_pos); + var_pair_t res = setup_control_points(5, flag, init_pos, init_pos); T_linear_variable_t& vars = res.first; vartype exptecdvars[] = {variable, variable, variable, variable, variable, constant}; @@ -2809,7 +2809,7 @@ void BezierLinearProblemsetup_control_pointsVarCombinatorialEnd(bool& error) { void BezierLinearProblemsetup_control_pointsVarCombinatorialMix(bool& error) { constraint_flag flag = END_POS | INIT_POS; point3_t init_pos = point3_t(1., 1., 1.); - var_pair_t res = setup_control_points(5, flag, init_pos); + var_pair_t res = setup_control_points(5, flag, init_pos, init_pos); T_linear_variable_t& vars = res.first; vartype exptecdvars[] = {constant, variable, variable, variable, variable, constant}; @@ -2881,7 +2881,7 @@ void BezierLinearProblemsetup_control_pointsVarCombinatorialMix(bool& error) { void BezierLinearProblemInitInequalities(bool& error) { constraint_flag flag = INIT_POS | END_POS; point3_t init_pos = point3_t(1., 1., 1.); - var_pair_t res = setup_control_points(5, flag, init_pos); + var_pair_t res = setup_control_points(5, flag, init_pos, init_pos); T_linear_variable_t& vars = res.first; vartype exptecdvars[] = {constant, variable, variable, variable, variable, constant}; From 636f40a5917834a228b75025abf48c66ea732cef Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 20 Dec 2024 23:06:23 +0100 Subject: [PATCH 7/9] ci: Add pixi workflow to test Windows build tests: uninit value --- .github/workflows/windows-pixi.yml | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/windows-pixi.yml diff --git a/.github/workflows/windows-pixi.yml b/.github/workflows/windows-pixi.yml new file mode 100644 index 00000000..49e466c9 --- /dev/null +++ b/.github/workflows/windows-pixi.yml @@ -0,0 +1,53 @@ +name: Build ndcurves for Windows via pixi + +on: [push, pull_request] + +jobs: + ndcurves-pixi: + name: "CI on ${{ matrix.os }} / python ${{ matrix.python-version }} with pixi" + runs-on: "${{ matrix.os }}" + + strategy: + matrix: + os: [windows-latest] + python-version: ["3.9", "3.12"] + compiler: [cl, clang-cl] + steps: + - uses: actions/checkout@v4 + with: + submodules: 'true' + - uses: prefix-dev/setup-pixi@v0.8.1 + with: + cache: false + run-install: false + - name: Create pixi.toml + run: | + pixi init + pixi add cmake ^ + ninja ^ + cxx-compiler ^ + eigen ^ + eigenpy ^ + pinocchio ^ + libboost-devel ^ + libboost-python-devel + + - name: Configure + shell: pixi run bash -e {0} + env: + COMPILER: ${{ matrix.compiler }} + run: | + export CXX=$COMPILER + cmake -B build \ + -S . \ + -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_PYTHON_INTERFACE=ON \ + -DGENERATE_PYTHON_STUB=ON \ + -DCURVES_WITH_PINOCCHIO_SUPPORT=ON + - name: Build + shell: pixi run bash -e {0} + run: cmake --build build + - name: Test + shell: pixi run bash -e {0} + run: cmake --build build -t test From b5197a8b6c8c5251de14497da6c57a89c739eb01 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Tue, 31 Dec 2024 12:29:35 +0100 Subject: [PATCH 8/9] ci: Use conda instead of pixi --- .github/workflows/windows-conda.yml | 64 +++++++++++++++++++++++++++++ .github/workflows/windows-pixi.yml | 53 ------------------------ 2 files changed, 64 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/windows-conda.yml delete mode 100644 .github/workflows/windows-pixi.yml diff --git a/.github/workflows/windows-conda.yml b/.github/workflows/windows-conda.yml new file mode 100644 index 00000000..0307aaf6 --- /dev/null +++ b/.github/workflows/windows-conda.yml @@ -0,0 +1,64 @@ +name: Build ndcurves for Windows via conda + +on: [push, pull_request] + +jobs: + ndcurves-conda: + name: "CI on ${{ matrix.os }} / compiler ${{ matrix.compiler }} / python ${{ matrix.python-version }} with conda" + runs-on: "${{ matrix.os }}" + + strategy: + matrix: + os: [windows-latest] + python-version: ["3.9", "3.12"] + compiler: [cl, clang-cl] + steps: + - uses: actions/checkout@v4 + with: + submodules: 'true' + + - uses: conda-incubator/setup-miniconda@v3 + with: + channels: conda-forge + python-version: ${{ matrix.python-version }} + activate-environment: ndcurve + + - name: Create conda environment + shell: bash -l {0} + run: | + conda install cmake \ + ninja \ + cxx-compiler \ + eigen \ + eigenpy \ + pinocchio \ + libboost-devel \ + libboost-python-devel + + - name: Configure + shell: cmd /C CALL {0} + env: + COMPILER: ${{ matrix.compiler }} + run: | + set CC=${{ matrix.compiler }} + set CXX=${{ matrix.compiler }} + + call conda info + call conda list + + cmake -B build ^ + -S . ^ + -GNinja ^ + -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DPYTHON_SITELIB=%CONDA_PREFIX%\Lib\site-packages ^ + -DPYTHON_EXECUTABLE=%CONDA_PREFIX%\python.exe ^ + -DBUILD_PYTHON_INTERFACE=ON ^ + -DGENERATE_PYTHON_STUB=ON ^ + -DCURVES_WITH_PINOCCHIO_SUPPORT=ON + - name: Build + shell: cmd /C CALL {0} + run: cmake --build build -j2 + - name: Test + shell: cmd /C CALL {0} + run: ctest --test-dir build --output-on-failure diff --git a/.github/workflows/windows-pixi.yml b/.github/workflows/windows-pixi.yml deleted file mode 100644 index 49e466c9..00000000 --- a/.github/workflows/windows-pixi.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Build ndcurves for Windows via pixi - -on: [push, pull_request] - -jobs: - ndcurves-pixi: - name: "CI on ${{ matrix.os }} / python ${{ matrix.python-version }} with pixi" - runs-on: "${{ matrix.os }}" - - strategy: - matrix: - os: [windows-latest] - python-version: ["3.9", "3.12"] - compiler: [cl, clang-cl] - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - uses: prefix-dev/setup-pixi@v0.8.1 - with: - cache: false - run-install: false - - name: Create pixi.toml - run: | - pixi init - pixi add cmake ^ - ninja ^ - cxx-compiler ^ - eigen ^ - eigenpy ^ - pinocchio ^ - libboost-devel ^ - libboost-python-devel - - - name: Configure - shell: pixi run bash -e {0} - env: - COMPILER: ${{ matrix.compiler }} - run: | - export CXX=$COMPILER - cmake -B build \ - -S . \ - -GNinja \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_PYTHON_INTERFACE=ON \ - -DGENERATE_PYTHON_STUB=ON \ - -DCURVES_WITH_PINOCCHIO_SUPPORT=ON - - name: Build - shell: pixi run bash -e {0} - run: cmake --build build - - name: Test - shell: pixi run bash -e {0} - run: cmake --build build -t test From 4139751de3b164a71619f3e802cb9fe1c0749fed Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Tue, 31 Dec 2024 16:10:20 +0100 Subject: [PATCH 9/9] Update .github/workflows/windows-conda.yml Co-authored-by: Guilhem Saurel --- .github/workflows/windows-conda.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-conda.yml b/.github/workflows/windows-conda.yml index 0307aaf6..ab3c4e50 100644 --- a/.github/workflows/windows-conda.yml +++ b/.github/workflows/windows-conda.yml @@ -1,6 +1,14 @@ name: Build ndcurves for Windows via conda -on: [push, pull_request] +on: + push: + branches: + - devel + - master + pull_request: + branches: + - devel + - master jobs: ndcurves-conda: