HandMarkerLocalization.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-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 VisionX::Component
19 * @author Kai Welke (welke at kit dot edu)
20 * @date 2013
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27// VisionX
28#include <VirtualRobot/VirtualRobot.h>
29
31
32// forward declarations
33class CByteImage;
34class CVisualTargetLocator;
35class CColorParameterSet;
36
37namespace visionx
38{
41 {
42 public:
45 {
47 "ColorParameterFile",
48 "VisionX/examples/colors.txt",
49 "The color parameter file configures the colors used for segmentable recognition "
50 "(usually colors.txt)");
52 "ShowSegmentedResultImages",
53 true,
54 "Decide whether to calculate color-segmented images with the marker color and show "
55 "them as result images. Causes small additional computational effort.");
57 "TCPNameLeft", "TCP L", "Name of the TCP of the left robot hand.");
59 "TCPNameRight", "TCP R", "Name of the TCP of the right robot hand.");
61 "MarkerNameLeft", "Marker L", "Name of the marker ball at the left robot hand.");
63 "MarkerNameRight", "Marker R", "Name of the marker ball at the right robot hand.");
65 "UseVision",
66 true,
67 "You can switch off the use of the camera images. The returned pose will then just "
68 "be taken from the forward kinematics.");
70 "RobotStateComponentName",
71 "RobotStateComponent",
72 "Name of the RobotStateComponent that should be used");
74 "MaximalAcceptedDistanceFromForwardKinematics",
75 200,
76 "Maximal distance that the localization result may have from the position "
77 "determined by forward kinematics. If it is further away, it is discarded..");
78 }
79 };
80
81 /**
82 * HandMarkerLocalization uses the CVisualTargetLocator of IVT in order to recognize and localize the marker balls at the hands of the robot.
83 * The returned hand pose takes the offset from marker to TCP into account, which is defined in the robot model file.
84 * The marker color is read from PriorKnowledge and CommonStorage via MemoryX.
85 * The hand localization is invoked automatically by the working memory if the object has been requested there.
86 */
88 {
89 public:
91
92 /**
93 * @see PropertyUser::createPropertyDefinitions()
94 */
101
102 /**
103 * @see Component::getDefaultName()
104 */
105 std::string
106 getDefaultName() const override
107 {
108 return "HandMarkerLocalization";
109 }
110
111 protected:
112 /**
113 * @see ObjectLocalizerProcessor::onInitObjectLocalizerProcessor()
114 */
115 void onInitObjectLocalizerProcessor() override;
116
117 /**
118 * Initialize stuff here?
119 *
120 * @see ObjectLocalizerProcessor::onConnectObjectLocalizerProcessor()
121 */
122 void onConnectObjectLocalizerProcessor() override;
123
124 /**
125 * @see ObjectLocalizerProcessor::onExitObjectLocalizerProcessor()
126 */
127 void
129 {
130 }
131
132 /**
133 * Initializes segmentable recognition
134 *
135 * @return success
136 */
137 bool initRecognizer() override;
138
139 /**
140 * Add a memory entity representing the hand marker in order to set its properties
141 *
142 * @param objectClassEntity entity containing all information available for the object class
143 * @param fileManager GridFileManager required to read files associated to prior knowledge from the database.
144 *
145 * @return success of adding this entity
146 */
147 bool addObjectClass(const memoryx::EntityPtr& objectClassEntity,
148 const memoryx::GridFileManagerPtr& fileManager) override;
149
150 /**
151 * localize one or both hand markers
152 *
153 * @param objectClassNames is ignored here
154 * @param cameraImages the two input images
155 * @param resultImages the two result images. are provided if result images are enabled.
156 *
157 * @return list of object instances
158 */
159 memoryx::ObjectLocalizationResultList
160 localizeObjectClasses(const std::vector<std::string>& objectClassNames,
161 CByteImage** cameraImages,
162 armarx::MetaInfoSizeBasePtr imageMetaInfo,
163 CByteImage** resultImages) override;
164
165
166 private:
167 void drawCrossInImage(CByteImage* image, Eigen::Vector3f point, bool leftCamera);
168
169
170 // decides whether images or forward kinematic will be used
171 bool useVision;
172
173 // locator for the tracking balls
174 CVisualTargetLocator* visualTargetLocator;
175 std::map<std::string, ObjectColor> markerColors;
176
177 // remote robot for the orientation
178 VirtualRobot::RobotPtr localRobot;
179 std::string tcpNameLeft, tcpNameRight, markerNameLeft, markerNameRight;
180
181 // visualization
182 bool showSegmentedResultImages;
183 CColorParameterSet* colorParameterSet;
184
185 armarx::RobotStateComponentInterfacePrx robotStateComponent;
186 };
187} // namespace visionx
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
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)
bool initRecognizer() override
Initializes segmentable recognition.
memoryx::ObjectLocalizationResultList localizeObjectClasses(const std::vector< std::string > &objectClassNames, CByteImage **cameraImages, armarx::MetaInfoSizeBasePtr imageMetaInfo, CByteImage **resultImages) override
localize one or both hand markers
void onConnectObjectLocalizerProcessor() override
Initialize stuff here?
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
std::string getDefaultName() const override
bool addObjectClass(const memoryx::EntityPtr &objectClassEntity, const memoryx::GridFileManagerPtr &fileManager) override
Add a memory entity representing the hand marker in order to set its properties.
armarx::MetaInfoSizeBasePtr imageMetaInfo
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
IceInternal::Handle< Entity > EntityPtr
Typedef of EntityPtr as IceInternal::Handle<Entity> for convenience.
Definition Entity.h:45
std::shared_ptr< GridFileManager > GridFileManagerPtr
ArmarX headers.