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/Robot.h>
26 
31 
32 #include <armarx/control/common/FTSensor.h>
34 #include <armarx/control/common/control_law/ControllerCommonInterface.h>
35 #include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
36 
37 
39 {
40  namespace common = armarx::control::common;
42  /**
43  * @defgroup Library-NJointKeypointsAdmittanceController NJointKeypointsAdmittanceController
44  * @ingroup Library-RobotUnit-NJointControllers
45  * A description of the library NJointKeypointsAdmittanceController.
46  *
47  * @class NJointKeypointsAdmittanceController
48  * @ingroup Library-NJointKeypointsAdmittanceController
49  * @brief Brief description of class NJointKeypointsAdmittanceController.
50  *
51  * Detailed description of class NJointKeypointsAdmittanceController.
52  */
54  virtual public NJointControllerWithTripleBuffer<law::KeypointsAdmittanceController::Config>,
55  virtual public NJointKeypointsAdmittanceControllerInterface
56  {
57  public:
58  using ConfigPtrT = NJointTaskspaceControllerConfigPtr;
59 
60  NJointKeypointsAdmittanceController(const RobotUnitPtr& robotUnit, const NJointControllerConfigPtr& config, const VirtualRobot::RobotPtr&);
61  std::string getClassName(const Ice::Current&) const override;
62  void rtRun(const IceUtil::Time& sensorValuesTimestamp, 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, const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
69  void setControlParameters(const std::string&, const Eigen::VectorXf&, const Ice::Current&) override;
70  void setKeypointsParameters(const std::string &name, const Eigen::VectorXf &value, const Ice::Current &) override;
71 
72  /// ft sensor
73  void setForceTorqueBaseline(const Eigen::Vector3f&, const Eigen::Vector3f&, const Ice::Current&) override;
74  void toggleGravityCompensation(const bool toggle, const Ice::Current &) override;
75  void setTCPMass(Ice::Float, const Ice::Current&) override;
76  void setTCPCoMInFTFrame(const Eigen::Vector3f&, const Ice::Current&) override;
77  void calibrateFTSensor(const Ice::Current&) override;
78 
79  protected:
80  virtual void additionalTask(){};
82 
83  protected:
84  /// devices
85  std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors;
86  std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
87  std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
88  std::vector<ControlTarget1DoFActuatorTorque*> targets;
89 
90 
91  protected:
92  /// variables
93  std::string configFileName;
94  std::vector<std::string> jointNames;
96  common::FTSensor ftsensor;
97 
98  /// set buffers
101 
102  std::atomic_bool rtFirstRun = true;
103  std::string kinematicChainName;
104  std::atomic_bool rtReady = false;
105 
106  protected:
107  void onInitNJointController() override;
108  void rtPreActivateController() override;
109  };
110 } /// 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:340
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setTCPMass
void setTCPMass(Ice::Float, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:427
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::additionalTask
virtual void additionalTask()
Definition: KeypointsAdmittanceController.h:80
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
RobotUnit.h
armarx::control::njoint_controller::task_space
Definition: AdmittanceController.cpp:37
armarx::control::common::control_law::KeypointsAdmittanceController
Definition: KeypointsAdmittanceController.h:33
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::ftsensor
common::FTSensor ftsensor
Definition: KeypointsAdmittanceController.h:96
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: KeypointsAdmittanceController.cpp:453
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:586
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:331
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:446
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::jointNames
std::vector< std::string > jointNames
Definition: KeypointsAdmittanceController.h:94
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::onInitNJointController
void onInitNJointController() override
Definition: KeypointsAdmittanceController.cpp:142
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:420
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::controller
law::KeypointsAdmittanceController controller
Definition: KeypointsAdmittanceController.h:95
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController
Brief description of class NJointKeypointsAdmittanceController.
Definition: KeypointsAdmittanceController.h:53
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::calibrateFTSensor
void calibrateFTSensor(const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:441
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::getKinematicChainName
std::string getKinematicChainName(const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:137
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::torqueSensors
std::vector< const SensorValue1DoFActuatorTorque * > torqueSensors
devices
Definition: KeypointsAdmittanceController.h:85
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: KeypointsAdmittanceController.cpp:229
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: KeypointsAdmittanceController.cpp:132
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::configFileName
std::string configFileName
variables
Definition: KeypointsAdmittanceController.h:93
armarx::control::common::control_law
This file is part of ArmarX.
Definition: aron_conversions.cpp:68
filename
std::string filename
Definition: VisualizationRobot.cpp:83
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::ftSensorBuffer
TripleBuffer< common::FTSensor::FTBufferData > ftSensorBuffer
Definition: KeypointsAdmittanceController.h:100
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::NJointKeypointsAdmittanceController
NJointKeypointsAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
Definition: KeypointsAdmittanceController.cpp:34
ControlTarget1DoFActuator.h
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:103
KeypointsAdmittanceController.h
NJointController.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:160
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::velocitySensors
std::vector< const SensorValue1DoFActuatorVelocity * > velocitySensors
Definition: KeypointsAdmittanceController.h:86
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setTCPCoMInFTFrame
void setTCPCoMInFTFrame(const Eigen::Vector3f &, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:434
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::controlStatusBuffer
TripleBuffer< law::KeypointsAdmittanceController::Status > controlStatusBuffer
set buffers
Definition: KeypointsAdmittanceController.h:99
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::positionSensors
std::vector< const SensorValue1DoFActuatorPosition * > positionSensors
Definition: KeypointsAdmittanceController.h:87
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::setControlParameters
void setControlParameters(const std::string &, const Eigen::VectorXf &, const Ice::Current &) override
Definition: KeypointsAdmittanceController.cpp:370
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::targets
std::vector< ControlTarget1DoFActuatorTorque * > targets
Definition: KeypointsAdmittanceController.h:88
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtFirstRun
std::atomic_bool rtFirstRun
Definition: KeypointsAdmittanceController.h:102
armarx::control::njoint_controller::task_space::NJointKeypointsAdmittanceController::rtReady
std::atomic_bool rtReady
Definition: KeypointsAdmittanceController.h:104
SensorValue1DoFActuator.h
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::TripleBuffer< law::KeypointsAdmittanceController::Status >