VelocityManipulatingTorque.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2017, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarX
19  * @author Mirko Waechter( mirko.waechter at kit dot edu)
20  * @date 2018
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #pragma once
27 
28 
29 // STD/STL
30 #include <cmath>
31 
32 // armarx
34 
36 
37 // control
40 
41 
43 {
45  std::shared_ptr<class VelocityManipulatingTorqueControllerConfiguration>;
46 
48  {
49  public:
53  bool limitless,
54  float jointLimitLow,
55  float jointLimitHigh);
57  double pid_integral_gain = 0;
58  double pid_derivative_gain = 0;
59  double pid_max_value = 1.0;
60  double accelerationGain = 0.1;
61  double deadZone = 0.1;
62  double decay = 0.99;
63  double maxVelocity = 3.0;
64  double maxAcceleration = 10.0;
65  double maxJerk = 500.0;
66  double torqueToCurrent = 0.0;
67  double maxTargetTorque = 10.0;
68  bool limitless = true;
69  double jointLimitHigh = 0.0, jointLimitLow = 0.0;
70  double pushbackMargin = 5.0 / 180. * M_PI;
71  double pushBackTorque = 100;
72  std::vector<float> firFilterImpulseResponse;
73  };
74 
76  {
77  public:
80  float update(const IceUtil::Time& sensorValuesTimestamp,
81  const IceUtil::Time& timeSinceLastIteration,
82  float gravity,
83  float actualTorque,
84  float targetTorque,
85  float actualVelocity,
86  float actualPosition);
87  void reset();
88 
89 
90  double getCurrentTargetVelocity() const;
91 
92  // const VelocityManipulatingTorqueControllerConfigurationPtr& getTorqueConfigData() const;
94 
96  const PIDController& getPid();
97  double getLastAcceleration() const;
98 
99  double getLastJerk() const;
100 
101  protected:
102  double calcJointLimitProtectionTorque(float actualPosition);
103 
104  private:
105  PIDController pid;
106  PIDController pidTargetTorque;
107  std::mutex pidParameterMutex;
108  armarx::rtfilters::GaussianFilter torqueGaussianFilter;
109  armarx::control::rt_filters::RtMedianFilter torqueMedianFilter, actualVelocityFilter;
111  double currentTargetVelocity = 0.0;
112  double lastAcceleration = 0.0;
113  double lastJerk = 0.0;
114  };
115 
116 } // namespace armarx::control::joint_controller
GaussianFilter.h
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::VelocityManipulatingTorqueControllerConfiguration
VelocityManipulatingTorqueControllerConfiguration()
Definition: VelocityManipulatingTorque.cpp:87
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::pid_integral_gain
double pid_integral_gain
Definition: VelocityManipulatingTorque.h:57
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::maxJerk
double maxJerk
Definition: VelocityManipulatingTorque.h:65
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::deadZone
double deadZone
Definition: VelocityManipulatingTorque.h:61
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::torqueToCurrent
double torqueToCurrent
Definition: VelocityManipulatingTorque.h:66
armarx::rtfilters::GaussianFilter
Definition: GaussianFilter.h:32
armarx::control::joint_controller::VelocityManipulatingTorqueController::getPid
const PIDController & getPid()
Definition: VelocityManipulatingTorque.cpp:280
ControllerConfiguration.h
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration
Definition: VelocityManipulatingTorque.h:47
armarx::control::joint_controller::VelocityManipulatingTorqueController::reset
void reset()
Definition: VelocityManipulatingTorque.cpp:238
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::decay
double decay
Definition: VelocityManipulatingTorque.h:62
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::accelerationGain
double accelerationGain
Definition: VelocityManipulatingTorque.h:60
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::pid_proportional_gain
double pid_proportional_gain
Definition: VelocityManipulatingTorque.h:56
armarx::control::joint_controller::VelocityManipulatingTorqueController::setTorqueConfigData
bool setTorqueConfigData(VelocityManipulatingTorqueControllerConfiguration configData)
Definition: VelocityManipulatingTorque.cpp:259
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::firFilterImpulseResponse
std::vector< float > firFilterImpulseResponse
Definition: VelocityManipulatingTorque.h:72
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::maxTargetTorque
double maxTargetTorque
Definition: VelocityManipulatingTorque.h:67
armarx::control::joint_controller::VelocityManipulatingTorqueController::getTorqueConfigData
VelocityManipulatingTorqueControllerConfiguration getTorqueConfigData() const
Definition: VelocityManipulatingTorque.cpp:253
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::jointLimitLow
double jointLimitLow
Definition: VelocityManipulatingTorque.h:69
armarx::control::joint_controller::VelocityManipulatingTorqueController::calcJointLimitProtectionTorque
double calcJointLimitProtectionTorque(float actualPosition)
Definition: VelocityManipulatingTorque.cpp:92
armarx::control::joint_controller::VelocityManipulatingTorqueController::VelocityManipulatingTorqueController
VelocityManipulatingTorqueController(const VelocityManipulatingTorqueControllerConfigurationPtr &torqueConfigData)
Definition: VelocityManipulatingTorque.cpp:35
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::jointLimitHigh
double jointLimitHigh
Definition: VelocityManipulatingTorque.h:69
M_PI
#define M_PI
Definition: MathTools.h:17
armarx::PIDController
Definition: PIDController.h:43
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::pushbackMargin
double pushbackMargin
Definition: VelocityManipulatingTorque.h:70
armarx::control::joint_controller::VelocityManipulatingTorqueController
Definition: VelocityManipulatingTorque.h:75
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfigurationPtr
std::shared_ptr< class VelocityManipulatingTorqueControllerConfiguration > VelocityManipulatingTorqueControllerConfigurationPtr
Definition: VelocityManipulatingTorque.h:45
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::pid_max_value
double pid_max_value
Definition: VelocityManipulatingTorque.h:59
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::joint_controller::VelocityManipulatingTorqueController::getCurrentTargetVelocity
double getCurrentTargetVelocity() const
Definition: VelocityManipulatingTorque.cpp:247
PIDController.h
armarx::control::joint_controller::VelocityManipulatingTorqueController::update
float update(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration, float gravity, float actualTorque, float targetTorque, float actualVelocity, float actualPosition)
Definition: VelocityManipulatingTorque.cpp:129
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::CreateTorqueConfigData
static VelocityManipulatingTorqueControllerConfigurationPtr CreateTorqueConfigData(hardware_config::Config &config, bool limitless, float jointLimitLow, float jointLimitHigh)
Definition: VelocityManipulatingTorque.cpp:54
armarx::control::joint_controller
Definition: ControllerConfiguration.cpp:3
armarx::control::hardware_config::Config
The Config class is the base class of all specialized configurations that have a direct key -> value ...
Definition: Config.h:91
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::maxVelocity
double maxVelocity
Definition: VelocityManipulatingTorque.h:63
RtMedianFilter.h
armarx::control::joint_controller::VelocityManipulatingTorqueController::getLastJerk
double getLastJerk() const
Definition: VelocityManipulatingTorque.cpp:117
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::limitless
bool limitless
Definition: VelocityManipulatingTorque.h:68
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::maxAcceleration
double maxAcceleration
Definition: VelocityManipulatingTorque.h:64
armarx::control::joint_controller::VelocityManipulatingTorqueController::getLastAcceleration
double getLastAcceleration() const
Definition: VelocityManipulatingTorque.cpp:123
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::pid_derivative_gain
double pid_derivative_gain
Definition: VelocityManipulatingTorque.h:58
armarx::control::joint_controller::VelocityManipulatingTorqueControllerConfiguration::pushBackTorque
double pushBackTorque
Definition: VelocityManipulatingTorque.h:71
armarx::control::rt_filters::RtMedianFilter
Definition: RtMedianFilter.h:14