Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2018-2020, LAAS-CNRS, University of Edinburgh |
5 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
6 |
|
|
// All rights reserved. |
7 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
8 |
|
|
|
9 |
|
|
#ifndef BINDINGS_PYTHON_CROCODDYL_CORE_ACTION_BASE_HPP_ |
10 |
|
|
#define BINDINGS_PYTHON_CROCODDYL_CORE_ACTION_BASE_HPP_ |
11 |
|
|
|
12 |
|
|
#include <quadruped-walkgen/quadruped.hpp> |
13 |
|
|
#include <quadruped-walkgen/quadruped_augmented.hpp> |
14 |
|
|
#include <quadruped-walkgen/quadruped_augmented_time.hpp> |
15 |
|
|
#include <quadruped-walkgen/quadruped_nl.hpp> |
16 |
|
|
#include <quadruped-walkgen/quadruped_step.hpp> |
17 |
|
|
#include <quadruped-walkgen/quadruped_step_period.hpp> |
18 |
|
|
#include <quadruped-walkgen/quadruped_step_time.hpp> |
19 |
|
|
#include <quadruped-walkgen/quadruped_time.hpp> |
20 |
|
|
|
21 |
|
|
#include "core.hpp" |
22 |
|
|
#include "crocoddyl/core/utils/exception.hpp" |
23 |
|
|
|
24 |
|
|
namespace quadruped_walkgen { |
25 |
|
|
namespace python { |
26 |
|
|
|
27 |
|
|
class ActionModelAbstract_wrap : public ActionModelAbstract, |
28 |
|
|
public bp::wrapper<ActionModelAbstract> { |
29 |
|
|
public: |
30 |
|
✗ |
ActionModelAbstract_wrap(boost::shared_ptr<StateAbstract> state, |
31 |
|
✗ |
const std::size_t& nu, const std::size_t& nr = 1) |
32 |
|
✗ |
: ActionModelAbstract(state, nu, nr), |
33 |
|
✗ |
bp::wrapper<ActionModelAbstract>() {} |
34 |
|
|
|
35 |
|
✗ |
void calc(const boost::shared_ptr<ActionDataAbstract>& data, |
36 |
|
|
const Eigen::Ref<const Eigen::VectorXd>& x, |
37 |
|
|
const Eigen::Ref<const Eigen::VectorXd>& u) { |
38 |
|
✗ |
if (static_cast<std::size_t>(x.size()) != state_->get_nx()) { |
39 |
|
✗ |
throw_pretty("Invalid argument: " |
40 |
|
|
<< "x has wrong dimension (it should be " + |
41 |
|
|
std::to_string(state_->get_nx()) + ")"); |
42 |
|
|
} |
43 |
|
✗ |
if (static_cast<std::size_t>(u.size()) != nu_) { |
44 |
|
✗ |
throw_pretty("Invalid argument: " |
45 |
|
|
<< "u has wrong dimension (it should be " + |
46 |
|
|
std::to_string(nu_) + ")"); |
47 |
|
|
} |
48 |
|
✗ |
return bp::call<void>(this->get_override("calc").ptr(), data, |
49 |
|
✗ |
(Eigen::VectorXd)x, (Eigen::VectorXd)u); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
✗ |
void calcDiff(const boost::shared_ptr<ActionDataAbstract>& data, |
53 |
|
|
const Eigen::Ref<const Eigen::VectorXd>& x, |
54 |
|
|
const Eigen::Ref<const Eigen::VectorXd>& u) { |
55 |
|
✗ |
if (static_cast<std::size_t>(x.size()) != state_->get_nx()) { |
56 |
|
✗ |
throw_pretty("Invalid argument: " |
57 |
|
|
<< "x has wrong dimension (it should be " + |
58 |
|
|
std::to_string(state_->get_nx()) + ")"); |
59 |
|
|
} |
60 |
|
✗ |
if (static_cast<std::size_t>(u.size()) != nu_) { |
61 |
|
✗ |
throw_pretty("Invalid argument: " |
62 |
|
|
<< "u has wrong dimension (it should be " + |
63 |
|
|
std::to_string(nu_) + ")"); |
64 |
|
|
} |
65 |
|
✗ |
return bp::call<void>(this->get_override("calcDiff").ptr(), data, |
66 |
|
✗ |
(Eigen::VectorXd)x, (Eigen::VectorXd)u); |
67 |
|
|
} |
68 |
|
|
}; |
69 |
|
|
|
70 |
|
|
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(ActionModel_quasiStatic_wraps, |
71 |
|
|
ActionModelAbstract::quasiStatic_x, 2, 4) |
72 |
|
|
|
73 |
|
|
} // namespace python |
74 |
|
|
} // namespace quadruped_walkgen |
75 |
|
|
|
76 |
|
|
#endif // BINDINGS_PYTHON_CROCODDYL_CORE_ACTION_BASE_HPP_ |
77 |
|
|
|