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
27#include <vector>
28
29#include <VirtualRobot/VirtualRobot.h>
30
34
36#include <RobotAPI/interface/units/KinematicUnitInterface.h>
37
38namespace armarx
39{
40 /**
41 * \class KinematicUnitPropertyDefinitions
42 * \brief
43 */
45 {
46 public:
48 {
50 "RobotNodeSetName",
51 "Robot node set name as defined in robot xml file, e.g. 'LeftArm'");
53 "Robot file name, e.g. robot_model.xml");
54 defineOptionalProperty<std::string>("RobotFileNameProject",
55 "",
56 "Project in which the robot filename is located "
57 "(if robot is loaded from an external project)");
59 "TopicPrefix", "", "Prefix for the sensor value topic name.");
60 defineOptionalProperty<std::string>("SkillProviderTopic",
61 "SkillProviderTopic",
62 "Topic where skill providers provide their skills");
63 }
64 };
65
66 /**
67 * \defgroup Component-KinematicUnit KinematicUnit
68 * \ingroup RobotAPI-SensorActorUnits
69 * \brief Base unit for kinematic sensors and actors.
70 *
71 * KinematicUnits are SensorActorUnits which provide sensory data in terms of joints angles, joint velocities and joint forces.
72 * Further target joint angles and velocities can be controlled.
73 *
74 * The KinematicUnit retrieves its configuration from a VirtualRobot robot model. Within the model, the joints, the unit
75 * controls are defined with a RobotNodeSet.
76 */
77
78 /**
79 * @ingroup Component-KinematicUnit
80 * @brief The KinematicUnit class
81 */
82 class KinematicUnit : virtual public KinematicUnitInterface, virtual public SensorActorUnit
83 {
84 public:
85 // inherited from Component
86 std::string
87 getDefaultName() const override
88 {
89 return "KinematicUnit";
90 }
91
92 void onInitComponent() override;
93 void onConnectComponent() override;
94 void onExitComponent() override;
95
96 /**
97 * \return the robot xml filename as specified in the configuration
98 */
99 std::string getRobotFilename(const Ice::Current& = Ice::emptyCurrent) const override;
100
101 /*!
102 * \brief getArmarXPackages
103 * \return All dependent packages, which might contain a robot file.
104 */
105 std::vector<std::string>
106 getArmarXPackages(const Ice::Current& = Ice::emptyCurrent) const override;
107
108 /**
109 *
110 * \return The name of this robot instance.
111 */
112 std::string getRobotName(const Ice::Current& = Ice::emptyCurrent) const override;
113 /**
114 *
115 * \return The name of this robot instance.
116 */
117 std::string getRobotNodeSetName(const Ice::Current& = Ice::emptyCurrent) const override;
118
119 /**
120 *
121 * \return The name of the report topic
122 */
123 std::string getReportTopicName(const Ice::Current& = Ice::emptyCurrent) const override;
124
125 virtual void onInitKinematicUnit() = 0;
126 virtual void onStartKinematicUnit() = 0;
127 virtual void onExitKinematicUnit() = 0;
128
129 // proxy implementation
130 virtual void requestKinematicUnit(const Ice::StringSeq& nodes,
131 const Ice::Current& c = Ice::emptyCurrent);
132 virtual void releaseKinematicUnit(const Ice::StringSeq& nodes,
133 const Ice::Current& c = Ice::emptyCurrent);
134 void switchControlMode(const NameControlModeMap& targetJointModes,
135 const Ice::Current& c = Ice::emptyCurrent) override;
136 void setJointAngles(const NameValueMap& targetJointAngles,
137 const Ice::Current& c = Ice::emptyCurrent) override;
138 void setJointVelocities(const NameValueMap& targetJointVelocities,
139 const Ice::Current& c = Ice::emptyCurrent) override;
140
141
142 //other
145
146 /**
147 * \see PropertyUser::createPropertyDefinitions()
148 */
150
151 protected:
152 KinematicUnitListenerPrx listenerPrx;
153
154 std::string relativeRobotFile;
156 std::string robotNodeSetName;
157 std::string listenerName;
158 std::vector<VirtualRobot::RobotNodePtr> robotNodes;
159 std::vector<std::string> armarXPackages;
160 };
161} // namespace armarx
constexpr T c
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
KinematicUnitPropertyDefinitions(std::string prefix)
The KinematicUnit class.
std::string getRobotName(const Ice::Current &=Ice::emptyCurrent) const override
void onInitComponent() override
Pure virtual hook for the subclass.
virtual void onStartKinematicUnit()=0
VirtualRobot::RobotPtr robot
std::vector< std::string > armarXPackages
std::string relativeRobotFile
void setJointAngles(const NameValueMap &targetJointAngles, const Ice::Current &c=Ice::emptyCurrent) override
void switchControlMode(const NameControlModeMap &targetJointModes, const Ice::Current &c=Ice::emptyCurrent) override
virtual void releaseKinematicUnit(const Ice::StringSeq &nodes, const Ice::Current &c=Ice::emptyCurrent)
std::vector< VirtualRobot::RobotNodePtr > robotNodes
std::vector< std::string > getArmarXPackages(const Ice::Current &=Ice::emptyCurrent) const override
getArmarXPackages
std::string robotNodeSetName
virtual void requestKinematicUnit(const Ice::StringSeq &nodes, const Ice::Current &c=Ice::emptyCurrent)
void onConnectComponent() override
Pure virtual hook for the subclass.
virtual void onExitKinematicUnit()=0
PropertyDefinitionsPtr createPropertyDefinitions() override
virtual void onInitKinematicUnit()=0
void onExitComponent() override
Hook for subclass.
std::string getRobotFilename(const Ice::Current &=Ice::emptyCurrent) const override
KinematicUnitListenerPrx listenerPrx
std::string getRobotNodeSetName(const Ice::Current &=Ice::emptyCurrent) const override
void setJointVelocities(const NameValueMap &targetJointVelocities, const Ice::Current &c=Ice::emptyCurrent) override
std::string getDefaultName() const override
Retrieve default name of component.
std::string getReportTopicName(const Ice::Current &=Ice::emptyCurrent) const override
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
SensorActorUnit()
Constructs a SensorActorUnit.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.