EnvironmentalPrimitiveSegment.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::WorkingMemory
17 * @author Peter Kaiser (peter dot kaiser at kit dot edu)
18 * @date 2014
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
26 
27 #include <MemoryX/interface/core/EntityBase.h>
28 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
29 #include <MemoryX/interface/memorytypes/MemorySegments.h>
32 
33 namespace memoryx
34 {
36  virtual public WorkingMemoryEntitySegment<EnvironmentalPrimitive>,
37  virtual public EnvironmentalPrimitiveSegmentBase
38  {
39  public:
41 
42  EnvironmentalPrimitiveBaseList
43  getEnvironmentalPrimitives(const ::Ice::Current& c = Ice::emptyCurrent) const override;
44  PlanePrimitiveBaseList
45  getPlanes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
46  SpherePrimitiveBaseList
47  getSpheres(const ::Ice::Current& c = Ice::emptyCurrent) const override;
48  CylinderPrimitiveBaseList
49  getCylinders(const ::Ice::Current& c = Ice::emptyCurrent) const override;
50  BoxPrimitiveBaseList getBoxes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
51 
52  EnvironmentalPrimitiveBasePtr
53  getEnvironmentalPrimitiveById(const std::string& id,
54  const ::Ice::Current& c = Ice::emptyCurrent) const override;
55  PlanePrimitiveBasePtr
56  getPlaneById(const std::string& id,
57  const ::Ice::Current& c = Ice::emptyCurrent) const override;
58  SpherePrimitiveBasePtr
59  getSphereById(const std::string& id,
60  const ::Ice::Current& c = Ice::emptyCurrent) const override;
61  CylinderPrimitiveBasePtr
62  getCylinderById(const std::string& id,
63  const ::Ice::Current& c = Ice::emptyCurrent) const override;
64  BoxPrimitiveBasePtr getBoxById(const std::string& id,
65  const ::Ice::Current& c = Ice::emptyCurrent) const override;
66 
67  EnvironmentalPrimitiveBaseList getEnvironmentalPrimitivesByTimestamp(
68  const armarx::TimestampBasePtr& timestamp,
69  const ::Ice::Current& c = Ice::emptyCurrent) const override;
70  PlanePrimitiveBaseList
71  getPlanesByTimestamp(const armarx::TimestampBasePtr& timestamp,
72  const ::Ice::Current& c = Ice::emptyCurrent) const override;
73  SpherePrimitiveBaseList
74  getSpheresByTimestamp(const armarx::TimestampBasePtr& timestamp,
75  const ::Ice::Current& c = Ice::emptyCurrent) const override;
76  CylinderPrimitiveBaseList
77  getCylindersByTimestamp(const armarx::TimestampBasePtr& timestamp,
78  const ::Ice::Current& c = Ice::emptyCurrent) const override;
79  BoxPrimitiveBaseList
80  getBoxesByTimestamp(const armarx::TimestampBasePtr& timestamp,
81  const ::Ice::Current& c = Ice::emptyCurrent) const override;
82 
83  EnvironmentalPrimitiveBaseList getMostRecentEnvironmentalPrimitives(
84  const ::Ice::Current& c = Ice::emptyCurrent) const override;
85  PlanePrimitiveBaseList
86  getMostRecentPlanes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
87  SpherePrimitiveBaseList
88  getMostRecentSpheres(const ::Ice::Current& c = Ice::emptyCurrent) const override;
89  CylinderPrimitiveBaseList
90  getMostRecentCylinders(const ::Ice::Current& c = Ice::emptyCurrent) const override;
91  BoxPrimitiveBaseList
92  getMostRecentBoxes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
93 
94  void removePrimitivesByTimestamp(const armarx::TimestampBasePtr& timestamp,
95  const ::Ice::Current& c = Ice::emptyCurrent) override;
96  void removeOlderPrimitives(const armarx::TimestampBasePtr& olderThan,
97  const ::Ice::Current& c = Ice::emptyCurrent) override;
98 
99  protected:
100  template <typename EntityPtrType>
101  Ice::Long
102  getMostRecentTimestamp(const std::vector<EntityPtrType>& primitives,
103  const ::Ice::Current& c = Ice::emptyCurrent) const
104  {
105  Ice::Long mostRecentTimestamp = 0;
106 
107  for (auto& p : primitives)
108  {
109  Ice::Long t = p->getTime(c)->timestamp;
110  if (t > mostRecentTimestamp)
111  {
112  mostRecentTimestamp = t;
113  }
114  }
115 
116  return mostRecentTimestamp;
117  }
118  };
119 
121 } // namespace memoryx
EnvironmentalPrimitive.h
memoryx::EnvironmentalPrimitiveSegment::getMostRecentTimestamp
Ice::Long getMostRecentTimestamp(const std::vector< EntityPtrType > &primitives, const ::Ice::Current &c=Ice::emptyCurrent) const
Definition: EnvironmentalPrimitiveSegment.h:102
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::WorkingMemoryEntitySegment
Definition: WorkingMemoryEntitySegment.h:45
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:918
WorkingMemoryEntitySegment.h
memoryx::EnvironmentalPrimitiveSegment
Definition: EnvironmentalPrimitiveSegment.h:35
ImportExportComponent.h