LocalizationStrategyRepeated.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
26#include <IceUtil/Time.h>
27
29
31
32namespace memoryx
33{
35 {
36 public:
37 LocalizationStrategyRepeated(unsigned int cycleTimeMS)
38 {
39 started = false;
40 this->cycleTimeMS = cycleTimeMS;
41 }
42
43 void
44 start() override
45 {
46 startTime = armarx::TimeUtil::GetTime();
47 started = true;
48 }
49
50 bool
51 waiting() override
52 {
53 if (!started)
54 {
55 return true;
56 }
57 else
58 {
59 IceUtil::Time currentTime = armarx::TimeUtil::GetTime();
60 IceUtil::Time diff = currentTime - startTime;
61
62 if (diff.toMilliSeconds() > cycleTimeMS)
63 {
64 return true;
65 }
66 else
67 {
68 return false;
69 }
70 }
71 }
72
73 private:
74 bool started;
75 IceUtil::Time startTime;
76 unsigned int cycleTimeMS;
77 };
78
80} // namespace memoryx
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
Definition TimeUtil.cpp:42
The LocalizationJob class is the description of the basic workload executed by ObjectLocalizationMemo...
VirtualRobot headers.
IceUtil::Handle< LocalizationStrategyRepeated > LocalizationStrategyRepeatedPtr