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 
29 
30 #include <MemoryX/interface/core/EntityBase.h>
31 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
32 #include <MemoryX/interface/memorytypes/MemorySegments.h>
33 
34 namespace memoryx
35 {
37  virtual public WorkingMemoryEntitySegment<EnvironmentalPrimitive>,
38  virtual public EnvironmentalPrimitiveSegmentBase
39  {
40  public:
42 
43  EnvironmentalPrimitiveBaseList getEnvironmentalPrimitives(const ::Ice::Current& c = Ice::emptyCurrent) const override;
44  PlanePrimitiveBaseList getPlanes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
45  SpherePrimitiveBaseList getSpheres(const ::Ice::Current& c = Ice::emptyCurrent) const override;
46  CylinderPrimitiveBaseList getCylinders(const ::Ice::Current& c = Ice::emptyCurrent) const override;
47  BoxPrimitiveBaseList getBoxes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
48 
49  EnvironmentalPrimitiveBasePtr getEnvironmentalPrimitiveById(const std::string& id, const ::Ice::Current& c = Ice::emptyCurrent) const override;
50  PlanePrimitiveBasePtr getPlaneById(const std::string& id, const ::Ice::Current& c = Ice::emptyCurrent) const override;
51  SpherePrimitiveBasePtr getSphereById(const std::string& id, const ::Ice::Current& c = Ice::emptyCurrent) const override;
52  CylinderPrimitiveBasePtr getCylinderById(const std::string& id, const ::Ice::Current& c = Ice::emptyCurrent) const override;
53  BoxPrimitiveBasePtr getBoxById(const std::string& id, const ::Ice::Current& c = Ice::emptyCurrent) const override;
54 
55  EnvironmentalPrimitiveBaseList getEnvironmentalPrimitivesByTimestamp(const armarx::TimestampBasePtr& timestamp, const ::Ice::Current& c = Ice::emptyCurrent) const override;
56  PlanePrimitiveBaseList getPlanesByTimestamp(const armarx::TimestampBasePtr& timestamp, const ::Ice::Current& c = Ice::emptyCurrent) const override;
57  SpherePrimitiveBaseList getSpheresByTimestamp(const armarx::TimestampBasePtr& timestamp, const ::Ice::Current& c = Ice::emptyCurrent) const override;
58  CylinderPrimitiveBaseList getCylindersByTimestamp(const armarx::TimestampBasePtr& timestamp, const ::Ice::Current& c = Ice::emptyCurrent) const override;
59  BoxPrimitiveBaseList getBoxesByTimestamp(const armarx::TimestampBasePtr& timestamp, const ::Ice::Current& c = Ice::emptyCurrent) const override;
60 
61  EnvironmentalPrimitiveBaseList getMostRecentEnvironmentalPrimitives(const ::Ice::Current& c = Ice::emptyCurrent) const override;
62  PlanePrimitiveBaseList getMostRecentPlanes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
63  SpherePrimitiveBaseList getMostRecentSpheres(const ::Ice::Current& c = Ice::emptyCurrent) const override;
64  CylinderPrimitiveBaseList getMostRecentCylinders(const ::Ice::Current& c = Ice::emptyCurrent) const override;
65  BoxPrimitiveBaseList getMostRecentBoxes(const ::Ice::Current& c = Ice::emptyCurrent) const override;
66 
67  void removePrimitivesByTimestamp(const armarx::TimestampBasePtr& timestamp, const ::Ice::Current& c = Ice::emptyCurrent) override;
68  void removeOlderPrimitives(const armarx::TimestampBasePtr& olderThan, const ::Ice::Current& c = Ice::emptyCurrent) override;
69 
70  protected:
71  template<typename EntityPtrType> Ice::Long getMostRecentTimestamp(const std::vector<EntityPtrType>& primitives, const ::Ice::Current& c = Ice::emptyCurrent) const
72  {
73  Ice::Long mostRecentTimestamp = 0;
74 
75  for (auto& p : primitives)
76  {
77  Ice::Long t = p->getTime(c)->timestamp;
78  if (t > mostRecentTimestamp)
79  {
80  mostRecentTimestamp = t;
81  }
82  }
83 
84  return mostRecentTimestamp;
85  }
86  };
87 
89 }
90 
EnvironmentalPrimitive.h
memoryx::EnvironmentalPrimitiveSegment::getMostRecentTimestamp
Ice::Long getMostRecentTimestamp(const std::vector< EntityPtrType > &primitives, const ::Ice::Current &c=Ice::emptyCurrent) const
Definition: EnvironmentalPrimitiveSegment.h:71
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
IceInternal::Handle
Definition: forward_declarations.h:8
memoryx::WorkingMemoryEntitySegment
Definition: WorkingMemoryEntitySegment.h:44
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
WorkingMemoryEntitySegment.h
memoryx::EnvironmentalPrimitiveSegment
Definition: EnvironmentalPrimitiveSegment.h:36
ImportExportComponent.h