Skip to content

Commit

Permalink
Merge pull request #144 from jorisv/topic/windows
Browse files Browse the repository at this point in the history
Fix Windows build
  • Loading branch information
nim65s authored Dec 31, 2024
2 parents 48bca89 + 4139751 commit eae0677
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 15 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/windows-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build ndcurves for Windows via conda

on:
push:
branches:
- devel
- master
pull_request:
branches:
- devel
- master

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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ if(CURVES_WITH_PINOCCHIO_SUPPORT)
INTERFACE -DCURVES_WITH_PINOCCHIO_SUPPORT)
endif(CURVES_WITH_PINOCCHIO_SUPPORT)

# Define M_PI constant in <cmath>
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}
Expand Down
14 changes: 14 additions & 0 deletions include/ndcurves/linear_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions include/ndcurves/serialization/archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct Serializable {
/// \brief Loads a Derived object from an binary file.
template <class Derived>
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<Derived>();
Expand All @@ -132,7 +132,7 @@ struct Serializable {
/// \brief Saved a Derived object as an binary file.
template <class Derived>
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<Derived>();
Expand Down
5 changes: 4 additions & 1 deletion python/ndcurves/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ 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}")
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)
Expand Down
12 changes: 6 additions & 6 deletions tests/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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};
Expand Down
12 changes: 7 additions & 5 deletions tests/load_problem.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace ndcurves {

typedef Eigen::Vector3d point_t;
typedef std::vector<point_t, Eigen::aligned_allocator<point_t> > t_point_t;
typedef std::vector<point_t, Eigen::aligned_allocator<point_t>> t_point_t;
typedef Eigen::VectorXd pointX_t;
typedef std::pair<double, pointX_t> Waypoint;
typedef std::vector<Waypoint> T_Waypoint;
Expand All @@ -41,9 +41,10 @@ typedef quadratic_problem<point_t, double> 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<double> buff;
buff.resize(MAXBUFSIZE);

// Read numbers from file into buffer.
// ifstream infile;
Expand All @@ -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<size_t>(cols * rows + temp_cols++)];

if (temp_cols == 0) continue;

Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion tests/test-so3-smooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit eae0677

Please sign in to comment.