Writer.cpp
Go to the documentation of this file.
1#include "Writer.h"
2
3#include <mutex>
4#include <string>
5
7
12
16
18{
19 Writer::~Writer() = default;
20
21 bool
23 const std::string& name,
24 const std::string& providerName,
26 {
27 std::lock_guard g{writeMutex};
28
29 const auto result =
31
32 if (not result.success)
33 {
34 ARMARX_ERROR << result.errorMessage;
35
36 // TODO(fabian.reister): message
37 return false;
38 }
39
40 const auto providerId = armem::MemoryID(result.segmentID);
41 const auto entityID = providerId.withEntityName(name).withTimestamp(timestamp);
42
44 update.entityID = entityID;
45
46 auto aronCostmap3D = algorithms::toAron(grid);
47
48 update.instancesData = {aronCostmap3D};
49 update.referencedTime = timestamp;
50
51 ARMARX_DEBUG << "Committing " << update << " at time " << timestamp;
52 armem::EntityUpdateResult updateResult = memoryWriter().commit(update);
53
54 ARMARX_DEBUG << updateResult;
55
56 if (not updateResult.success)
57 {
58 ARMARX_ERROR << updateResult.errorMessage;
59 }
60
61 return updateResult.success;
62 }
63
64 std::string
66 {
67 return "mem.nav.costmap3d.";
68 }
69
70 armarx::armem::client::util::SimpleWriterBase::SimpleWriterBase::Properties
72 {
73 return SimpleWriterBase::Properties{.memoryName = memory::constants::NavigationMemoryName,
74 .coreSegmentName =
76 }
77
78} // namespace armarx::navigation::memory::client::costmap3d
std::string timestamp()
data::AddSegmentResult addSegment(const std::string &coreSegmentName, const std::string &providerSegmentName, bool clearWhenExists=false) const
Definition Writer.cpp:25
CommitResult commit(const Commit &commit) const
Writes a Commit to the memory.
Definition Writer.cpp:68
bool store(const algorithms::orientation_aware::Costmap3D &grid, const std::string &name, const std::string &providerName, const armem::Time &timestamp)
Definition Writer.cpp:22
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
Definition Logging.h:184
armarx::core::time::DateTime Time
armarx::aron::data::DictPtr toAron(const Costmap &bo)
constexpr const char * Costmap3DCoreSegmentName
Definition constants.h:37
constexpr const char * NavigationMemoryName
Definition constants.h:29
Result of an EntityUpdate.
Definition Commit.h:75
An update of an entity for a specific point in time.
Definition Commit.h:26