ZeroTorqueOrVelocityWithFT.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 armarx::skills::control
17 * @author Jianfeng Gao ( jianfeng dot gao at kit dot edu )
18 * @date 2024
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25
26#include <VirtualRobot/VirtualRobot.h>
27
29
30#include <armarx/control/njoint_controller/joint_space/ControllerInterface.h>
31
32namespace armarx
33{
34 class ControlTarget1DoFActuatorZeroTorque;
35 class ControlTarget1DoFActuatorZeroVelocity;
36} // namespace armarx
37
39{
40
45
47
49 public NJointControllerWithTripleBuffer<NJointZeroTorqueOrVelocityWithFTControllerTarget>,
51 {
52 public:
53 struct RtStatus
54 {
55 /// targets
56 Eigen::VectorXf desiredJointTorques;
57 Eigen::VectorXf desiredJointVelocity;
58 // Eigen::VectorXf nullspaceTorque;
59 // Eigen::VectorXf nullspaceVelocity;
60
61 /// force torque
63
64 /// task space variables
65 // Eigen::Vector6f forceImpedance;
67
68 /// current status
69 Eigen::VectorXf qpos;
70 // Eigen::VectorXf qvel;
71 // Eigen::VectorXf qvelFiltered;
72 // Eigen::Matrix4f currentPose;
73 // Eigen::Vector6f currentTwist;
74 // Eigen::Matrix4f desiredPose;
75
76 // /// intermediate results
77 // Eigen::Matrix3f poseDiffMatImp;
78 // Eigen::Vector6f poseErrorImp;
79
80 /// others
81 Eigen::MatrixXf jacobi;
82 // Eigen::MatrixXf jtpinv;
83 Eigen::MatrixXf jpinv;
84 bool rtSafe;
85
86 size_t nDoFTorque;
88 };
89
90 using ConfigPtrT = NJointZeroTorqueOrVelocityWithFTControllerConfigPtr;
92 RobotUnitPtr prov,
93 const NJointZeroTorqueOrVelocityWithFTControllerConfigPtr& config,
95
96 // NJointControllerInterface interface
97 std::string getClassName(const Ice::Current&) const override;
98 // WidgetDescription::StringWidgetDictionary getFunctionDescriptions(const Ice::Current&) const override;
99 // void callDescribedFunction(const std::string& name, const StringVariantBaseMap& valueMap, const Ice::Current&) override;
100
101 // NJointController interface
102 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
103 const IceUtil::Time& timeSinceLastIteration) override;
104 void onPublish(const SensorAndControl&,
106 const DebugObserverInterfacePrx&) override;
109 const std::map<std::string, ConstControlDevicePtr>&,
110 const std::map<std::string, ConstSensorDevicePtr>&);
111
112 static NJointZeroTorqueOrVelocityWithFTControllerConfigPtr
114
115 protected:
116 void rtPreActivateController() override;
117 void rtPostDeactivateController() override;
118
119 std::vector<ControlTarget1DoFActuatorZeroTorque*> targetsTorque;
120 std::vector<ControlTarget1DoFActuatorZeroVelocity*> targetsVel;
121 float maxTorque = std::numeric_limits<float>::max();
122 float maxVelocity = std::numeric_limits<float>::max();
123 std::atomic_bool useZeroVelocityModeForWrist{true};
124 std::vector<bool> torqueControlled;
125
126 // NJointZeroTorqueOrVelocityWithFTControllerInterface interface
127 public:
128 void setControllerTarget(const Ice::FloatSeq&, const Ice::Current&) override;
129
130 private:
131 VirtualRobot::DifferentialIKPtr ik;
132 const float lambda = 2.0f;
133 Eigen::MatrixXf I;
134 };
135
136} // namespace armarx::control::njoint_controller::joint_space
#define TYPEDEF_PTRS_HANDLE(T)
NJointControllerWithTripleBuffer(const NJointZeroTorqueOrVelocityWithFTControllerTarget &initialCommands=NJointZeroTorqueOrVelocityWithFTControllerTarget())
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
NJointZeroTorqueOrVelocityWithFTController(RobotUnitPtr prov, const NJointZeroTorqueOrVelocityWithFTControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
static NJointZeroTorqueOrVelocityWithFTControllerConfigPtr GenerateConfigFromVariants(const StringVariantBaseMap &values)
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void rtPreActivateController() override
This function is called before the controller is activated.
Matrix< float, 6, 1 > Vector6f
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
::IceInternal::Handle<::armarx::WidgetDescription::Widget > WidgetPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl