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;
37 namespace law = armarx::control::common::control_law;
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,
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;
104 law::KeypointsAdmittanceController controller;
105 common::FTSensor ftsensor;
106
107 /// set buffers
110
111 std::atomic_bool rtFirstRun = true;
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
NJointControllerWithTripleBuffer(const law::KeypointsAdmittanceController::Config &initialCommands=law::KeypointsAdmittanceController::Config())
A simple triple buffer for lockfree comunication between a single writer and a single reader.
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
TripleBuffer< law::KeypointsAdmittanceController::Status > controlStatusBuffer
set buffers
NJointKeypointsAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void setForceTorqueBaseline(const Eigen::Vector3f &, const Eigen::Vector3f &, const Ice::Current &) override
ft sensor
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void reconfigureController(const std::string &filename, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
set control target
void setKeypointsParameters(const std::string &name, const Eigen::VectorXf &value, const Ice::Current &) override
void setControlParameters(const std::string &, const Eigen::VectorXf &, const Ice::Current &) override
void rtPreActivateController() override
This function is called before the controller is activated.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file is part of ArmarX.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl