continuous_joint_pose.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 
33 
34 namespace exotica
35 {
37 {
38  if (phi.rows() != N_) ThrowNamed("Wrong size of Phi!");
39  for (std::size_t i = 0; i < joint_map_.size(); ++i)
40  {
41  phi(2 * i + 0) = std::cos(x(joint_map_[i]));
42  phi(2 * i + 1) = std::sin(x(joint_map_[i]));
43  }
44 }
45 
47 {
48  if (phi.rows() != N_) ThrowNamed("Wrong size of Phi!");
49  if (jacobian.rows() != N_) ThrowNamed("Wrong size of jacobian! " << N_);
50  jacobian.setZero();
51  for (std::size_t i = 0; i < joint_map_.size(); ++i)
52  {
53  phi(2 * i + 0) = std::cos(x(joint_map_[i]));
54  phi(2 * i + 1) = std::sin(x(joint_map_[i]));
55 
56  // Jacobian
57  jacobian(2 * i + 0, joint_map_[i]) = -std::sin(x(joint_map_[i]));
58  jacobian(2 * i + 1, joint_map_[i]) = std::cos(x(joint_map_[i]));
59  }
60 }
61 
63 {
64  if (phi.rows() != N_) ThrowNamed("Wrong size of Phi!");
65  if (jacobian.rows() != N_) ThrowNamed("Wrong size of jacobian! " << N_);
66  if (hessian.size() != N_) ThrowNamed("Wrong size of Hessian!" << N_ << " vs " << hessian.size());
67 
68  for (std::size_t i = 0; i < joint_map_.size(); ++i)
69  {
70  phi(2 * i + 0) = std::cos(x(joint_map_[i]));
71  phi(2 * i + 1) = std::sin(x(joint_map_[i]));
72 
73  // Jacobian
74  jacobian(2 * i + 0, joint_map_[i]) = -std::sin(x(joint_map_[i]));
75  jacobian(2 * i + 1, joint_map_[i]) = std::cos(x(joint_map_[i]));
76 
77  // Hessian
78  hessian(2 * i + 0)(joint_map_[i], joint_map_[i]) = -std::cos(x(joint_map_[i]));
79  hessian(2 * i + 1)(joint_map_[i], joint_map_[i]) = -std::sin(x(joint_map_[i]));
80  }
81 }
82 
84 {
85  scene_ = scene;
86  Initialize();
87 }
88 
90 {
91  const int num_controlled_joints = scene_->GetKinematicTree().GetNumControlledJoints();
92  if (parameters_.JointMap.rows() > 0)
93  {
94  if (parameters_.JointMap.rows() > num_controlled_joints)
95  ThrowPretty("Number of mapped joints greater than controlled joints!");
96 
97  joint_map_.resize(parameters_.JointMap.rows());
98  for (int i = 0; i < parameters_.JointMap.rows(); ++i)
99  {
100  joint_map_[i] = parameters_.JointMap(i);
101  }
102  }
103  else
104  {
105  joint_map_.resize(num_controlled_joints);
106  for (int i = 0; i < num_controlled_joints; ++i)
107  {
108  joint_map_[i] = i;
109  }
110  }
111  N_ = 2 * joint_map_.size();
112 }
113 
115 {
116  return N_;
117 }
118 } // namespace exotica
Eigen::Ref< Eigen::VectorXd > VectorXdRef
#define ThrowPretty(m)
std::shared_ptr< Scene > ScenePtr
#define ThrowNamed(m)
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Eigen::Ref< Hessian > HessianRef
void AssignScene(ScenePtr scene) override
Eigen::Ref< Eigen::MatrixXd > MatrixXdRef
REGISTER_TASKMAP_TYPE("ContinuousJointPose", exotica::ContinuousJointPose)
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