ZeroTorqueOrVelocityController.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 2024
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
30
32#include <armarx/control/common/control_law/aron/ZeroTorqueOrVelocityControllerConfig.aron.generated.h>
34#include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
35#include <armarx/control/njoint_controller/task_space/ControllerInterface.h>
36
37namespace armarx
38{
39 class ControlTarget1DoFActuatorZeroTorque;
40 class ControlTarget1DoFActuatorZeroVelocity;
41} // namespace armarx
42
44{
45 namespace law = armarx::control::common::control_law;
46
47 /**
48 * @defgroup Library-NJointTaskspaceZeroTorqueOrVelocityController NJointTaskspaceZeroTorqueOrVelocityController
49 * @ingroup Library-RobotUnit-NJointControllers
50 * A description of the library NJointTaskspaceZeroTorqueOrVelocityController.
51 *
52 * @class NJointTaskspaceZeroTorqueOrVelocityController
53 * @ingroup Library-NJointTaskspaceZeroTorqueOrVelocityController
54 * @brief Brief description of class NJointTaskspaceZeroTorqueOrVelocityController.
55 *
56 * Detailed description of class NJointTaskspaceZeroTorqueOrVelocityController.
57 */
59 virtual public NJointController,
61 {
62 public:
63 using ConfigPtrT = ConfigurableNJointControllerConfigPtr;
64 // using AronDTO = law::arondto::ZeroTorqueOrVelocityControllerConfigDict;
65 // using BO = law::ZeroTorqueOrVelocityController::ConfigDict;
67
68 using Config = common::control_law::arondto::ZeroTorqueOrVelocityControllerConfig;
69 using ConfigDict = common::control_law::arondto::ZeroTorqueOrVelocityControllerConfigDict;
70
71 struct ArmData
72 {
74 std::vector<ControlTarget1DoFActuatorZeroTorque*> targetsTorque;
75 std::vector<ControlTarget1DoFActuatorZeroVelocity*> targetsVel;
76
77 std::vector<size_t> torqueControlledIndex;
78 std::vector<size_t> velocityControlledIndex;
79
80 std::string kinematicChainName;
81 std::vector<std::string> jointNames;
82 law::ZeroTorqueOrVelocityController controller;
83
84 /// set buffers
86
93
98
99 std::atomic_bool rtFirstRun{true};
100 std::atomic_bool rtReady{false};
101 // std::atomic_bool reInitPreActivate{false};
102
104 };
105
106 using ArmPtr = std::unique_ptr<ArmData>;
107
109 const NJointControllerConfigPtr& config,
111
112 std::string getClassName(const Ice::Current&) const override;
113
114 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
115 const IceUtil::Time& timeSinceLastIteration) override;
116
117 /// NJointController interface
118 void updateConfig(const ::armarx::aron::data::dto::DictPtr& dto,
119 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
120
122 getConfig(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
123
126 const std::map<std::string, ConstControlDevicePtr>&,
127 const std::map<std::string, ConstSensorDevicePtr>&);
128
130
131
132 /// ft sensor
133 void calibrateFTSensor(const Ice::Current&) override;
134
135 protected:
136 void validateConfigData(Config& config, ArmPtr& arm);
137 void onPublish(const SensorAndControl&,
139 const DebugObserverInterfacePrx&) override;
140
141 void limbInit(const std::string nodeSetName,
142 ArmPtr& arm,
143 Config cfg,
144 VirtualRobot::RobotPtr& nonRtRobotPtr);
145 void limbRT(ArmPtr& arm, const double deltaT);
146 void limbPublish(ArmPtr& arm, const DebugObserverInterfacePrx& debugObs);
147 void limbReInit(ArmPtr& arm);
148
149 protected:
150 std::map<std::string, ArmPtr> limb;
154
155 protected:
156 /// NJointControllerBase interface
157 void onInitNJointController() override;
158 void rtPreActivateController() override;
159 void rtPostDeactivateController() override;
160 };
161} // namespace armarx::control::njoint_controller::task_space
A simple triple buffer for lockfree comunication between a single writer and a single reader.
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 > &)
NJointTaskspaceZeroTorqueOrVelocityController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
::armarx::aron::data::dto::DictPtr getConfig(const Ice::Current &iceCurrent=Ice::emptyCurrent) override
void limbInit(const std::string nodeSetName, ArmPtr &arm, Config cfg, VirtualRobot::RobotPtr &nonRtRobotPtr)
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 updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
NJointController interface.
void rtPreActivateController() override
This function is called before the controller is activated.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
::IceInternal::Handle<::armarx::WidgetDescription::Widget > WidgetPtr
::IceInternal::Handle< Dict > DictPtr
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
SynchronousNJointController NJointController
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl