CartesianVelocityRamp.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Sonja Marahrens (sonja dot marahrens)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #include "CartesianVelocityRamp.h"
25 
27 
28 namespace armarx
29 {
31  { }
32 
34  {
35  this->state = state;
36  this->mode = mode;
37  }
38 
39  Eigen::VectorXf CartesianVelocityRamp::update(const Eigen::VectorXf& target, float dt)
40  {
41  if (dt <= 0)
42  {
43  return state;
44  }
45  Eigen::VectorXf delta = target - state;
46  int i = 0;
47  float factor = 1 ;
48 
50  {
51  Eigen::Vector3f posDelta = delta.block<3, 1>(i, 0);
52  float posFactor = posDelta.norm() / maxPositionAcceleration / dt;
53  factor = std::max(factor, posFactor);
54  i += 3;
55  }
56 
58  {
59  Eigen::Vector3f oriDelta = delta.block<3, 1>(i, 0);
60  float oriFactor = oriDelta.norm() / maxOrientationAcceleration / dt;
61  factor = std::max(factor, oriFactor);
62  }
63 
64  state += delta / factor;
65  // ARMARX_IMPORTANT << "CartRamp state " << state;
66  return state;
67  }
68 
69  void CartesianVelocityRamp::setMaxPositionAcceleration(float maxPositionAcceleration)
70  {
71  this->maxPositionAcceleration = maxPositionAcceleration;
72 
73  }
74 
75  void CartesianVelocityRamp::setMaxOrientationAcceleration(float maxOrientationAcceleration)
76  {
77  this->maxOrientationAcceleration = maxOrientationAcceleration;
78 
79  }
80 
82  {
83  return maxPositionAcceleration;
84  }
85 
87  {
88  return maxOrientationAcceleration;
89  }
90 }
91 
armarx::CartesianVelocityRamp::CartesianVelocityRamp
CartesianVelocityRamp()
Definition: CartesianVelocityRamp.cpp:30
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:9
armarx::CartesianVelocityRamp::setState
void setState(const Eigen::VectorXf &state, VirtualRobot::IKSolver::CartesianSelection mode)
Definition: CartesianVelocityRamp.cpp:33
armarx::CartesianVelocityRamp::setMaxPositionAcceleration
void setMaxPositionAcceleration(float maxPositionAcceleration)
Definition: CartesianVelocityRamp.cpp:69
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
armarx::CartesianVelocityRamp::setMaxOrientationAcceleration
void setMaxOrientationAcceleration(float maxOrientationAcceleration)
Definition: CartesianVelocityRamp.cpp:75
armarx::CartesianVelocityRamp::update
Eigen::VectorXf update(const Eigen::VectorXf &target, float dt)
Definition: CartesianVelocityRamp.cpp:39
armarx::NJointTaskSpaceDMPControllerMode::CartesianSelection
CartesianSelection
Definition: ControllerInterface.ice:34
max
T max(T t1, T t2)
Definition: gdiam.h:48
armarx::CartesianVelocityRamp::getMaxPositionAcceleration
float getMaxPositionAcceleration()
Definition: CartesianVelocityRamp.cpp:81
CartesianVelocityRamp.h
armarx::CartesianVelocityRamp::getMaxOrientationAcceleration
float getMaxOrientationAcceleration()
Definition: CartesianVelocityRamp.cpp:86
Logging.h
armarx::navigation::core::Position
Eigen::Vector3f Position
Definition: basic_types.h:36
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
dt
constexpr T dt
Definition: UnscentedKalmanFilterTest.cpp:42