Skip to content

Commit 178e768

Browse files
authored
Merge pull request #250 from Simple-Robotics/topic/fix-build-without-pinocchio
Fully support building aligator without Pinocchio support (including without proxsuite-nlp Pinocchio support)
2 parents 6f2e296 + 5297287 commit 178e768

33 files changed

+166
-78
lines changed

.gersemirc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1+
definitions: [./CMakeLists.txt, ./examples, ./tests, ./bindings]
12
line_length: 80
2-
cache: true
33
indent: 2
4-
quiet: true
54
warn_about_unknown_commands: false
6-
workers: 8

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ ci:
44
autoupdate_schedule: quarterly
55
repos:
66
- repo: https://github.com/pre-commit/mirrors-clang-format
7-
rev: v19.1.1
7+
rev: v19.1.4
88
hooks:
99
- id: clang-format
1010
types_or: []
1111
types: [text]
1212
files: '\.(cpp|cxx|c|h|hpp|hxx|txx)$'
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
14-
rev: v4.6.0
14+
rev: v5.0.0
1515
hooks:
1616
- id: check-added-large-files
1717
- id: check-case-conflict
@@ -28,13 +28,13 @@ repos:
2828
)$
2929
- repo: https://github.com/astral-sh/ruff-pre-commit
3030
# Ruff version.
31-
rev: 'v0.6.9'
31+
rev: 'v0.8.1'
3232
hooks:
3333
- id: ruff
3434
args: [--fix, --exit-non-zero-on-fix]
3535
- id: ruff-format
3636
- repo: https://github.com/BlankSpruce/gersemi
37-
rev: 0.15.1
37+
rev: 0.17.1
3838
hooks:
3939
- id: gersemi
4040
- repo: https://github.com/Lucas-C/pre-commit-hooks

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Default constructor for `LQRProblemTpl`
3333
- Removed header `gar/fwd.hpp` with forward-declarations
3434

