Writer.cpp
Go to the documentation of this file.
1 #include "Writer.h"
2 
3 #include <armarx/navigation/algorithms/aron/Costmap.aron.generated.h>
6 
7 
9 {
10  Writer::~Writer() = default;
11 
12  bool
14  const std::string& name,
15  const std::string& providerName,
16  const armem::Time& timestamp)
17  {
18  std::lock_guard g{writeMutex};
19 
20  const auto result = memoryWriter().addSegment(memory::constants::CostmapCoreSegmentName, providerName);
21 
22  if (not result.success)
23  {
24  ARMARX_ERROR << result.errorMessage;
25 
26  // TODO(fabian.reister): message
27  return false;
28  }
29 
30  const auto providerId = armem::MemoryID(result.segmentID);
31  const auto entityID = providerId.withEntityName(name).withTimestamp(timestamp);
32 
34  update.entityID = entityID;
35 
36  auto aronCostmap = toAron(grid);
37 
38  update.instancesData = {aronCostmap};
39  update.referencedTime = timestamp;
40 
41  ARMARX_DEBUG << "Committing " << update << " at time " << timestamp;
43 
44  ARMARX_DEBUG << updateResult;
45 
46  if (not updateResult.success)
47  {
48  ARMARX_ERROR << updateResult.errorMessage;
49  }
50 
51  return updateResult.success;
52  }
53 
54  std::string
56  {
57  return "mem.nav.costmap.";
58  }
59 
60  armarx::armem::client::util::SimpleWriterBase::SimpleWriterBase::Properties
62  {
63  return SimpleWriterBase::Properties{.memoryName = memory::constants::NavigationMemoryName,
64  .coreSegmentName =
66  }
67 
68 } // namespace armarx::navigation::memory::client::costmap
armarx::armem::client::Writer::addSegment
data::AddSegmentResult addSegment(const std::string &coreSegmentName, const std::string &providerSegmentName, bool clearWhenExists=false) const
Definition: Writer.cpp:16
armarx::navigation::memory::constants::CostmapCoreSegmentName
const std::string CostmapCoreSegmentName
Definition: constants.h:34
armarx::navigation::memory::client::costmap::Writer::store
bool store(const algorithms::Costmap &grid, const std::string &name, const std::string &providerName, const armem::Time &timestamp)
Definition: Writer.cpp:13
aron_conversions.h
armarx::armem::EntityUpdateResult
Result of an EntityUpdate.
Definition: Commit.h:72
armarx::navigation::memory::client::costmap
Definition: Reader.cpp:23
armarx::navigation::memory::constants::NavigationMemoryName
const std::string NavigationMemoryName
Definition: constants.h:27
armarx::navigation::memory::client::costmap::Writer::~Writer
~Writer() override
armarx::armem::client::util::SimpleWriterBase::memoryWriter
armem::client::Writer & memoryWriter()
Definition: SimpleWriterBase.cpp:51
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::armem::client::util::SimpleWriterBase::Properties::memoryName
std::string memoryName
Definition: SimpleWriterBase.h:51
armarx::armem::EntityUpdate
An update of an entity for a specific point in time.
Definition: Commit.h:27
armarx::navigation::memory::client::costmap::Writer::defaultProperties
Properties defaultProperties() const override
Definition: Writer.cpp:61
armarx::armem::client::Writer::commit
CommitResult commit(const Commit &commit) const
Writes a Commit to the memory.
Definition: Writer.cpp:59
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:67
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
Writer.h
armarx::navigation::memory::toAron
void toAron(arondto::Circle &dto, const Circle &bo)
Definition: aron_conversions.cpp:29
constants.h
armarx::navigation::memory::client::costmap::Writer::propertyPrefix
std::string propertyPrefix() const override
Definition: Writer.cpp:55
armarx::navigation::algorithms::Costmap
Definition: Costmap.h:13
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29