Segment.cpp
Go to the documentation of this file.
1
#include "
Segment.h
"
2
3
#include <sstream>
4
5
#include <
ArmarXCore/core/application/properties/PluginAll.h
>
6
#include <
ArmarXCore/core/application/properties/PropertyDefinitionContainer.h
>
7
#include <
ArmarXCore/core/logging/Logging.h
>
8
#include <
ArmarXCore/core/time/TimeUtil.h
>
9
10
#include <
RobotAPI/libraries/armem/client/Writer.h
>
11
#include <
RobotAPI/libraries/armem/client/query/Builder.h
>
12
#include <
RobotAPI/libraries/armem/client/query/query_fns.h
>
13
#include <
RobotAPI/libraries/armem/core/MemoryID.h
>
14
#include <
RobotAPI/libraries/armem/core/aron_conversions.h
>
15
#include <
RobotAPI/libraries/armem/server/MemoryToIceAdapter.h
>
16
#include <
RobotAPI/libraries/armem/util/util.h
>
17
#include <RobotAPI/libraries/armem_objects/aron/Attachment.aron.generated.h>
18
#include <
RobotAPI/libraries/armem_objects/aron_conversions.h
>
19
#include <RobotAPI/libraries/armem_robot_state/aron/Robot.aron.generated.h>
20
#include <
RobotAPI/libraries/aron/common/aron_conversions.h
>
21
22
namespace
armarx::armem::server::obj::attachments
23
{
24
Segment::Segment
(
armem::server::MemoryToIceAdapter
& memoryToIceAdapter) :
25
iceMemory(memoryToIceAdapter)
26
{
27
Logging::setTag
(
"Attachments"
);
28
}
29
30
Segment::~Segment
() =
default
;
31
32
void
33
Segment::defineProperties
(
armarx::PropertyDefinitionsPtr
defs,
const
std::string& prefix)
34
{
35
defs->optional(p.coreSegmentName,
36
prefix +
"CoreSegmentName"
,
37
"Name of the object instance core segment."
);
38
defs->optional(p.maxHistorySize,
39
prefix +
"MaxHistorySize"
,
40
"Maximal size of object poses history (-1 for infinite)."
);
41
}
42
43
void
44
Segment::init
()
45
{
46
ARMARX_CHECK_NOT_NULL
(iceMemory.
workingMemory
);
47
48
coreSegment = &iceMemory.
workingMemory
->
addCoreSegment
(p.coreSegmentName,
49
arondto::Robot::ToAronType());
50
coreSegment->
setMaxHistorySize
(p.maxHistorySize);
51
}
52
53
void
54
Segment::connect
()
55
{
56
}
57
58
std::vector<armarx::armem::attachment::ObjectAttachment>
59
Segment::getAttachments
(
const
armem::Time
&
timestamp
)
const
60
{
61
ARMARX_CHECK_NOT_NULL
(coreSegment);
62
return
coreSegment->
doLocked
(
63
[
this
]()
64
{
65
std::vector<armarx::armem::attachment::ObjectAttachment> attachments;
66
coreSegment->
forEachEntity
(
67
[
this
, &attachments](
const
wm::Entity
& entity)
68
{
69
const
wm::EntityInstance
& entityInstance =
70
entity.
getLatestSnapshot
().getInstance(0);
71
72
const
auto
aronAttachment =
73
tryCast<armarx::armem::arondto::attachment::ObjectAttachment>(
74
entityInstance);
75
if
(not aronAttachment)
76
{
77
ARMARX_WARNING
78
<<
"Could not convert entity instance to 'ObjectAttachment'"
;
79
return
true
;
80
}
81
82
ARMARX_DEBUG
<<
"Key is "
<<
armem::MemoryID
(entity.
id
());
83
84
armarx::armem::attachment::ObjectAttachment
attachment;
85
fromAron
(*aronAttachment, attachment);
86
87
attachments.push_back(attachment);
88
return
true
;
89
});
90
91
return
attachments;
92
});
93
}
94
95
}
// namespace armarx::armem::server::obj::attachments
armarx::armem::server::MemoryToIceAdapter::workingMemory
server::wm::Memory * workingMemory
Definition:
MemoryToIceAdapter.h:89
armarx::armem::server::wm::detail::MaxHistorySizeParent::setMaxHistorySize
void setMaxHistorySize(long maxSize)
Sets the maximum history size of entities in this container.
Definition:
MaxHistorySize.h:41
Writer.h
armarx::armem::attachment::ObjectAttachment
ObjectAttachment describes a fixed transformation between an agent and an object.
Definition:
types.h:100
armarx::armem::wm::EntityInstance
Client-side working entity instance.
Definition:
memory_definitions.h:32
armarx::armem::server::obj::attachments::Segment::~Segment
virtual ~Segment()
armarx::armem::server::MemoryToIceAdapter
Helps connecting a Memory server to the Ice interface.
Definition:
MemoryToIceAdapter.h:19
armarx::armem::base::detail::GetLatestSnapshotMixin::getLatestSnapshot
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
Definition:
lookup_mixins.h:199
MemoryID.h
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition:
ExpressionException.h:206
armarx::armem::server::obj::attachments::Segment::Segment
Segment(server::MemoryToIceAdapter &iceMemory)
Definition:
Segment.cpp:24
query_fns.h
Segment.h
armarx::armem::server::wm::Entity
Definition:
memory_definitions.h:27
armarx::armem::base::detail::ForEachEntityMixin::forEachEntity
bool forEachEntity(FunctionT &&func)
Definition:
iteration_mixins.h:259
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition:
Logging.h:184
timestamp
std::string timestamp()
Definition:
CartographerAdapter.cpp:85
armarx::armem::server::obj::attachments::Segment::init
void init()
Definition:
Segment.cpp:44
PluginAll.h
armarx::armem::base::detail::MemoryItem::id
MemoryID & id()
Definition:
MemoryItem.h:25
armarx::armem::server::wm::CoreSegment::doLocked
auto doLocked(FunctionT &&function) const
Definition:
memory_definitions.h:110
aron_conversions.h
MemoryToIceAdapter.h
aron_conversions.h
armarx::armem::server::obj::attachments::Segment::getAttachments
std::vector< armarx::armem::attachment::ObjectAttachment > getAttachments(const armem::Time ×tamp) const
Definition:
Segment.cpp:59
armarx::core::time::DateTime
Represents a point in time.
Definition:
DateTime.h:24
armarx::armem::fromAron
void fromAron(const arondto::MemoryID &dto, MemoryID &bo)
Definition:
aron_conversions.cpp:8
armarx::armem::server::obj::attachments::Segment::defineProperties
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="")
Definition:
Segment.cpp:33
TimeUtil.h
armarx::armem::server::obj::attachments::Segment::connect
void connect()
Definition:
Segment.cpp:54
PropertyDefinitionContainer.h
IceUtil::Handle< class PropertyDefinitionContainer >
Builder.h
util.h
armarx::Logging::setTag
void setTag(const LogTag &tag)
Definition:
Logging.cpp:54
Logging.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition:
Logging.h:193
aron_conversions.h
armarx::armem::server::wm::Memory::addCoreSegment
CoreSegment & addCoreSegment(const std::string &name, Args... args)
Definition:
memory_definitions.h:151
armarx::armem::server::obj::attachments
Definition:
Segment.cpp:22
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition:
memory_ids.cpp:28
RobotAPI
libraries
armem_objects
server
attachments
Segment.cpp
Generated by
1.8.17