LocalizationJobContainer.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package MemoryX::Core
17 * @author Kai Welke <welke@kit.edu>
18 * @copyright 2012 Kai Welke
19 * @license http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <string>
26 
27 #include <Eigen/Eigen>
28 
29 #include <Ice/Ice.h>
30 
31 #include <RobotAPI/interface/core/RobotState.h>
33 
35 
36 namespace memoryx
37 {
38  class LocalizationQuery;
40 
41  /**
42  * @brief The LocalizationJobContainer class is used by ObjectLocalizationMemoryUpdater to create and execute segmentation specific groups of localization jobs.
43  */
44  class LocalizationJobContainer : public Ice::LocalObject
45  {
46  public:
47  LocalizationJobContainer(const std::string& recognitionMethod) :
48  recognitionMethod(recognitionMethod)
49  {
50  robotPose = new armarx::Pose(Eigen::Matrix4f::Identity());
51  }
52 
54  {
55  try
56  {
57  if (this->robotStatePrx)
58  {
59  this->robotStatePrx->unref();
60  }
61  }
62  catch (...)
63  {
64  }
65  }
66 
67  void
69  {
70  jobs.push_back(job);
71 
72  std::vector<std::string> jobClassNames = job->getClassNamesToBeLocalized();
73 
74  for (std::vector<std::string>::iterator iterNames = jobClassNames.begin();
75  iterNames != jobClassNames.end();
76  iterNames++)
77  {
78  classNamesUnique.insert(*iterNames);
79  }
80  }
81 
82  /**
83  * @brief startJobs calls the LocalizationJob::start() method on all jobs added via LocalizationJobContainer::addJob().
84  */
85  void
87  {
88  for (LocalizationJobList::iterator iter = jobs.begin(); iter != jobs.end(); iter++)
89  {
90  (*iter)->start();
91  }
92  }
93 
94  /**
95  * @brief finishJobs sets the finished property of all localization jobs to true
96  *
97  * This results in LocalizationQuery::getFinished() to return true, indicating that all localization jobs have finished running.
98  * Calls LocalizationJob::setFinished() on each job added via LocalizationJobContainer::addJob().
99  */
100  void
102  {
103  for (LocalizationJobList::iterator iter = jobs.begin(); iter != jobs.end(); iter++)
104  {
105  (*iter)->setFinished();
106  }
107  }
108 
109  std::vector<std::string>
111  {
112  std::vector<std::string> classNames;
113  std::copy(
114  classNamesUnique.begin(), classNamesUnique.end(), std::back_inserter(classNames));
115 
116  return classNames;
117  }
118 
119  std::vector<LocalizationQueryPtr>
121  {
122  std::vector<LocalizationQueryPtr> queries;
123 
124  for (LocalizationJobList::iterator iter = jobs.begin(); iter != jobs.end(); iter++)
125  {
126  queries.push_back((*iter)->getQuery());
127  }
128 
129  return queries;
130  }
131 
132  std::string
134  {
135  return recognitionMethod;
136  }
137 
138  void
140  {
141  if (this->robotStatePrx)
142  {
143  this->robotStatePrx->unref();
144  }
145 
146  this->robotStatePrx = robotStatePrx;
147 
148  if (this->robotStatePrx)
149  {
150  this->robotStatePrx->ref();
151  }
152  }
153 
156  {
157  return robotStatePrx;
158  }
159 
160  void
161  setRobotPose(const armarx::PosePtr& robotPose)
162  {
163  this->robotPose = robotPose;
164  }
165 
168  {
169  return robotPose;
170  }
171 
172 
173  private:
174  LocalizationJobList jobs;
175  std::set<std::string> classNamesUnique;
176  std::string recognitionMethod;
177  armarx::SharedRobotInterfacePrx robotStatePrx;
178  armarx::PosePtr robotPose;
179  };
180 
182 } // namespace memoryx
memoryx::LocalizationJobContainer::getRecognitionMethod
std::string getRecognitionMethod()
Definition: LocalizationJobContainer.h:133
memoryx::LocalizationJobContainer::getRobotPose
armarx::PosePtr getRobotPose()
Definition: LocalizationJobContainer.h:167
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
Pose.h
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::LocalizationJobContainer::setRobotPose
void setRobotPose(const armarx::PosePtr &robotPose)
Definition: LocalizationJobContainer.h:161
IceInternal::Handle
Definition: forward_declarations.h:8
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
copy
Use of this software is granted under one of the following two to be chosen freely by the user Boost Software License Version Marcin Kalicinski Permission is hereby free of to any person or organization obtaining a copy of the software and accompanying documentation covered by this and transmit the and to prepare derivative works of the and to permit third parties to whom the Software is furnished to do all subject to the including the above license this restriction and the following must be included in all copies of the in whole or in and all derivative works of the unless such copies or derivative works are solely in the form of machine executable object code generated by a source language processor THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR TITLE AND NON INFRINGEMENT IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN TORT OR ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE The MIT Marcin Kalicinski Permission is hereby free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
Definition: license.txt:39
LocalizationJob.h
memoryx::LocalizationJobContainer::LocalizationJobContainer
LocalizationJobContainer(const std::string &recognitionMethod)
Definition: LocalizationJobContainer.h:47
memoryx::LocalizationJobContainer::getQueries
std::vector< LocalizationQueryPtr > getQueries()
Definition: LocalizationJobContainer.h:120
memoryx::LocalizationJobContainer::startJobs
void startJobs()
startJobs calls the LocalizationJob::start() method on all jobs added via LocalizationJobContainer::a...
Definition: LocalizationJobContainer.h:86
memoryx::LocalizationJobContainer::setRobotState
void setRobotState(const armarx::SharedRobotInterfacePrx &robotStatePrx)
Definition: LocalizationJobContainer.h:139
memoryx::LocalizationJobContainer::getRobotState
armarx::SharedRobotInterfacePrx getRobotState()
Definition: LocalizationJobContainer.h:155
armarx::VariantType::LocalizationQuery
const armarx::VariantTypeId LocalizationQuery
Definition: LocalizationQuery.h:37
memoryx::LocalizationJobContainer
The LocalizationJobContainer class is used by ObjectLocalizationMemoryUpdater to create and execute s...
Definition: LocalizationJobContainer.h:44
memoryx::LocalizationJobContainer::finishJobs
void finishJobs()
finishJobs sets the finished property of all localization jobs to true
Definition: LocalizationJobContainer.h:101
IceUtil::Handle
Definition: forward_declarations.h:30
memoryx::LocalizationJobContainer::getClassNamesUnique
std::vector< std::string > getClassNamesUnique()
Definition: LocalizationJobContainer.h:110
IceInternal::ProxyHandle<::IceProxy::armarx::SharedRobotInterface >
memoryx::LocalizationJobList
std::vector< LocalizationJobPtr > LocalizationJobList
Definition: LocalizationJob.h:75
memoryx::LocalizationJobContainer::~LocalizationJobContainer
~LocalizationJobContainer() override
Definition: LocalizationJobContainer.h:53
memoryx::LocalizationJobContainer::addJob
void addJob(const LocalizationJobPtr &job)
Definition: LocalizationJobContainer.h:68