Directory: | ./ |
---|---|
File: | bindings/python/crocoddyl/crocoddyl.cpp |
Date: | 2025-03-26 19:23:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 19 | 19 | 100.0% |
Branches: | 24 | 48 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh, INRIA, | ||
5 | // Heriot-Watt University | ||
6 | // University of Oxford Copyright note valid unless otherwise stated in | ||
7 | // individual files. All rights reserved. | ||
8 | /////////////////////////////////////////////////////////////////////////////// | ||
9 | |||
10 | #include "crocoddyl/core/utils/version.hpp" | ||
11 | #include "python/crocoddyl/fwd.hpp" | ||
12 | #include "python/crocoddyl/utils/set-converter.hpp" | ||
13 | #include "python/crocoddyl/utils/vector-converter.hpp" | ||
14 | |||
15 | namespace crocoddyl { | ||
16 | namespace python { | ||
17 | |||
18 | namespace bp = boost::python; | ||
19 | |||
20 |
2/4✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
|
40 | BOOST_PYTHON_MODULE(libcrocoddyl_pywrap) { |
21 |
5/10✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 10 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
|
20 | bp::scope().attr("__version__") = crocoddyl::printVersion(); |
22 |
3/6✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
|
20 | bp::scope().attr("__raw_version__") = bp::str(CROCODDYL_VERSION); |
23 | |||
24 | 40 | bp::enum_<DType>("DType") | |
25 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | .value("Float64", DType::Float64) |
26 |
1/2✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
|
20 | .value("Float32", DType::Float32) |
27 | #ifdef CROCODDYL_WITH_CODEGEN_DISABLE | ||
28 | .value("ADFloat64", DType::ADFloat64) | ||
29 | #endif | ||
30 | ; | ||
31 | |||
32 | 20 | eigenpy::enableEigenPy(); | |
33 | |||
34 | typedef double Scalar; | ||
35 | typedef Eigen::Matrix<Scalar, 4, 1> Vector4; | ||
36 | typedef Eigen::Matrix<Scalar, 6, 1> Vector6; | ||
37 | typedef Eigen::Matrix<Scalar, 4, 6> Matrix46; | ||
38 | typedef Eigen::Matrix<Scalar, 6, Eigen::Dynamic> Matrix6x; | ||
39 | typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 3> MatrixX3; | ||
40 | typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> VectorX; | ||
41 | typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> MatrixX; | ||
42 | typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> | ||
43 | RowMatrixX; | ||
44 | |||
45 | 20 | eigenpy::enableEigenPySpecific<Vector4>(); | |
46 | 20 | eigenpy::enableEigenPySpecific<Vector6>(); | |
47 | 20 | eigenpy::enableEigenPySpecific<Matrix46>(); | |
48 | 20 | eigenpy::enableEigenPySpecific<MatrixX3>(); | |
49 | 20 | eigenpy::enableEigenPySpecific<Matrix6x>(); | |
50 | |||
51 | // Register converters between std::vector and Python list | ||
52 |
3/6✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
|
20 | StdVectorPythonVisitor<std::vector<VectorX>, true>::expose("StdVec_VectorX"); |
53 |
3/6✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
|
20 | StdVectorPythonVisitor<std::vector<MatrixX>, true>::expose("StdVec_MatrixX"); |
54 |
3/6✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
|
20 | StdVectorPythonVisitor<std::vector<RowMatrixX>, true>::expose( |
55 | "StdVec_RowMatrixX"); | ||
56 | |||
57 | // Register converters between std::set and Python set | ||
58 | StdSetPythonVisitor<std::string, std::less<std::string>, | ||
59 | std::allocator<std::string>, | ||
60 |
3/6✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
|
20 | true>::expose("StdSet_String"); |
61 | |||
62 | 20 | exposeCore(); | |
63 | 20 | exposeMultibody(); | |
64 | 20 | } | |
65 | |||
66 | } // namespace python | ||
67 | } // namespace crocoddyl | ||
68 |