joint_torque_minimization_proxy.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019, Wolfgang Merkt
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without specific
15 // prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 
31 
32 REGISTER_TASKMAP_TYPE("JointTorqueMinimizationProxy", exotica::JointTorqueMinimizationProxy);
33 
34 namespace exotica
35 {
36 void JointTorqueMinimizationProxy::Instantiate(const JointTorqueMinimizationProxyInitializer& init)
37 {
38  parameters_ = init;
39  if (init.h.size() != 6)
40  {
41  ThrowPretty("Size of selection vector h needs to be 6, got " << init.h.size());
42  }
43  h_ = init.h;
44 }
45 
46 Eigen::Matrix<double, 6, 1> JointTorqueMinimizationProxy::get_h() const
47 {
48  return h_;
49 }
50 
51 void JointTorqueMinimizationProxy::set_h(const Eigen::Matrix<double, 6, 1>& h_in)
52 {
53  if (h_in.size() != 6)
54  ThrowPretty("Wrong size!");
55  h_ = h_in;
56 }
57 
59 {
60  if (phi.rows() != static_cast<int>(frames_.size())) ThrowNamed("Wrong size of Phi!");
61  for (int i = 0; i < kinematics[0].Phi.rows(); ++i)
62  {
63  phi(i) = h_.transpose() * kinematics[0].jacobian[i].data * kinematics[0].jacobian[i].data.transpose() * h_;
64  }
65 }
66 
67 // void JointTorqueMinimizationProxy::Update(Eigen::VectorXdRefConst x, Eigen::VectorXdRef phi, Eigen::MatrixXdRef jacobian)
68 // {
69 // if (phi.rows() != frames_.size()) ThrowNamed("Wrong size of Phi!");
70 // for (int i = 0; i < kinematics[0].Phi.rows(); ++i)
71 // {
72 // phi(i) = h_.transpose() * kinematics[0].jacobian[i].data * kinematics[0].jacobian[i].data.transpose() * h_;
73 // Eigen::MatrixXd Jdot = scene_->GetKinematicTree().Jdot(kinematics[0].jacobian[i]);
74 // HIGHLIGHT("Jdot size:" << Jdot.rows() << "x" << Jdot.cols())
75 // HIGHLIGHT("Jacobian size:" << kinematics[0].jacobian[i].data.rows() << "x" << kinematics[0].jacobian[i].data.cols())
76 // HIGHLIGHT("h_ size:" << h_.rows() << "x" << h_.cols())
77 // HIGHLIGHT("jacobian-i size:" << jacobian.row(i).rows() << "x" << jacobian.row(i).cols())
78 // jacobian.row(i) = 2 * (h_.transpose() * Jdot).transpose() * kinematics[0].jacobian[i].data;
79 // }
80 // }
81 
83 {
84  return frames_.size();
85 }
86 } // namespace exotica
Eigen::Matrix< double, 6, 1 > get_h() const
void set_h(const Eigen::Matrix< double, 6, 1 > &h_in)
std::vector< KinematicFrameRequest > frames_
void Instantiate(const JointTorqueMinimizationProxyInitializer &init) override
Eigen::Ref< Eigen::VectorXd > VectorXdRef
#define ThrowPretty(m)
#define ThrowNamed(m)
REGISTER_TASKMAP_TYPE("JointTorqueMinimizationProxy", exotica::JointTorqueMinimizationProxy)
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
void Update(Eigen::VectorXdRefConst x, Eigen::VectorXdRef phi) override


exotica_core_task_maps
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Sat Apr 10 2021 02:36:09