35+
### Fixed
36+
37+
- Building aligator without Pinocchio support (including without Pinocchio support in the proxsuite-nlp dependency) is now supported. ([#250](https://github.com/Simple-Robotics/aligator/pull/250))
38+
3539
## [0.9.0] - 2024-10-11
3640

3741
### Added

CMakeLists.txt

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,37 @@ if(BUILD_WITH_OPENMP_SUPPORT)
212212
add_compile_definitions(ALIGATOR_MULTITHREADING)
213213
endif()
214214

215+
set(BOOST_REQUIRED_COMPONENTS filesystem)
216+
set_boost_default_options()
217+
export_boost_default_options()
218+
add_project_dependency(Boost REQUIRED COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
219+
add_project_dependency(proxsuite-nlp 0.8.0 REQUIRED PKG_CONFIG_REQUIRES "proxsuite-nlp >= 0.8.0")
220+
215221
if(BUILD_WITH_PINOCCHIO_SUPPORT)
216-
message(STATUS "Building with Pinocchio support.")
222+
message(STATUS "Building aligator with Pinocchio support.")
223+
if(NOT DEFINED PROXSUITE_NLP_WITH_PINOCCHIO_SUPPORT)
224+
message(
225+
FATAL_ERROR
226+
"The aligator Pinocchio features require Pinocchio support in proxsuite-nlp. Please check your installation of proxsuite-nlp (found at ${proxsuite-nlp_DIR}).\n"
227+
"If you didn't build proxsuite-nlp yourself, please contact the maintainer for the distribution you used."
228+
)
229+
endif()
217230
add_compile_definitions(ALIGATOR_WITH_PINOCCHIO)
218231
list(APPEND CFLAGS_DEPENDENCIES "-DALIGATOR_WITH_PINOCCHIO")
232+
set(PINOCCHIO_V3 ${pinocchio_VERSION} VERSION_GREATER "3.0.0")
233+
if(PINOCCHIO_V3)
234+
add_compile_definitions(ALIGATOR_PINOCCHIO_V3)
235+
endif()
236+
elseif(PROXSUITE_NLP_WITH_PINOCCHIO_SUPPORT)
237+
message(
238+
WARNING
239+
"Aligator is being built without Pinocchio features, although the provided version of proxsuite-nlp has Pinocchio support. "
240+
"Make sure this is what you want."
241+
)
219242
endif()
220243

221244
if(BUILD_CROCODDYL_COMPAT)
222-
message(STATUS "Building with Crocoddyl compatibility.")
245+
message(STATUS "Building with Crocoddyl support.")
223246
add_compile_definitions(ALIGATOR_WITH_CROCODDYL_COMPAT)
224247
list(APPEND CFLAGS_DEPENDENCIES "-DALIGATOR_WITH_CROCODDYL_COMPAT")
225248
endif()
@@ -238,21 +261,13 @@ if(BUILD_WITH_CHOLMOD_SUPPORT)
238261
add_compile_definitions(ALIGATOR_WITH_CHOLMOD)
239262
endif()
240263

241-
set(BOOST_REQUIRED_COMPONENTS filesystem)
242-
set_boost_default_options()
243-
export_boost_default_options()
244-
add_project_dependency(Boost REQUIRED COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
245-
246264
if(BUILD_PYTHON_INTERFACE)
247265
set(PYTHON_COMPONENTS Interpreter Development NumPy)
248-
findpython(REQUIRED)
249266
add_project_dependency(eigenpy 3.7.0 REQUIRED PKG_CONFIG_REQUIRES "eigenpy >= 3.7.0")
250267
set(PYLIB_NAME "py${PROJECT_NAME}")
251268
set(${PYLIB_NAME}_INSTALL_DIR ${PYTHON_SITELIB}/${PROJECT_NAME})
252269
endif()
253270

254-
add_project_dependency(proxsuite-nlp 0.8.0 REQUIRED PKG_CONFIG_REQUIRES "proxsuite-nlp >= 0.8.0")
255-
256271
set(LIB_SOURCES src/utils/exceptions.cpp src/utils/logger.cpp)
257272

258273
file(
@@ -432,9 +447,14 @@ add_subdirectory(bindings)
432447

433448
# benchmarks, examples, and tests
434449

435-
macro(create_ex_or_bench exfile exname)
450+
macro(create_ex_or_bench is_bench exfile exname)
436451
add_executable(${exname} ${exfile})
437-
message(STATUS "Adding cpp example ${exname}")
452+
if(${is_bench})
453+
set(ex_type "bench")
454+
else()
455+
set(ex_type "example")
456+
endif()
457+
message(STATUS "Adding cpp ${ex_type} ${exname}")
438458
set_target_properties(${exname} PROPERTIES LINKER_LANGUAGE CXX)
439459
set_standard_output_directory(${exname})
440460
target_include_directories(${exname} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
@@ -483,13 +503,6 @@ if(BUILD_BENCHMARKS OR BUILD_TESTING)
483503
set_standard_output_directory(gar_test_utils)
484504
endif()
485505

486-
if(
487-
BUILD_WITH_PINOCCHIO_SUPPORT
488-
AND ${pinocchio_VERSION} VERSION_GREATER "2.9.0"
489-
)
490-
set(PINOCCHIO_V3 True)
491-
endif()
492-
493506
if(PINOCCHIO_V3 AND (BUILD_EXAMPLES OR BUILD_BENCHMARKS))
494507
add_library(
495508
talos_walk_utils
@@ -534,19 +547,19 @@ macro(EXPORT_VARIABLE var_name var_value)
534547
endmacro()
535548

536549
if(BUILD_WITH_PINOCCHIO_SUPPORT)
537-
export_variable(ALIGATOR_WITH_PINOCCHIO_SUPPORT ON)
550+
EXPORT_VARIABLE(ALIGATOR_WITH_PINOCCHIO_SUPPORT ON)
538551
endif()
539552
if(ENABLE_TEMPLATE_INSTANTIATION)
540-
export_variable(ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION ON)
553+
EXPORT_VARIABLE(ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION ON)
541554
endif()
542555
if(BUILD_PYTHON_INTERFACE)
543-
export_variable(ALIGATOR_WITH_PYTHON_INTERFACE ON)
556+
EXPORT_VARIABLE(ALIGATOR_WITH_PYTHON_INTERFACE ON)
544557
endif()
545558
if(BUILD_WITH_OPENMP_SUPPORT)
546-
export_variable(ALIGATOR_WITH_OPENMP_SUPPORT ON)
559+
EXPORT_VARIABLE(ALIGATOR_WITH_OPENMP_SUPPORT ON)
547560
endif()
548561
if(BUILD_CROCODDYL_COMPAT)
549-
export_variable(ALIGATOR_WITH_CROCODDYL_COMPAT ON)
562+
EXPORT_VARIABLE(ALIGATOR_WITH_CROCODDYL_COMPAT ON)
550563
pkg_config_append_libs(aligator_croc_compat)
551564
endif()
552565

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ It's used by our CI agent so you have the guarantee to get the right dependencie
4848
Run the following command to install dependencies, configure, build and test the project:
4949

5050
```bash
51-
pixi run -e all test
51+
pixi run test
5252
```
5353

5454
The project will be built in the `build` directory.

bench/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#
2-
# Copyright (C) 2023 LAAS-CNRS, INRIA
2+
# Copyright (C) 2023-2024 LAAS-CNRS, INRIA
33
#
44

55
# Create a benchmark
66
function(create_bench exfile croc)
77
get_filename_component(exname ${exfile} NAME_WE)
88
set(exname "bench-${exname}")
9-
create_ex_or_bench(${exfile} ${exname})
9+
create_ex_or_bench(TRUE ${exfile} ${exname})
1010

1111
target_include_directories(${exname} PRIVATE ../examples)
1212
target_link_libraries(${exname} PRIVATE benchmark::benchmark)

bindings/python/src/modelling/expose-fly-high.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// @file
22
/// @copyright Copyright (C) 2023 LAAS-CNRS, INRIA
3-
#include "aligator/modelling/multibody/context.hpp"
43
#ifdef ALIGATOR_WITH_PINOCCHIO
4+
#include "aligator/modelling/multibody/context.hpp"
55

66
#include "aligator/python/fwd.hpp"
77
#include "aligator/python/modelling/multibody-utils.hpp"

bindings/python/src/modelling/expose-freefwd.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/// @copyright Copyright (C) 2022 LAAS-CNRS, INRIA
1+
/// @copyright Copyright (C) 2022-2024 LAAS-CNRS, INRIA
2+
#ifdef ALIGATOR_WITH_PINOCCHIO
23
#include "aligator/modelling/dynamics/context.hpp"
34
#include "aligator/python/fwd.hpp"
45

@@ -55,3 +56,4 @@ void exposeFreeFwdDynamics() {
5556
}
5657
} // namespace python
5758
} // namespace aligator
59+
#endif

bindings/python/src/modelling/expose-gravity-compensation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// @copyright Copyright (C) 2024 LAAS-CNRS, INRIA
2+
#ifdef ALIGATOR_WITH_PINOCCHIO
13
#include "aligator/python/fwd.hpp"
24
#include "aligator/modelling/multibody/context.hpp"
35
#include "aligator/modelling/multibody/gravity-compensation-residual.hpp"
@@ -30,3 +32,4 @@ void exposeGravityCompensation() {
3032
}
3133

3234
} // namespace aligator::python
35+
#endif

bindings/python/src/modelling/expose-kinodynamics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// @copyright Copyright (C) 2022 LAAS-CNRS, INRIA
22
#include "aligator/python/fwd.hpp"
33

4+
#ifdef PROXSUITE_NLP_WITH_PINOCCHIO
45
#include "aligator/modelling/dynamics/kinodynamics-fwd.hpp"
56
#include <pinocchio/multibody/fwd.hpp>
67
#include <proxsuite-nlp/modelling/spaces/multibody.hpp>
@@ -49,3 +50,4 @@ void exposeKinodynamics() {
4950
}
5051
} // namespace python
5152
} // namespace aligator
53+
#endif

examples/CMakeLists.txt

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,60 @@
11
#
2-
# Copyright (C) 2022-2023 LAAS-CNRS, INRIA
2+
# Copyright (C) 2022-2024 LAAS-CNRS, INRIA
33
#
44

55
cmake_policy(SET CMP0057 NEW)
66

77
# Create an example
8-
macro(create_example exfile)
8+
function(create_example exfile)
9+
set(options "")
10+
set(oneValueArgs "")
11+
set(multiValueArgs DEPENDENCIES)
12+
13+
cmake_parse_arguments(
14+
arg_crex
15+
"${options}"
16+
"${oneValueArgs}"
17+
"${multiValueArgs}"
18+
${ARGN}
19+
)
20+
921
get_filename_component(exname ${exfile} NAME_WE)
1022
set(exname "${PROJECT_NAME}-example-${exname}")
11-
create_ex_or_bench(${exfile} ${exname})
12-
endmacro()
13-
14-
function(create_example_with_croco exfile)
15-
create_example(${exfile})
16-
target_link_libraries(
17-
${exname}
18-
PRIVATE aligator::croc_compat croc_talos_arm_utils
19-
)
23+
create_ex_or_bench(False ${exfile} ${exname})
24+
if(DEFINED arg_crex_DEPENDENCIES)
25+
message(" > depends on ${arg_crex_DEPENDENCIES}")
26+
foreach(dep ${arg_crex_DEPENDENCIES})
27+
target_link_libraries(${exname} PRIVATE ${dep})
28+
endforeach()
29+
endif()
2030
endfunction()
2131

22-
create_example(se2-car.cpp)
23-
create_example(clqr.cpp)
32+
set(EXAMPLES_LIST clqr)
33+
34+
if(PROXSUITE_NLP_WITH_PINOCCHIO_SUPPORT)
35+
list(APPEND EXAMPLES_LIST se2-car)
36+
endif()
37+
if(PINOCCHIO_V3)
38+
list(APPEND EXAMPLES_LIST talos-walk)
39+
endif()
40+
41+
foreach(filename ${EXAMPLES_LIST})
42+
create_example(${filename}.cpp)
43+
endforeach()
44+
2445
if(PINOCCHIO_V3)
25-
create_example(talos-walk.cpp)
26-
target_add_talos_walk(${exname})
46+
target_add_talos_walk(aligator-example-talos-walk)
2747
endif()
2848

2949
if(BUILD_CROCODDYL_COMPAT)
30-
create_example_with_croco(talos-arm.cpp)
31-
target_add_example_robot_data(${exname})
50+
add_project_private_dependency(example-robot-data 4.0.9 REQUIRED)
51+
create_example(
52+
talos-arm.cpp
53+
DEPENDENCIES
54+
aligator::croc_compat
55+
croc_talos_arm_utils
56+
example-robot-data::example-robot-data
57+
)
3258
endif()
3359

3460
file(GLOB EXAMPLES_PY *.py)

include/aligator/fwd.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
#ifdef ALIGATOR_WITH_PINOCCHIO
1010
#include <pinocchio/config.hpp>
11-
#if PINOCCHIO_VERSION_AT_LEAST(3, 0, 0)
12-
#define ALIGATOR_PINOCCHIO_V3
13-
#endif
1411
#endif
1512

1613
#include "aligator/math.hpp"

include/aligator/modelling/dynamics/kinodynamics-fwd.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "aligator/modelling/dynamics/ode-abstract.hpp"
55

6+
#ifdef PROXSUITE_NLP_WITH_PINOCCHIO
7+
68
#include <Eigen/LU>
79
#include <proxsuite-nlp/modelling/spaces/multibody.hpp>
810
#include <pinocchio/multibody/model.hpp>
@@ -99,3 +101,4 @@ struct KinodynamicsFwdDataTpl : ContinuousDynamicsDataTpl<Scalar> {
99101
} // namespace aligator
100102

101103
#include "aligator/modelling/dynamics/kinodynamics-fwd.hxx"
104+
#endif

include/aligator/modelling/dynamics/kinodynamics-fwd.hxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/// @copyright Copyright (C) 2022 LAAS-CNRS, INRIA
22
#pragma once
33

4+
#include "aligator/fwd.hpp"
5+
#ifdef PROXSUITE_NLP_WITH_PINOCCHIO
46
#include "aligator/modelling/dynamics/kinodynamics-fwd.hpp"
57

68
#include <pinocchio/algorithm/centroidal-derivatives.hpp>
@@ -227,3 +229,4 @@ KinodynamicsFwdDataTpl<Scalar>::KinodynamicsFwdDataTpl(
227229
}
228230
} // namespace dynamics
229231
} // namespace aligator
232+
#endif

