KeypointsAdmittanceController.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 ...
17  * @author Jianfeng Gao ( jianfeng dot gao at kit dot edu )
18  * @date 2021
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 
28 
29 #include <armarx/control/common/FTSensor.h>
30 #include <armarx/control/common/control_law/ControllerCommonInterface.h>
32 #include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
33 
35 {
36  namespace common = armarx::control::common;
38 
39  /**
40  * @defgroup Library-NJointKeypointsAdmittanceController NJointKeypointsAdmittanceController
41  * @ingroup Library-RobotUnit-NJointControllers
42  * A description of the library NJointKeypointsAdmittanceController.
43  *
44  * @class NJointKeypointsAdmittanceController
45  * @ingroup Library-NJointKeypointsAdmittanceController
46  * @brief Brief description of class NJointKeypointsAdmittanceController.
47  *
48  * Detailed description of class NJointKeypointsAdmittanceController.
49  */
51  virtual public NJointControllerWithTripleBuffer<law::KeypointsAdmittanceController::Config>,
52  virtual public NJointKeypointsAdmittanceControllerInterface
53  {
54  public:
55  using ConfigPtrT = NJointTaskspaceControllerConfigPtr;
56 
58  const NJointControllerConfigPtr& config,
59  const VirtualRobot::RobotPtr&);
60  std::string getClassName(const Ice::Current&) const override;
61  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
62  const IceUtil::Time& timeSinceLastIteration) override;
63 
64  // NJointController interface
65  std::string getKinematicChainName(const Ice::Current&) override;
66 
67  /// set control target
68  void reconfigureController(const std::string& filename,
69  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
70  void setControlParameters(const std::string&,
71  const Eigen::VectorXf&,
72  const Ice::Current&) override;
73  void setKeypointsParameters(const std::string& name,
74  const Eigen::VectorXf& value,
75  const Ice::Current&) override;
76 
77  /// ft sensor
78  void setForceTorqueBaseline(const Eigen::Vector3f&,
79  const Eigen::Vector3f&,
80  const Ice::Current&) override;
81  void toggleGravityCompensation(const bool toggle, const Ice::Current&) override;
82  void setTCPMass(Ice::Float, const Ice::Current&) override;
83  void setTCPCoMInFTFrame(const Eigen::Vector3f&, const Ice::Current&) override;
84  void calibrateFTSensor(const Ice::Current&) override;
85 
86  protected:
87  virtual void additionalTask(){};
88  void onPublish(const SensorAndControl&,
90  const DebugObserverInterfacePrx&) override;
91 
92  protected:
93  /// devices
94  std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors;
95  std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
96  std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
97  std::vector<ControlTarget1DoFActuatorTorque*> targets;
98 
99 
100  protected:
101  /// variables
102  std::string configFileName;
103  std::vector<std::string> jointNames;
105  common::FTSensor ftsensor;
106 
107  /// set buffers
110 
111  std::atomic_bool rtFirstRun = true;
112  std::string kinematicChainName;
113  std::atomic_bool rtReady = false;
114 
115  protected:
116  void onInitNJointController() override;
117  void rtPreActivateController() override;
118  };
119 } // namespace armarx::control::njoint_controller::task_space
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setKeypointsParameters
void setKeypointsParameters(const std::string &name, const Eigen::VectorXf &value, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:431
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setTCPMass
void setTCPMass(Ice::Float, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:528
NJointControllerBase.h
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::additionalTask
virtual void additionalTask()
Definition: KeypointsAdmittanceController.h:87
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:43
armarx::control::common::control_law::KeypointsAdmittanceController
Definition: KeypointsAdmittanceController.h:44
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::ftsensor
common::FTSensor ftsensor
Definition: KeypointsAdmittanceController.h:105
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: KeypointsAdmittanceController.cpp:561
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:587
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::reconfigureController
void reconfigureController(const std::string &filename, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
set control target
Definition: KeypointsAdmittanceController.cpp:420
armarx::control::common
This file is part of ArmarX.
Definition: aron_conversions.cpp:29
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::toggleGravityCompensation
void toggleGravityCompensation(const bool toggle, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:552
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::jointNames
std::vector< std::string > jointNames
Definition: KeypointsAdmittanceController.h:103
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::onInitNJointController
void onInitNJointController() override
Definition: KeypointsAdmittanceController.cpp:158
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setForceTorqueBaseline
void setForceTorqueBaseline(const Eigen::Vector3f &, const Eigen::Vector3f &, const Ice::Current &) override
ft sensor
Definition: KeypointsAdmittanceController.cpp:517
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::controller
law::KeypointsAdmittanceController controller
Definition: KeypointsAdmittanceController.h:104
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:182
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController
Brief description of class NJointKeypointsAdmittanceController.
Definition: KeypointsAdmittanceController.h:50
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::calibrateFTSensor
void calibrateFTSensor(const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:546
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::getKinematicChainName
std::string getKinematicChainName(const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:152
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::torqueSensors
std::vector< const SensorValue1DoFActuatorTorque * > torqueSensors
devices
Definition: KeypointsAdmittanceController.h:94
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: KeypointsAdmittanceController.cpp:257
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: KeypointsAdmittanceController.cpp:146
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::configFileName
std::string configFileName
variables
Definition: KeypointsAdmittanceController.h:102
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
filename
std::string filename
Definition: VisualizationRobot.cpp:86
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::ftSensorBuffer
TripleBuffer< common::FTSensor::FTBufferData > ftSensorBuffer
Definition: KeypointsAdmittanceController.h:109
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::NJointKeypointsAdmittanceController
NJointKeypointsAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: KeypointsAdmittanceController.cpp:42
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::kinematicChainName
std::string kinematicChainName
Definition: KeypointsAdmittanceController.h:112
KeypointsAdmittanceController.h
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: KeypointsAdmittanceController.cpp:179
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::velocitySensors
std::vector< const SensorValue1DoFActuatorVelocity * > velocitySensors
Definition: KeypointsAdmittanceController.h:95
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setTCPCoMInFTFrame
void setTCPCoMInFTFrame(const Eigen::Vector3f &, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:536
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::controlStatusBuffer
TripleBuffer< law::KeypointsAdmittanceController::Status > controlStatusBuffer
set buffers
Definition: KeypointsAdmittanceController.h:108
IceUtil::Handle< class RobotUnit >
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::positionSensors
std::vector< const SensorValue1DoFActuatorPosition * > positionSensors
Definition: KeypointsAdmittanceController.h:96
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setControlParameters
void setControlParameters(const std::string &, const Eigen::VectorXf &, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:464
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::targets
std::vector< ControlTarget1DoFActuatorTorque * > targets
Definition: KeypointsAdmittanceController.h:97
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtFirstRun
std::atomic_bool rtFirstRun
Definition: KeypointsAdmittanceController.h:111
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtReady
std::atomic_bool rtReady
Definition: KeypointsAdmittanceController.h:113
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::TripleBuffer< law::KeypointsAdmittanceController::Status >