NJointCartesianTorqueController.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2017, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarX
19  * @author Mirko Waechter( mirko.waechter at kit dot edu)
20  * @date 2017
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 
27 #include <VirtualRobot/IK/DifferentialIK.h>
28 #include <VirtualRobot/Robot.h>
29 
30 #include <RobotAPI/interface/units/RobotUnit/NJointCartesianTorqueController.h>
31 
32 #include "../ControlTargets/ControlTarget1DoFActuator.h"
33 #include "../SensorValues/SensorValue1DoFActuator.h"
35 
36 namespace armarx
37 {
38 
39  TYPEDEF_PTRS_HANDLE(NJointCartesianTorqueController);
40  //TYPEDEF_PTRS_HANDLE(NJointCartesianTorqueControllerConfig);
41 
42  /*class NJointCartesianTorqueControllerConfig : virtual public NJointControllerConfig
43  {
44  public:
45  NJointCartesianTorqueControllerConfig(std::string const& nodeSetName, const std::string& tcpName, VirtualRobot::IKSolver::CartesianSelection mode):
46  nodeSetName(nodeSetName),
47  tcpName(tcpName),
48  mode(mode)
49  {}
50 
51  const std::string nodeSetName;
52  const std::string tcpName;
53  const VirtualRobot::IKSolver::CartesianSelection mode;
54  };*/
55 
56  TYPEDEF_PTRS_HANDLE(NJointCartesianTorqueControllerControlData);
57 
59  {
60  public:
61  float forceX = 0;
62  float forceY = 0;
63  float forceZ = 0;
64  float torqueX = 0;
65  float torqueY = 0;
66  float torqueZ = 0;
67 
68  //VirtualRobot::IKSolver::CartesianSelection mode = VirtualRobot::IKSolver::All;
69  };
70 
71  /**
72  * @brief The NJointCartesianTorqueController class
73  * @ingroup Library-RobotUnit-NJointControllers
74  */
76  public NJointControllerWithTripleBuffer<NJointCartesianTorqueControllerControlData>,
77  public NJointCartesianTorqueControllerInterface
78  {
79  public:
80  using ConfigPtrT = NJointCartesianTorqueControllerConfigPtr;
82  const NJointControllerConfigPtr& config,
83  const VirtualRobot::RobotPtr&);
84 
85  // NJointControllerInterface interface
86  std::string getClassName(const Ice::Current&) const override;
88  getFunctionDescriptions(const Ice::Current&) const override;
89  void callDescribedFunction(const std::string& name,
90  const StringVariantBaseMap& valueMap,
91  const Ice::Current&) override;
92 
93  // NJointController interface
94  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
95  const IceUtil::Time& timeSinceLastIteration) override;
98  const std::map<std::string, ConstControlDevicePtr>&,
99  const std::map<std::string, ConstSensorDevicePtr>&);
100 
101  static NJointCartesianTorqueControllerConfigPtr
104  NJointCartesianTorqueControllerConfigPtr config,
105  const VirtualRobot::RobotPtr& r);
106 
107  std::string getNodeSetName() const;
108  static ::armarx::WidgetDescription::HBoxLayoutPtr createSliders();
109  //WidgetDescription::HBoxLayoutPtr createJointSlidersLayout(float min, float max, float defaultValue) const;
110 
111  protected:
112  void rtPreActivateController() override;
113  void rtPostDeactivateController() override;
114 
115  private:
116  std::vector<ControlTarget1DoFActuatorTorque*> targets;
117  //std::vector<const SensorValue1DoFActuatorPosition*> sensors;
118  //std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors;
119  //std::vector<const SensorValue1DoFGravityTorque*> gravityTorqueSensors;
120 
121  std::string nodeSetName;
122 
123  VirtualRobot::DifferentialIKPtr ik;
124  VirtualRobot::RobotNodePtr tcp;
125 
126 
127  // NJointCartesianTorqueControllerInterface interface
128  public:
129  void setControllerTarget(float forceX,
130  float forceY,
131  float forceZ,
132  float torqueX,
133  float torqueY,
134  float torqueZ,
135  const Ice::Current&) override;
136  };
137 
138 } // namespace armarx
armarx::NJointCartesianTorqueControllerControlData::torqueX
float torqueX
Definition: NJointCartesianTorqueController.h:64
NJointControllerWithTripleBuffer.h
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::TYPEDEF_PTRS_HANDLE
TYPEDEF_PTRS_HANDLE(NJointCartesianNaturalPositionController)
armarx::NJointCartesianTorqueController::callDescribedFunction
void callDescribedFunction(const std::string &name, const StringVariantBaseMap &valueMap, const Ice::Current &) override
Definition: NJointCartesianTorqueController.cpp:246
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
armarx::WidgetDescription::StringWidgetDictionary
::std::map<::std::string, ::armarx::WidgetDescription::WidgetPtr > StringWidgetDictionary
Definition: NJointControllerBase.h:69
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::NJointCartesianTorqueController::getClassName
std::string getClassName(const Ice::Current &) const override
Definition: NJointCartesianTorqueController.cpp:42
armarx::NJointCartesianTorqueController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: NJointCartesianTorqueController.cpp:96
armarx::NJointCartesianTorqueController::GenerateConfigFromVariants
static NJointCartesianTorqueControllerConfigPtr GenerateConfigFromVariants(const StringVariantBaseMap &values)
Definition: NJointCartesianTorqueController.cpp:219
armarx::NJointCartesianTorqueController
The NJointCartesianTorqueController class.
Definition: NJointCartesianTorqueController.h:75
armarx::NJointCartesianTorqueControllerControlData::forceY
float forceY
Definition: NJointCartesianTorqueController.h:62
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::NJointCartesianTorqueController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: NJointCartesianTorqueController.cpp:232
armarx::NJointCartesianTorqueController::NJointCartesianTorqueController
NJointCartesianTorqueController(RobotUnit *prov, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
armarx::NJointCartesianTorqueControllerControlData::torqueZ
float torqueZ
Definition: NJointCartesianTorqueController.h:66
armarx::NJointCartesianTorqueControllerControlData
Definition: NJointCartesianTorqueController.h:58
armarx::NJointCartesianTorqueControllerControlData::torqueY
float torqueY
Definition: NJointCartesianTorqueController.h:65
armarx::NJointCartesianTorqueController::setControllerTarget
void setControllerTarget(float forceX, float forceY, float forceZ, float torqueX, float torqueY, float torqueZ, const Ice::Current &) override
Definition: NJointCartesianTorqueController.cpp:269
armarx::NJointCartesianTorqueController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: NJointCartesianTorqueController.cpp:101
armarx::NJointCartesianTorqueController::createSliders
::armarx::WidgetDescription::HBoxLayoutPtr createSliders()
Definition: NJointCartesianTorqueController.cpp:125
armarx::NJointCartesianTorqueController::getNodeSetName
std::string getNodeSetName() const
Definition: NJointCartesianTorqueController.cpp:226
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::NJointCartesianTorqueControllerControlData::forceZ
float forceZ
Definition: NJointCartesianTorqueController.h:63
armarx::NJointCartesianTorqueController::ConfigPtrT
NJointCartesianTorqueControllerConfigPtr ConfigPtrT
Definition: NJointCartesianTorqueController.h:80
armarx::NJointCartesianTorqueController::getFunctionDescriptions
WidgetDescription::StringWidgetDictionary getFunctionDescriptions(const Ice::Current &) const override
Definition: NJointCartesianTorqueController.cpp:237
armarx::RobotUnit
The RobotUnit class manages a robot and its controllers.
Definition: RobotUnit.h:180
armarx::NJointCartesianTorqueController::GenerateConfigDescription
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
Definition: NJointCartesianTorqueController.cpp:174
armarx::NJointCartesianTorqueControllerControlData::forceX
float forceX
Definition: NJointCartesianTorqueController.h:61
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18