NJointTaskSpaceImpedanceController.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package TaskSpaceActiveImpedanceControl::ArmarXObjects::NJointTaskSpaceImpedanceController
17  * @author zhou ( you dot zhou at kit dot edu )
18  * @date 2018
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <VirtualRobot/IK/DifferentialIK.h>
26 #include <VirtualRobot/Robot.h>
27 
32 #include <RobotAPI/interface/units/RobotUnit/TaskSpaceActiveImpedanceControl.h>
33 
34 #include "../ControllerParts/CartesianImpedanceController.h"
35 
36 namespace armarx
37 {
38  /**
39  * @defgroup Library-NJointTaskSpaceImpedanceController NJointTaskSpaceImpedanceController
40  * @ingroup Library-RobotUnit-NJointControllers
41  * A description of the library NJointTaskSpaceImpedanceController.
42  *
43  * @class NJointTaskSpaceImpedanceController
44  * @ingroup Library-NJointTaskSpaceImpedanceController
45  * @brief Brief description of class NJointTaskSpaceImpedanceController.
46  *
47  * Detailed description of class NJointTaskSpaceImpedanceController.
48  */
50  public NJointControllerWithTripleBuffer<CartesianImpedanceController::Config>,
51  public NJointTaskSpaceImpedanceControlInterface
52  {
53  public:
54  using ConfigPtrT = NJointTaskSpaceImpedanceControlConfigPtr;
55 
56  NJointTaskSpaceImpedanceController(const RobotUnitPtr& robotUnit,
57  const NJointControllerConfigPtr& config,
58  const VirtualRobot::RobotPtr&);
59 
60  std::string
61  getClassName(const Ice::Current&) const override
62  {
63  return "TaskSpaceImpedanceController";
64  }
65 
66  // NJointController interface
67  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
68  const IceUtil::Time& timeSinceLastIteration) override;
69 
70  protected:
71  void onPublish(const SensorAndControl&,
73  const DebugObserverInterfacePrx&) override;
74 
75  void setPosition(const Eigen::Vector3f&, const Ice::Current&) override;
76  void setOrientation(const Eigen::Quaternionf&, const Ice::Current&) override;
77  void setPositionOrientation(const Eigen::Vector3f& pos,
78  const Eigen::Quaternionf& ori,
79  const Ice::Current&) override;
80  void setPose(const Eigen::Matrix4f& mat, const Ice::Current&) override;
81 
82  void setImpedanceParameters(const std::string&,
83  const Ice::FloatSeq&,
84  const Ice::Current&) override;
85  void setNullspaceConfig(const Eigen::VectorXf& joint,
86  const Eigen::VectorXf& knull,
87  const Eigen::VectorXf& dnull,
88  const Ice::Current&) override;
89  void setConfig(const NJointTaskSpaceImpedanceControlRuntimeConfig& cfg,
90  const Ice::Current&) override;
91 
92  private:
93  std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors;
94  std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
95  std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
96 
97  std::vector<ControlTarget1DoFActuatorTorque*> targets;
98 
99  struct NJointTaskSpaceImpedanceControllerDebugInfo
100  {
101  StringFloatDictionary desired_torques;
102  float desiredForce_x;
103  float desiredForce_y;
104  float desiredForce_z;
105  float tcpDesiredTorque_x;
106  float tcpDesiredTorque_y;
107  float tcpDesiredTorque_z;
108 
109  float tcpDesiredAngularError_x;
110  float tcpDesiredAngularError_y;
111  float tcpDesiredAngularError_z;
112 
113  float currentTCPAngularVelocity_x;
114  float currentTCPAngularVelocity_y;
115  float currentTCPAngularVelocity_z;
116 
117  float currentTCPLinearVelocity_x;
118  float currentTCPLinearVelocity_y;
119  float currentTCPLinearVelocity_z;
120 
121  float quatError;
122  float posiError;
123  };
124 
125  TripleBuffer<NJointTaskSpaceImpedanceControllerDebugInfo> debugDataInfo;
126 
127  std::vector<std::string> jointNames;
128  CartesianImpedanceController controller;
129 
130 
131  // NJointController interface
132  protected:
133  void rtPreActivateController() override;
134  };
135 } // namespace armarx
armarx::NJointTaskSpaceImpedanceController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: NJointTaskSpaceImpedanceController.cpp:101
NJointControllerWithTripleBuffer.h
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
RobotUnit.h
armarx::NJointTaskSpaceImpedanceController::setPositionOrientation
void setPositionOrientation(const Eigen::Vector3f &pos, const Eigen::Quaternionf &ori, const Ice::Current &) override
Definition: NJointTaskSpaceImpedanceController.cpp:179
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
armarx::NJointTaskSpaceImpedanceController::setNullspaceConfig
void setNullspaceConfig(const Eigen::VectorXf &joint, const Eigen::VectorXf &knull, const Eigen::VectorXf &dnull, const Ice::Current &) override
Definition: NJointTaskSpaceImpedanceController.cpp:276
armarx::NJointTaskSpaceImpedanceController::setPosition
void setPosition(const Eigen::Vector3f &, const Ice::Current &) override
Definition: NJointTaskSpaceImpedanceController.cpp:162
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
controller
Definition: AddOperation.h:39
ControlTarget1DoFActuator.h
Eigen::Quaternionf
Quaternion< float, 0 > Quaternionf
Definition: EigenForwardDeclarations.h:61
armarx::NJointTaskSpaceImpedanceController::setConfig
void setConfig(const NJointTaskSpaceImpedanceControlRuntimeConfig &cfg, const Ice::Current &) override
Definition: NJointTaskSpaceImpedanceController.cpp:292
armarx::NJointTaskSpaceImpedanceController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: NJointTaskSpaceImpedanceController.h:61
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::NJointTaskSpaceImpedanceController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: NJointTaskSpaceImpedanceController.cpp:130
armarx::NJointTaskSpaceImpedanceController::setOrientation
void setOrientation(const Eigen::Quaternionf &, const Ice::Current &) override
Definition: NJointTaskSpaceImpedanceController.cpp:170
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::NJointTaskSpaceImpedanceController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: NJointTaskSpaceImpedanceController.cpp:315
armarx::NJointTaskSpaceImpedanceController::NJointTaskSpaceImpedanceController
NJointTaskSpaceImpedanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: NJointTaskSpaceImpedanceController.cpp:35
armarx::NJointTaskSpaceImpedanceController
Brief description of class NJointTaskSpaceImpedanceController.
Definition: NJointTaskSpaceImpedanceController.h:49
armarx::NJointTaskSpaceImpedanceController::setPose
void setPose(const Eigen::Matrix4f &mat, const Ice::Current &) override
Definition: NJointTaskSpaceImpedanceController.cpp:190
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
SensorValue1DoFActuator.h
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::NJointTaskSpaceImpedanceController::setImpedanceParameters
void setImpedanceParameters(const std::string &, const Ice::FloatSeq &, const Ice::Current &) override
Definition: NJointTaskSpaceImpedanceController.cpp:199