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/Robot.h>
27 //#include <VirtualRobot/VirtualRobot.h>
28 
31 
32 #include <armarx/control/njoint_controller/joint_space/ControllerInterface.h>
33 
35 {
36 
38  {
39  Ice::FloatSeq targetTorqueOrVelocity;
40  };
41 
43 
45  public NJointControllerWithTripleBuffer<NJointZeroTorqueOrVelocityWithFTControllerTarget>,
47  {
48  public:
49  struct RtStatus
50  {
51  /// targets
52  Eigen::VectorXf desiredJointTorques;
53  Eigen::VectorXf desiredJointVelocity;
54  // Eigen::VectorXf nullspaceTorque;
55  // Eigen::VectorXf nullspaceVelocity;
56 
57  /// force torque
59 
60  /// task space variables
61  // Eigen::Vector6f forceImpedance;
63 
64  /// current status
65  Eigen::VectorXf qpos;
66  // Eigen::VectorXf qvel;
67  // Eigen::VectorXf qvelFiltered;
68  // Eigen::Matrix4f currentPose;
69  // Eigen::Vector6f currentTwist;
70  // Eigen::Matrix4f desiredPose;
71 
72  // /// intermediate results
73  // Eigen::Matrix3f poseDiffMatImp;
74  // Eigen::Vector6f poseErrorImp;
75 
76  /// others
77  Eigen::MatrixXf jacobi;
78  // Eigen::MatrixXf jtpinv;
79  Eigen::MatrixXf jpinv;
80  bool rtSafe;
81 
82  size_t nDoFTorque;
83  size_t nDoFVelocity;
84  };
85 
86  using ConfigPtrT = NJointZeroTorqueOrVelocityWithFTControllerConfigPtr;
88  RobotUnitPtr prov,
89  const NJointZeroTorqueOrVelocityWithFTControllerConfigPtr& config,
90  const VirtualRobot::RobotPtr&);
91 
92  // NJointControllerInterface interface
93  std::string getClassName(const Ice::Current&) const override;
94  // WidgetDescription::StringWidgetDictionary getFunctionDescriptions(const Ice::Current&) const override;
95  // void callDescribedFunction(const std::string& name, const StringVariantBaseMap& valueMap, const Ice::Current&) override;
96 
97  // NJointController interface
98  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
99  const IceUtil::Time& timeSinceLastIteration) override;
100  void onPublish(const SensorAndControl&,
102  const DebugObserverInterfacePrx&) override;
105  const std::map<std::string, ConstControlDevicePtr>&,
106  const std::map<std::string, ConstSensorDevicePtr>&);
107 
108  static NJointZeroTorqueOrVelocityWithFTControllerConfigPtr
110 
111  protected:
112  void rtPreActivateController() override;
113  void rtPostDeactivateController() override;
114 
115  std::vector<ControlTarget1DoFActuatorZeroTorque*> targetsTorque;
116  std::vector<ControlTarget1DoFActuatorZeroVelocity*> targetsVel;
119  std::atomic_bool useZeroVelocityModeForWrist{true};
120  std::vector<bool> torqueControlled;
121 
122  // NJointZeroTorqueOrVelocityWithFTControllerInterface interface
123  public:
124  void setControllerTarget(const Ice::FloatSeq&, const Ice::Current&) override;
125 
126  private:
127  VirtualRobot::DifferentialIKPtr ik;
128  const float lambda = 2.0f;
129  Eigen::MatrixXf I;
130  };
131 
132 } // namespace armarx::control::njoint_controller::joint_space
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTControllerTarget
Definition: ZeroTorqueOrVelocityWithFT.h:37
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::jpinv
Eigen::MatrixXf jpinv
Definition: ZeroTorqueOrVelocityWithFT.h:79
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: ZeroTorqueOrVelocityWithFT.cpp:91
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::nDoFVelocity
size_t nDoFVelocity
Definition: ZeroTorqueOrVelocityWithFT.h:83
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: ZeroTorqueOrVelocityWithFT.cpp:20
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::setControllerTarget
void setControllerTarget(const Ice::FloatSeq &, const Ice::Current &) override
Definition: ZeroTorqueOrVelocityWithFT.cpp:209
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::GenerateConfigDescription
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
Definition: ZeroTorqueOrVelocityWithFT.cpp:136
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController
Definition: ZeroTorqueOrVelocityWithFT.h:44
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::targetsVel
std::vector< ControlTarget1DoFActuatorZeroVelocity * > targetsVel
Definition: ZeroTorqueOrVelocityWithFT.h:116
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
armarx::control::njoint_controller::joint_space
Definition: Torque.cpp:9
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::useZeroVelocityModeForWrist
std::atomic_bool useZeroVelocityModeForWrist
Definition: ZeroTorqueOrVelocityWithFT.h:119
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: ZeroTorqueOrVelocityWithFT.cpp:82
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::cartesianVelTarget
Eigen::Vector6f cartesianVelTarget
task space variables
Definition: ZeroTorqueOrVelocityWithFT.h:62
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::targetsTorque
std::vector< ControlTarget1DoFActuatorZeroTorque * > targetsTorque
Definition: ZeroTorqueOrVelocityWithFT.h:115
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTControllerTarget::targetTorqueOrVelocity
Ice::FloatSeq targetTorqueOrVelocity
Definition: ZeroTorqueOrVelocityWithFT.h:39
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::qpos
Eigen::VectorXf qpos
current status
Definition: ZeroTorqueOrVelocityWithFT.h:65
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus
Definition: ZeroTorqueOrVelocityWithFT.h:49
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::currentForceTorque
Eigen::Vector6f currentForceTorque
force torque
Definition: ZeroTorqueOrVelocityWithFT.h:58
armarx::control::NJointZeroTorqueOrVelocityWithFTControllerInterface
Definition: ControllerInterface.ice:72
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::maxTorque
float maxTorque
Definition: ZeroTorqueOrVelocityWithFT.h:117
ControlTarget1DoFActuator.h
max
T max(T t1, T t2)
Definition: gdiam.h:48
armarx::control::njoint_controller::joint_space::TYPEDEF_PTRS_HANDLE
TYPEDEF_PTRS_HANDLE(NJointTorqueController)
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
NJointController.h
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: ZeroTorqueOrVelocityWithFT.cpp:204
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::maxVelocity
float maxVelocity
Definition: ZeroTorqueOrVelocityWithFT.h:118
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::NJointZeroTorqueOrVelocityWithFTController
NJointZeroTorqueOrVelocityWithFTController(RobotUnitPtr prov, const NJointZeroTorqueOrVelocityWithFTControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: ZeroTorqueOrVelocityWithFT.cpp:25
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::rtSafe
bool rtSafe
Definition: ZeroTorqueOrVelocityWithFT.h:80
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::GenerateConfigFromVariants
static NJointZeroTorqueOrVelocityWithFTControllerConfigPtr GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: ZeroTorqueOrVelocityWithFT.cpp:189
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::desiredJointVelocity
Eigen::VectorXf desiredJointVelocity
Definition: ZeroTorqueOrVelocityWithFT.h:53
Eigen::Matrix< float, 6, 1 >
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::desiredJointTorques
Eigen::VectorXf desiredJointTorques
targets
Definition: ZeroTorqueOrVelocityWithFT.h:52
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::jacobi
Eigen::MatrixXf jacobi
others
Definition: ZeroTorqueOrVelocityWithFT.h:77
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::torqueControlled
std::vector< bool > torqueControlled
Definition: ZeroTorqueOrVelocityWithFT.h:120
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::RtStatus::nDoFTorque
size_t nDoFTorque
Definition: ZeroTorqueOrVelocityWithFT.h:82
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::control::njoint_controller::joint_space::NJointZeroTorqueOrVelocityWithFTController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: ZeroTorqueOrVelocityWithFT.cpp:129