NJointCartesianVelocityControllerWithRamp.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 Sonja Marahrens( sonja.marahrens at kit dot edu)
20  * @date 2018
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/NJointCartesianVelocityControllerWithRamp.h>
32 
33 #include "../ControlTargets/ControlTarget1DoFActuator.h"
34 #include "../SensorValues/SensorValue1DoFActuator.h"
36 
37 namespace armarx
38 {
39 
40  TYPEDEF_PTRS_HANDLE(NJointCartesianVelocityControllerWithRamp);
41 
43  {
44  public:
45  float xVel = 0;
46  float yVel = 0;
47  float zVel = 0;
48  float rollVel = 0;
49  float pitchVel = 0;
50  float yawVel = 0;
51  };
52 
54  {
55  WidgetDescription::VBoxLayoutPtr vlayout = new WidgetDescription::VBoxLayout;
56  WidgetDescription::HBoxLayoutPtr hlayout;
57 
58  public:
60  {
61  newLine();
62  }
63 
64  void
66  {
67  using namespace WidgetDescription;
68  hlayout = new HBoxLayout;
69  vlayout->children.emplace_back(hlayout);
70  }
71 
72  void
73  addSlider(const std::string& label, float min, float max, float value)
74  {
75  using namespace WidgetDescription;
76  hlayout->children.emplace_back(new Label(false, label));
77  FloatSliderPtr slider = new FloatSlider;
78  slider->name = label;
79  slider->min = min;
80  slider->defaultValue = value;
81  slider->max = max;
82  hlayout->children.emplace_back(slider);
83  }
84 
85  WidgetDescription::VBoxLayoutPtr
86  getLayout() const
87  {
88  return vlayout;
89  }
90  };
91 
92  /**
93  * @brief The NJointCartesianVelocityControllerWithRamp class
94  * @ingroup Library-RobotUnit-NJointControllers
95  */
98  NJointCartesianVelocityControllerWithRampControlData>,
99  public NJointCartesianVelocityControllerWithRampInterface
100  {
101  public:
102  using ConfigPtrT = NJointCartesianVelocityControllerWithRampConfigPtr;
104  RobotUnit* robotUnit,
105  const NJointCartesianVelocityControllerWithRampConfigPtr& config,
106  const VirtualRobot::RobotPtr&);
107 
108  // NJointControllerInterface interface
109  std::string getClassName(const Ice::Current&) const override;
110 
111  // NJointController interface
112  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
113  const IceUtil::Time& timeSinceLastIteration) override;
114 
116  GenerateConfigDescription(const VirtualRobot::RobotPtr&,
117  const std::map<std::string, ConstControlDevicePtr>&,
118  const std::map<std::string, ConstSensorDevicePtr>&);
119  static NJointCartesianVelocityControllerWithRampConfigPtr
120  GenerateConfigFromVariants(const StringVariantBaseMap& values);
122  getFunctionDescriptions(const Ice::Current&) const override;
123  void callDescribedFunction(const std::string& name,
124  const StringVariantBaseMap& valueMap,
125  const Ice::Current&) override;
126  WidgetDescription::VBoxLayoutPtr createTargetLayout() const;
127  WidgetDescription::VBoxLayoutPtr createParameterLayout() const;
128 
129  static VirtualRobot::IKSolver::CartesianSelection ModeFromString(const std::string mode);
130  static CartesianSelectionMode::CartesianSelection IceModeFromString(const std::string mode);
132  ModeFromIce(const CartesianSelectionMode::CartesianSelection mode);
133 
134  protected:
135  void rtPreActivateController() override;
136  void rtPostDeactivateController() override;
137 
138  private:
139  std::vector<ControlTarget1DoFActuatorVelocity*> targets;
140  //std::vector<const SensorValue1DoFActuatorPosition*> sensors;
141  std::vector<const float*> velocitySensors;
142 
143  std::string nodeSetName;
144  float jointLimitAvoidanceScale;
145  float KpJointLimitAvoidance;
146  VirtualRobot::IKSolver::CartesianSelection mode = VirtualRobot::IKSolver::All;
147 
149 
150 
151  // NJointCartesianVelocityControllerWithRampInterface interface
152  public:
153  void setMaxAccelerations(float maxPositionAcceleration,
154  float maxOrientationAcceleration,
155  float maxNullspaceAcceleration,
156  const Ice::Current& = Ice::emptyCurrent) override;
157  void setTargetVelocity(float vx,
158  float vy,
159  float vz,
160  float vrx,
161  float vry,
162  float vrz,
163  const Ice::Current&) override;
164  void setJointLimitAvoidanceScale(float jointLimitAvoidanceScale,
165  const Ice::Current&) override;
166  void setKpJointLimitAvoidance(float KpJointLimitAvoidance, const Ice::Current&) override;
167  void immediateHardStop(const Ice::Current&) override;
168  const std::string& getNodeSetName() const;
169  };
170 
171 } // namespace armarx
NJointControllerWithTripleBuffer.h
armarx::NJointCartesianVelocityControllerWithRamp
The NJointCartesianVelocityControllerWithRamp class.
Definition: NJointCartesianVelocityControllerWithRamp.h:96
armarx::NJointCartesianVelocityControllerWithRampControlData::xVel
float xVel
Definition: NJointCartesianVelocityControllerWithRamp.h:45
armarx::StringVariantBaseMap
std::map< std::string, VariantBasePtr > StringVariantBaseMap
Definition: ManagedIceObject.h:111
armarx::TYPEDEF_PTRS_HANDLE
TYPEDEF_PTRS_HANDLE(NJointCartesianNaturalPositionController)
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
armarx::WidgetDescription::StringWidgetDictionary
::std::map<::std::string, ::armarx::WidgetDescription::WidgetPtr > StringWidgetDictionary
Definition: NJointControllerBase.h:69
armarx::LayoutBuilder::addSlider
void addSlider(const std::string &label, float min, float max, float value)
Definition: NJointCartesianVelocityControllerWithRamp.h:73
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:267
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::NJointCartesianVelocityControllerWithRampControlData::zVel
float zVel
Definition: NJointCartesianVelocityControllerWithRamp.h:47
CartesianVelocityControllerWithRamp.h
IceInternal::Handle
Definition: forward_declarations.h:8
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:7
armarx::NJointCartesianVelocityControllerWithRampControlData::rollVel
float rollVel
Definition: NJointCartesianVelocityControllerWithRamp.h:48
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::LayoutBuilder
Definition: NJointCartesianVelocityControllerWithRamp.h:53
armarx::NJointCartesianVelocityControllerWithRampControlData
Definition: NJointCartesianVelocityControllerWithRamp.h:42
controller
Definition: AddOperation.h:39
armarx::RemoteGui::Client::FloatSlider
Definition: Widgets.h:107
armarx::NJointCartesianVelocityControllerWithRampControlData::yVel
float yVel
Definition: NJointCartesianVelocityControllerWithRamp.h:46
armarx::NJointTaskSpaceDMPControllerMode::CartesianSelection
CartesianSelection
Definition: ControllerInterface.ice:34
armarx::NJointCartesianVelocityControllerWithRampControlData::pitchVel
float pitchVel
Definition: NJointCartesianVelocityControllerWithRamp.h:49
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::LayoutBuilder::LayoutBuilder
LayoutBuilder()
Definition: NJointCartesianVelocityControllerWithRamp.h:59
armarx::RemoteGui::Client::HBoxLayout
Definition: Widgets.h:160
armarx::LayoutBuilder::newLine
void newLine()
Definition: NJointCartesianVelocityControllerWithRamp.h:65
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:294
armarx::LayoutBuilder::getLayout
WidgetDescription::VBoxLayoutPtr getLayout() const
Definition: NJointCartesianVelocityControllerWithRamp.h:86
armarx::RobotUnit
The RobotUnit class manages a robot and its controllers.
Definition: RobotUnit.h:180
armarx::NJointCartesianVelocityControllerWithRamp::ConfigPtrT
NJointCartesianVelocityControllerWithRampConfigPtr ConfigPtrT
Definition: NJointCartesianVelocityControllerWithRamp.h:102
armarx::NJointCartesianVelocityControllerWithRampControlData::yawVel
float yawVel
Definition: NJointCartesianVelocityControllerWithRamp.h:50
armarx::CartesianVelocityControllerWithRampPtr
std::shared_ptr< CartesianVelocityControllerWithRamp > CartesianVelocityControllerWithRampPtr
Definition: CartesianVelocityControllerWithRamp.h:40
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