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