Skip to content
Snippets Groups Projects
Commit b4c02321 authored by Fabian Reister's avatar Fabian Reister
Browse files

occupancy grid writer

parent 77f97de0
No related branches found
No related tags found
No related merge requests found
#include "Writer.h"
#include "RobotAPI/libraries/armem_vision/aron_conversions.h"
#include <RobotAPI/libraries/armem_vision/aron/OccupancyGrid.aron.generated.h>
namespace armarx::armem::vision::occupancy_grid::client
{
bool Writer::store(const OccupancyGrid& grid,
const std::string& frame,
const std::string& agentName,
const std::int64_t& timestamp)
{
std::lock_guard g{memoryWriterMutex()};
const auto result =
memoryWriter().addSegment(properties().memoryName, agentName);
if (not result.success)
{
ARMARX_ERROR << result.errorMessage;
// TODO(fabian.reister): message
return false;
}
const auto iceTimestamp = Time::microSeconds(timestamp);
const auto providerId = armem::MemoryID(result.segmentID);
const auto entityID =
providerId.withEntityName(frame).withTimestamp(iceTimestamp);
armem::EntityUpdate update;
update.entityID = entityID;
arondto::OccupancyGrid aronGrid;
// currently only sets the header
toAron(aronGrid, grid);
auto dict = aronGrid.toAron();
dict->addElement("grid", toAron(grid.grid));
update.instancesData = {dict};
update.timeCreated = iceTimestamp;
ARMARX_DEBUG << "Committing " << update << " at time " << iceTimestamp;
armem::EntityUpdateResult updateResult = memoryWriter().commit(update);
ARMARX_DEBUG << updateResult;
if (not updateResult.success)
{
ARMARX_ERROR << updateResult.errorMessage;
}
return updateResult.success;
}
std::string Writer::propertyPrefix() const { return "mem.vision."; }
armarx::armem::client::util::SimpleWriterBase::SimpleWriterBase::Properties
Writer::defaultProperties() const
{
return SimpleWriterBase::Properties{.memoryName = "Vision",
.coreSegmentName = "OccupancyGrid"};
}
} // namespace armarx::armem::vision::occupancy_grid::client
\ No newline at end of file
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::
* @author Fabian Reister ( fabian dot reister at kit dot edu )
* @date 2021
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <mutex>
#include "RobotAPI/libraries/armem/client/util/SimpleWriterBase.h"
#include "RobotAPI/libraries/armem_vision/types.h"
namespace armarx::armem::vision::occupancy_grid::client
{
/**
* @defgroup Component-ExampleClient ExampleClient
* @ingroup RobotAPI-Components
* A description of the component ExampleClient.
*
* @class ExampleClient
* @ingroup Component-ExampleClient
* @brief Brief description of class ExampleClient.
*
* Detailed description of class ExampleClient.
*/
class Writer : virtual public armarx::armem::client::util::SimpleWriterBase
{
public:
using armarx::armem::client::util::SimpleWriterBase::SimpleWriterBase;
~Writer() override;
bool store(const OccupancyGrid& grid,
const std::string& frame,
const std::string& agentName,
const std::int64_t& timestamp);
protected:
std::string propertyPrefix() const override ;
Properties defaultProperties() const override;
};
} // namespace armarx::armem::vision::occupancy_grid::client
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment