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/VirtualRobot.h>
26
31#include <RobotAPI/interface/units/RobotUnit/TaskSpaceActiveImpedanceControl.h>
32
34
35namespace armarx
36{
37 /**
38 * @defgroup Library-NJointTaskSpaceImpedanceController NJointTaskSpaceImpedanceController
39 * @ingroup Library-RobotUnit-NJointControllers
40 * A description of the library NJointTaskSpaceImpedanceController.
41 *
42 * @class NJointTaskSpaceImpedanceController
43 * @ingroup Library-NJointTaskSpaceImpedanceController
44 * @brief Brief description of class NJointTaskSpaceImpedanceController.
45 *
46 * Detailed description of class NJointTaskSpaceImpedanceController.
47 */
49 public NJointControllerWithTripleBuffer<CartesianImpedanceController::Config>,
50 public NJointTaskSpaceImpedanceControlInterface
51 {
52 public:
53 using ConfigPtrT = NJointTaskSpaceImpedanceControlConfigPtr;
54
56 const NJointControllerConfigPtr& config,
58
59 std::string
60 getClassName(const Ice::Current&) const override
61 {
62 return "TaskSpaceImpedanceController";
63 }
64
65 // NJointController interface
66 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
67 const IceUtil::Time& timeSinceLastIteration) override;
68
69 protected:
70 void onPublish(const SensorAndControl&,
72 const DebugObserverInterfacePrx&) override;
73
74 void setPosition(const Eigen::Vector3f&, const Ice::Current&) override;
75 void setOrientation(const Eigen::Quaternionf&, const Ice::Current&) override;
76 void setPositionOrientation(const Eigen::Vector3f& pos,
77 const Eigen::Quaternionf& ori,
78 const Ice::Current&) override;
79 void setPose(const Eigen::Matrix4f& mat, const Ice::Current&) override;
80
81 void setImpedanceParameters(const std::string&,
82 const Ice::FloatSeq&,
83 const Ice::Current&) override;
84 void setNullspaceConfig(const Eigen::VectorXf& joint,
85 const Eigen::VectorXf& knull,
86 const Eigen::VectorXf& dnull,
87 const Ice::Current&) override;
88 void setConfig(const NJointTaskSpaceImpedanceControlRuntimeConfig& cfg,
89 const Ice::Current&) override;
90
91 private:
92 std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors;
93 std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
94 std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
95
96 std::vector<ControlTarget1DoFActuatorTorque*> targets;
97
98 struct NJointTaskSpaceImpedanceControllerDebugInfo
99 {
100 StringFloatDictionary desired_torques;
101 float desiredForce_x;
102 float desiredForce_y;
103 float desiredForce_z;
104 float tcpDesiredTorque_x;
105 float tcpDesiredTorque_y;
106 float tcpDesiredTorque_z;
107
108 float tcpDesiredAngularError_x;
109 float tcpDesiredAngularError_y;
110 float tcpDesiredAngularError_z;
111
112 float currentTCPAngularVelocity_x;
113 float currentTCPAngularVelocity_y;
114 float currentTCPAngularVelocity_z;
115
116 float currentTCPLinearVelocity_x;
117 float currentTCPLinearVelocity_y;
118 float currentTCPLinearVelocity_z;
119
120 float quatError;
121 float posiError;
122 };
123
124 TripleBuffer<NJointTaskSpaceImpedanceControllerDebugInfo> debugDataInfo;
125
126 std::vector<std::string> jointNames;
127 CartesianImpedanceController controller;
128
129
130 // NJointController interface
131 protected:
132 void rtPreActivateController() override;
133 };
134} // namespace armarx
NJointControllerWithTripleBuffer(const CartesianImpedanceController::Config &initialCommands=CartesianImpedanceController::Config())
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
void setPose(const Eigen::Matrix4f &mat, const Ice::Current &) override
void setConfig(const NJointTaskSpaceImpedanceControlRuntimeConfig &cfg, const Ice::Current &) override
void setPositionOrientation(const Eigen::Vector3f &pos, const Eigen::Quaternionf &ori, const Ice::Current &) override
void setImpedanceParameters(const std::string &, const Ice::FloatSeq &, const Ice::Current &) override
NJointTaskSpaceImpedanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void setOrientation(const Eigen::Quaternionf &, const Ice::Current &) override
void setPosition(const Eigen::Vector3f &, const Ice::Current &) override
NJointTaskSpaceImpedanceControlConfigPtr ConfigPtrT
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void setNullspaceConfig(const Eigen::VectorXf &joint, const Eigen::VectorXf &knull, const Eigen::VectorXf &dnull, const Ice::Current &) override
std::string getClassName(const Ice::Current &) const override
void rtPreActivateController() override
This function is called before the controller is activated.
Brief description of class targets.
Definition targets.h:39
Quaternion< float, 0 > Quaternionf
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl