GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/crocoddyl-float.cpp
Date: 2025-04-18 16:41:15
Exec Total Coverage
Lines: 0 15 0.0%
Branches: 0 44 0.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 // Auto-generated file for float
11 #include "crocoddyl/core/utils/version.hpp"
12 #include "python/crocoddyl/fwd.hpp"
13 #include "python/crocoddyl/utils/set-converter.hpp"
14 #include "python/crocoddyl/utils/vector-converter.hpp"
15
16 #define SCALAR_float32
17
18 namespace crocoddyl {
19 namespace python {
20
21 namespace bp = boost::python;
22
23 BOOST_PYTHON_MODULE(libcrocoddyl_pywrap_float32) {
24 bp::scope().attr("__version__") = crocoddyl::printVersion();
25 bp::scope().attr("__raw_version__") = bp::str(CROCODDYL_VERSION);
26
27 #ifdef SCALAR_float64
28 bp::enum_<DType>("DType")
29 .value("Float64", DType::Float64)
30 .value("Float32", DType::Float32)
31 #ifdef CROCODDYL_WITH_CODEGEN
32 .value("ADFloat64", DType::ADFloat64)
33 #endif
34 ;
35 #endif
36
37 eigenpy::enableEigenPy();
38 #ifdef CROCODDYL_WITH_CODEGEN
39 // Check if pycppad module is already importable
40 PyObject* pycppad_module = PyImport_ImportModule("pycppad");
41 if (pycppad_module != nullptr) {
42 Py_DECREF(pycppad_module); // don't leak
43 // Do not call enablePyCppAD, already imported
44 } else {
45 PyErr_Clear(); // clear the error if import failed
46 // pycppad::enablePyCppAD(); // not found, so we register the converters
47 }
48 bp::scope().attr("WITH_CODEGEN") = true;
49 #else
50 bp::scope().attr("WITH_CODEGEN") = false;
51 #endif
52
53 typedef double Scalar;
54 typedef Eigen::Matrix<Scalar, 4, 1> Vector4;
55 typedef Eigen::Matrix<Scalar, 6, 1> Vector6;
56 typedef Eigen::Matrix<Scalar, 4, 6> Matrix46;
57 typedef Eigen::Matrix<Scalar, 6, Eigen::Dynamic> Matrix6x;
58 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 3> MatrixX3;
59 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> VectorX;
60 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> MatrixX;
61 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
62 RowMatrixX;
63
64 eigenpy::enableEigenPySpecific<Vector4>();
65 eigenpy::enableEigenPySpecific<Vector6>();
66 eigenpy::enableEigenPySpecific<Matrix46>();
67 eigenpy::enableEigenPySpecific<MatrixX3>();
68 eigenpy::enableEigenPySpecific<Matrix6x>();
69
70 // Register converters between std::vector and Python list
71 StdVectorPythonVisitor<std::vector<VectorX>, true>::expose("StdVec_VectorX");
72 StdVectorPythonVisitor<std::vector<MatrixX>, true>::expose("StdVec_MatrixX");
73 StdVectorPythonVisitor<std::vector<RowMatrixX>, true>::expose(
74 "StdVec_RowMatrixX");
75
76 #ifdef SCALAR_float64
77 // Register converters between std::set and Python set
78 StdSetPythonVisitor<std::string, std::less<std::string>,
79 std::allocator<std::string>,
80 true>::expose("StdSet_String");
81 #endif
82
83 exposeCore();
84 exposeMultibody();
85 }
86
87 } // namespace python
88 } // namespace crocoddyl
89