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 #include <Ice/Ice.h>
27 
29 #include <RobotAPI/interface/core/RobotState.h>
31 
32 #include <Eigen/Eigen>
33 
34 
35 namespace memoryx
36 {
37  /**
38  * @brief The LocalizationJobContainer class is used by ObjectLocalizationMemoryUpdater to create and execute segmentation specific groups of localization jobs.
39  */
41  public Ice::LocalObject
42  {
43  public:
44  LocalizationJobContainer(const std::string& recognitionMethod) :
45  recognitionMethod(recognitionMethod)
46  {
47  robotPose = new armarx::Pose(Eigen::Matrix4f::Identity());
48  }
49 
51  {
52  try
53  {
54  if (this->robotStatePrx)
55  {
56  this->robotStatePrx->unref();
57  }
58  }
59  catch (...) {}
60  }
61 
62  void addJob(const LocalizationJobPtr& job)
63  {
64  jobs.push_back(job);
65 
66  std::vector<std::string> jobClassNames = job->getClassNamesToBeLocalized();
67 
68  for (std::vector<std::string>::iterator iterNames = jobClassNames.begin() ; iterNames != jobClassNames.end() ; iterNames++)
69  {
70  classNamesUnique.insert(*iterNames);
71  }
72  }
73 
74  /**
75  * @brief startJobs calls the LocalizationJob::start() method on all jobs added via LocalizationJobContainer::addJob().
76  */
77  void startJobs()
78  {
79  for (LocalizationJobList::iterator iter = jobs.begin() ; iter != jobs.end() ; iter++)
80  {
81  (*iter)->start();
82  }
83  }
84 
85  /**
86  * @brief finishJobs sets the finished property of all localization jobs to true
87  *
88  * This results in LocalizationQuery::getFinished() to return true, indicating that all localization jobs have finished running.
89  * Calls LocalizationJob::setFinished() on each job added via LocalizationJobContainer::addJob().
90  */
91  void finishJobs()
92  {
93  for (LocalizationJobList::iterator iter = jobs.begin() ; iter != jobs.end() ; iter++)
94  {
95  (*iter)->setFinished();
96  }
97  }
98 
99  std::vector<std::string> getClassNamesUnique()
100  {
101  std::vector<std::string> classNames;
102  std::copy(classNamesUnique.begin(), classNamesUnique.end(), std::back_inserter(classNames));
103 
104  return classNames;
105  }
106 
107  std::vector<LocalizationQueryPtr> getQueries()
108  {
109  std::vector<LocalizationQueryPtr> queries;
110 
111  for (LocalizationJobList::iterator iter = jobs.begin() ; iter != jobs.end() ; iter++)
112  {
113  queries.push_back((*iter)->getQuery());
114  }
115 
116  return queries;
117  }
118 
119  std::string getRecognitionMethod()
120  {
121  return recognitionMethod;
122  }
123 
125  {
126  if (this->robotStatePrx)
127  {
128  this->robotStatePrx->unref();
129  }
130 
131  this->robotStatePrx = robotStatePrx;
132 
133  if (this->robotStatePrx)
134  {
135  this->robotStatePrx->ref();
136  }
137  }
138 
140  {
141  return robotStatePrx;
142  }
143 
144  void setRobotPose(const armarx::PosePtr& robotPose)
145  {
146  this->robotPose = robotPose;
147  }
148 
150  {
151  return robotPose;
152  }
153 
154 
155  private:
156  LocalizationJobList jobs;
157  std::set<std::string> classNamesUnique;
158  std::string recognitionMethod;
159  armarx::SharedRobotInterfacePrx robotStatePrx;
160  armarx::PosePtr robotPose;
161  };
162 
164 }
165 
memoryx::LocalizationJobContainer::getRecognitionMethod
std::string getRecognitionMethod()
Definition: LocalizationJobContainer.h:119
memoryx::LocalizationJobContainer::getRobotPose
armarx::PosePtr getRobotPose()
Definition: LocalizationJobContainer.h:149
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:144
IceInternal::Handle< Pose >
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
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:44
memoryx::LocalizationJobContainer::getQueries
std::vector< LocalizationQueryPtr > getQueries()
Definition: LocalizationJobContainer.h:107
memoryx::LocalizationJobContainer::startJobs
void startJobs()
startJobs calls the LocalizationJob::start() method on all jobs added via LocalizationJobContainer::a...
Definition: LocalizationJobContainer.h:77
memoryx::LocalizationJobContainer::setRobotState
void setRobotState(const armarx::SharedRobotInterfacePrx &robotStatePrx)
Definition: LocalizationJobContainer.h:124
memoryx::LocalizationJobContainer::getRobotState
armarx::SharedRobotInterfacePrx getRobotState()
Definition: LocalizationJobContainer.h:139
memoryx::LocalizationJobContainer
The LocalizationJobContainer class is used by ObjectLocalizationMemoryUpdater to create and execute s...
Definition: LocalizationJobContainer.h:40
memoryx::LocalizationJobContainer::finishJobs
void finishJobs()
finishJobs sets the finished property of all localization jobs to true
Definition: LocalizationJobContainer.h:91
IceUtil::Handle
Definition: forward_declarations.h:29
memoryx::LocalizationJobContainer::getClassNamesUnique
std::vector< std::string > getClassNamesUnique()
Definition: LocalizationJobContainer.h:99
IceInternal::ProxyHandle< ::IceProxy::armarx::SharedRobotInterface >
memoryx::LocalizationJobList
std::vector< LocalizationJobPtr > LocalizationJobList
Definition: LocalizationJob.h:68
memoryx::LocalizationJobContainer::~LocalizationJobContainer
~LocalizationJobContainer() override
Definition: LocalizationJobContainer.h:50
memoryx::LocalizationJobContainer::addJob
void addJob(const LocalizationJobPtr &job)
Definition: LocalizationJobContainer.h:62