forked from sammy-tri/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inverse_kinematics_pointwise.cc
65 lines (58 loc) · 2.46 KB
/
inverse_kinematics_pointwise.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <string>
#include <vector>
#include "drake/common/drake_assert.h"
#include "drake/multibody/inverse_kinematics_backend.h"
#include "drake/multibody/rigid_body_ik.h"
#include "drake/multibody/rigid_body_tree.h"
using Eigen::Map;
using Eigen::MatrixBase;
using Eigen::MatrixXd;
using drake::systems::plants::inverseKinBackend;
template <typename DerivedA, typename DerivedB, typename DerivedC>
void inverseKinPointwise(
RigidBodyTree<double>* model, const int nT, const double* t,
const MatrixBase<DerivedA>& q_seed, const MatrixBase<DerivedB>& q_nom,
const int num_constraints,
const RigidBodyConstraint* const* constraint_array,
const IKoptions& ikoptions, MatrixBase<DerivedC>* q_sol, int* info,
std::vector<std::string>* infeasible_constraint) {
inverseKinBackend(model, nT, t, q_seed, q_nom, num_constraints,
constraint_array, ikoptions, q_sol,
info, infeasible_constraint);
}
template void inverseKinPointwise(
RigidBodyTree<double>* model, const int nT, const double* t,
const MatrixBase<Map<MatrixXd>>& q_seed,
const MatrixBase<Map<MatrixXd>>& q_nom, const int num_constraints,
const RigidBodyConstraint* const* constraint_array,
const IKoptions& ikoptions, MatrixBase<Map<MatrixXd>>* q_sol, int *info,
std::vector<std::string>* infeasible_constraint);
template void inverseKinPointwise(
RigidBodyTree<double>* model, const int nT, const double* t,
const MatrixBase<MatrixXd>& q_seed, const MatrixBase<MatrixXd>& q_nom,
const int num_constraints,
const RigidBodyConstraint* const* constraint_array,
const IKoptions& ikoptions, MatrixBase<MatrixXd>* q_sol, int* info,
std::vector<std::string>* infeasible_constraint);
IKResults inverseKinPointwiseSimple(
RigidBodyTree<double>* model,
const Eigen::VectorXd& t,
const Eigen::MatrixXd& q_seed,
const Eigen::MatrixXd& q_nom,
const std::vector<RigidBodyConstraint*>& constraint_array,
const IKoptions& ikoptions) {
Eigen::MatrixXd q_sol_mat(model->get_num_positions(), t.size());
q_sol_mat.fill(0);
IKResults results;
results.info.resize(t.size(), 0);
inverseKinBackend(
model, t.size(), t.data(), q_seed, q_nom,
constraint_array.size(), constraint_array.data(),
ikoptions, &q_sol_mat, results.info.data(),
&results.infeasible_constraints);
results.q_sol.resize(t.size());
for (int i = 0; i < t.size(); i++) {
results.q_sol[i] = q_sol_mat.col(i);
}
return results;
}