KinematicUnit.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, 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 ArmarXCore::units
19  * @author Christian Boege (boege at kit dot edu)
20  * @date 2011
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
28 
32 
33 #include <RobotAPI/interface/units/KinematicUnitInterface.h>
34 
35 #include <VirtualRobot/Nodes/RobotNode.h>
36 #include <vector>
37 
38 namespace armarx
39 {
40  /**
41  * \class KinematicUnitPropertyDefinitions
42  * \brief
43  */
46  {
47  public:
50  {
51  defineRequiredProperty<std::string>("RobotNodeSetName", "Robot node set name as defined in robot xml file, e.g. 'LeftArm'");
52  defineRequiredProperty<std::string>("RobotFileName", "Robot file name, e.g. robot_model.xml");
53  defineOptionalProperty<std::string>("RobotFileNameProject", "", "Project in which the robot filename is located (if robot is loaded from an external project)");
54  defineOptionalProperty<std::string>("TopicPrefix", "", "Prefix for the sensor value topic name.");
55  defineOptionalProperty<std::string>("SkillProviderTopic", "SkillProviderTopic", "Topic where skill providers provide their skills");
56  }
57  };
58 
59 
60  /**
61  * \defgroup Component-KinematicUnit KinematicUnit
62  * \ingroup RobotAPI-SensorActorUnits
63  * \brief Base unit for kinematic sensors and actors.
64  *
65  * KinematicUnits are SensorActorUnits which provide sensory data in terms of joints angles, joint velocities and joint forces.
66  * Further target joint angles and velocities can be controlled.
67  *
68  * The KinematicUnit retrieves its configuration from a VirtualRobot robot model. Within the model, the joints, the unit
69  * controls are defined with a RobotNodeSet.
70  */
71 
72  /**
73  * @ingroup Component-KinematicUnit
74  * @brief The KinematicUnit class
75  */
76  class KinematicUnit :
77  virtual public KinematicUnitInterface,
78  virtual public SensorActorUnit
79  {
80  public:
81  // inherited from Component
82  std::string getDefaultName() const override
83  {
84  return "KinematicUnit";
85  }
86 
87  void onInitComponent() override;
88  void onConnectComponent() override;
89  void onExitComponent() override;
90 
91  /**
92  * \return the robot xml filename as specified in the configuration
93  */
94  std::string getRobotFilename(const Ice::Current& = Ice::emptyCurrent) const override;
95 
96  /*!
97  * \brief getArmarXPackages
98  * \return All dependent packages, which might contain a robot file.
99  */
100  std::vector< std::string > getArmarXPackages(const Ice::Current& = Ice::emptyCurrent) const override;
101 
102  /**
103  *
104  * \return The name of this robot instance.
105  */
106  std::string getRobotName(const Ice::Current& = Ice::emptyCurrent) const override;
107  /**
108  *
109  * \return The name of this robot instance.
110  */
111  std::string getRobotNodeSetName(const Ice::Current& = Ice::emptyCurrent) const override;
112 
113  /**
114  *
115  * \return The name of the report topic
116  */
117  std::string getReportTopicName(const Ice::Current& = Ice::emptyCurrent) const override;
118 
119  virtual void onInitKinematicUnit() = 0;
120  virtual void onStartKinematicUnit() = 0;
121  virtual void onExitKinematicUnit() = 0;
122 
123  // proxy implementation
124  virtual void requestKinematicUnit(const Ice::StringSeq& nodes, const Ice::Current& c = Ice::emptyCurrent);
125  virtual void releaseKinematicUnit(const Ice::StringSeq& nodes, const Ice::Current& c = Ice::emptyCurrent);
126  void switchControlMode(const NameControlModeMap& targetJointModes, const Ice::Current& c = Ice::emptyCurrent) override;
127  void setJointAngles(const NameValueMap& targetJointAngles, const Ice::Current& c = Ice::emptyCurrent) override;
128  void setJointVelocities(const NameValueMap& targetJointVelocities, const Ice::Current& c = Ice::emptyCurrent) override;
129 
130 
131  //other
132  void setJointAnglesToZero();
134 
135  /**
136  * \see PropertyUser::createPropertyDefinitions()
137  */
139 
140  protected:
141  KinematicUnitListenerPrx listenerPrx;
142 
143  std::string relativeRobotFile;
145  std::string robotNodeSetName;
146  std::string listenerName;
147  std::vector< VirtualRobot::RobotNodePtr > robotNodes;
148  std::vector<std::string> armarXPackages;
149  };
150 }
151 
armarx::KinematicUnitPropertyDefinitions::KinematicUnitPropertyDefinitions
KinematicUnitPropertyDefinitions(std::string prefix)
Definition: KinematicUnit.h:48
armarx::KinematicUnit::relativeRobotFile
std::string relativeRobotFile
Definition: KinematicUnit.h:143
armarx::KinematicUnit::setJointAngles
void setJointAngles(const NameValueMap &targetJointAngles, const Ice::Current &c=Ice::emptyCurrent) override
Definition: KinematicUnit.cpp:128
armarx::KinematicUnit::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: KinematicUnit.cpp:118
armarx::KinematicUnit
The KinematicUnit class.
Definition: KinematicUnit.h:76
armarx::KinematicUnit::onStartKinematicUnit
virtual void onStartKinematicUnit()=0
armarx::KinematicUnit::robotNodeSetName
std::string robotNodeSetName
Definition: KinematicUnit.h:145
Properties.h
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::KinematicUnit::getArmarXPackages
std::vector< std::string > getArmarXPackages(const Ice::Current &=Ice::emptyCurrent) const override
getArmarXPackages
Definition: KinematicUnit.cpp:177
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::KinematicUnit::setJointAnglesToZero
void setJointAnglesToZero()
Definition: KinematicUnit.cpp:136
armarx::KinematicUnit::getReportTopicName
std::string getReportTopicName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: KinematicUnit.cpp:203
armarx::KinematicUnit::getRobotName
std::string getRobotName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: KinematicUnit.cpp:182
armarx::KinematicUnit::onExitKinematicUnit
virtual void onExitKinematicUnit()=0
armarx::KinematicUnit::setJointVelocitiesToZero
void setJointVelocitiesToZero()
Definition: KinematicUnit.cpp:148
armarx::KinematicUnit::armarXPackages
std::vector< std::string > armarXPackages
Definition: KinematicUnit.h:148
SensorActorUnit.h
armarx::KinematicUnit::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: KinematicUnit.cpp:109
armarx::KinematicUnit::robotNodes
std::vector< VirtualRobot::RobotNodePtr > robotNodes
Definition: KinematicUnit.h:147
armarx::KinematicUnit::setJointVelocities
void setJointVelocities(const NameValueMap &targetJointVelocities, const Ice::Current &c=Ice::emptyCurrent) override
Definition: KinematicUnit.cpp:132
armarx::KinematicUnitPropertyDefinitions
Definition: KinematicUnit.h:44
armarx::KinematicUnit::getRobotNodeSetName
std::string getRobotNodeSetName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: KinematicUnit.cpp:194
armarx::KinematicUnit::releaseKinematicUnit
virtual void releaseKinematicUnit(const Ice::StringSeq &nodes, const Ice::Current &c=Ice::emptyCurrent)
Definition: KinematicUnit.cpp:166
Component.h
armarx::KinematicUnit::switchControlMode
void switchControlMode(const NameControlModeMap &targetJointModes, const Ice::Current &c=Ice::emptyCurrent) override
Definition: KinematicUnit.cpp:124
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::KinematicUnit::listenerName
std::string listenerName
Definition: KinematicUnit.h:146
armarx::KinematicUnit::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: KinematicUnit.cpp:208
armarx::KinematicUnit::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: KinematicUnit.cpp:40
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::KinematicUnit::listenerPrx
KinematicUnitListenerPrx listenerPrx
Definition: KinematicUnit.h:141
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::SensorActorUnit
Base Class for SensorActorUnits.
Definition: SensorActorUnit.h:42
armarx::KinematicUnit::requestKinematicUnit
virtual void requestKinematicUnit(const Ice::StringSeq &nodes, const Ice::Current &c=Ice::emptyCurrent)
Definition: KinematicUnit.cpp:161
armarx::KinematicUnit::onInitKinematicUnit
virtual void onInitKinematicUnit()=0
armarx::KinematicUnit::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: KinematicUnit.h:82
armarx::KinematicUnit::getRobotFilename
std::string getRobotFilename(const Ice::Current &=Ice::emptyCurrent) const override
Definition: KinematicUnit.cpp:172
armarx::KinematicUnit::robot
VirtualRobot::RobotPtr robot
Definition: KinematicUnit.h:144
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
ImportExportComponent.h