include/aligator/modelling/dynamics/multibody-free-fwd.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "aligator/modelling/dynamics/ode-abstract.hpp"
55

6+
#ifdef ALIGATOR_WITH_PINOCCHIO
67
#include <proxsuite-nlp/modelling/spaces/multibody.hpp>
78
#include <pinocchio/multibody/data.hpp>
89

@@ -86,3 +87,4 @@ struct MultibodyFreeFwdDataTpl : ContinuousDynamicsDataTpl<Scalar> {
8687
#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
8788
#include "aligator/modelling/dynamics/multibody-free-fwd.txx"
8889
#endif
90+
#endif

include/aligator/modelling/multibody/contact-force.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#pragma once
22

3+
#ifdef ALIGATOR_PINOCCHIO_V3
4+
35
#include "./fwd.hpp"
46
#include "aligator/core/function-abstract.hpp"
57

68
#include <Eigen/src/Core/util/Constants.h>
79
#include <proxsuite-nlp/modelling/spaces/multibody.hpp>
8-
9-
#ifdef ALIGATOR_PINOCCHIO_V3
1010
#include <pinocchio/algorithm/proximal.hpp>
1111

1212
namespace aligator {

include/aligator/modelling/multibody/contact-force.hxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#ifdef ALIGATOR_PINOCCHIO_V3
4+
35
#include "aligator/modelling/multibody/contact-force.hpp"
46

57
#include <pinocchio/algorithm/constrained-dynamics.hpp>
@@ -60,3 +62,4 @@ ContactForceDataTpl<Scalar>::ContactForceDataTpl(
6062
}
6163

6264
} // namespace aligator
65+
#endif

0 commit comments

Comments
 (0)