Skip to content
Snippets Groups Projects
Commit 84ef5e31 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Merge branch 'armem/dev' into armem/resolve-memory-link-in-gui

# Conflicts:
#	source/RobotAPI/components/armem/client/ExampleMemoryClient/ExampleMemoryClient.cpp
#	source/RobotAPI/libraries/armem/CMakeLists.txt
#	source/RobotAPI/libraries/armem/core/base/CoreSegmentBase.h
#	source/RobotAPI/libraries/armem_gui/CMakeLists.txt
#	source/RobotAPI/libraries/armem_gui/instance/sanitize_typename.cpp
parents e880df06 59b33566
No related branches found
No related tags found
No related merge requests found
Showing
with 291 additions and 117 deletions
# ARON
/source/RobotAPI/libraries/aron/ @fratty @dreher
/source/RobotAPI/interface/aron/ @fratty @dreher
/source/RobotAPI/interface/aron.ice @fratty @dreher
# ArMem
/source/RobotAPI/components/armem/ @fratty @RainerKartmann @dreher
......
# see https://github.com/intersvyaz/zerod/blob/master/cmake/modules/FindLibbson.cmake
# - Find libbson
# Find the native libbson includes and library.
# Once done this will define
#
# LIBBSON_INCLUDE_DIRS - where to find bson.h, etc.
# LIBBSON_LIBRARIES - List of libraries when using libbson.
# LIBBSON_FOUND - True if libbson found.
#
# LIBBSON_VERSION_STRING - The version of libbson found (x.y.z)
# LIBBSON_VERSION_MAJOR - The major version
# LIBBSON_VERSION_MINOR - The minor version
# LIBBSON_VERSION_MICRO - The micro version
FIND_PATH(LIBBSON_INCLUDE_DIR NAMES bson.h PATH_SUFFIXES libbson-1.0)
FIND_LIBRARY(LIBBSON_LIBRARY NAMES bson-1.0)
MARK_AS_ADVANCED(LIBBSON_LIBRARY LIBBSON_INCLUDE_DIR)
IF(LIBBSON_INCLUDE_DIR AND EXISTS "${LIBBSON_INCLUDE_DIR}/bson-version.h")
# Read and parse version header file for version number
file(READ "${LIBBSON_INCLUDE_DIR}/bson-version.h" _libbson_HEADER_CONTENTS)
IF(_libbson_HEADER_CONTENTS MATCHES ".*BSON_MAJOR_VERSION.*")
#define BSON_MAJOR_VERSION
string(REGEX REPLACE ".*#define +BSON_MAJOR_VERSION +\\(([0-9]+)\\).*" "\\1" LIBBSON_VERSION_MAJOR "${_libbson_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define +BSON_MINOR_VERSION +\\(([0-9]+)\\).*" "\\1" LIBBSON_VERSION_MINOR "${_libbson_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define +BSON_MICRO_VERSION +\\(([0-9]+)\\).*" "\\1" LIBBSON_VERSION_MICRO "${_libbson_HEADER_CONTENTS}")
ELSE()
SET(LIBBSON_VERSION_MAJOR 0)
SET(LIBBSON_VERSION_MINOR 0)
SET(LIBBSON_VERSION_MICRO 0)
ENDIF()
SET(LIBBSON_VERSION_STRING "${LIBBSON_VERSION_MAJOR}.${LIBBSON_VERSION_MINOR}.${LIBBSON_VERSION_MICRO}")
ENDIF()
# handle the QUIETLY and REQUIRED arguments and set LIBBSON_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libbson-1.0
REQUIRED_VARS LIBBSON_LIBRARY LIBBSON_INCLUDE_DIR
VERSION_VAR LIBBSON_VERSION_STRING
)
IF(LIBBSON_FOUND)
SET(LIBBSON_INCLUDE_DIRS ${LIBBSON_INCLUDE_DIR})
SET(LIBBSON_LIBRARIES ${LIBBSON_LIBRARY})
ENDIF()
# see https://github.com/intersvyaz/freeradius-mongodb/blob/master/cmake/modules/FindLibmongoc.cmake
# - Find libmongoc
# Find the native libmongoc includes and library.
# Once done this will define
#
# LIBMONGOC_INCLUDE_DIRS - where to find mongoc.h, etc.
# LIBMONGOC_LIBRARIES - List of libraries when using libmongoc.
# LIBMONGOC_FOUND - True if libmongoc found.
#
# LIBMONGOC_VERSION_STRING - The version of libmongoc found (x.y.z)
# LIBMONGOC_VERSION_MAJOR - The major version
# LIBMONGOC_VERSION_MINOR - The minor version
# LIBMONGOC_VERSION_MICRO - The micro version
FIND_PATH(LIBMONGOC_INCLUDE_DIR NAMES mongoc.h PATH_SUFFIXES libmongoc-1.0)
FIND_LIBRARY(LIBMONGOC_LIBRARY NAMES mongoc-1.0)
MARK_AS_ADVANCED(LIBMONGOC_LIBRARY LIBMONGOC_INCLUDE_DIR)
IF(LIBMONGOC_INCLUDE_DIR AND EXISTS "${LIBMONGOC_INCLUDE_DIR}/mongoc-version.h")
# Read and parse version header file for version number
file(READ "${LIBMONGOC_INCLUDE_DIR}/mongoc-version.h" _libmongoc_HEADER_CONTENTS)
IF(_libmongoc_HEADER_CONTENTS MATCHES ".*MONGOC_MAJOR_VERSION.*")
string(REGEX REPLACE ".*#define +MONGOC_MAJOR_VERSION +\\(([0-9]+)\\).*" "\\1" LIBMONGOC_VERSION_MAJOR "${_libmongoc_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define +MONGOC_MINOR_VERSION +\\(([0-9]+)\\).*" "\\1" LIBMONGOC_VERSION_MINOR "${_libmongoc_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define +MONGOC_MICRO_VERSION +\\(([0-9]+)\\).*" "\\1" LIBMONGOC_VERSION_MICRO "${_libmongoc_HEADER_CONTENTS}")
ELSE()
SET(LIBMONGOC_VERSION_MAJOR 0)
SET(LIBMONGOC_VERSION_MINOR 0)
SET(LIBMONGOC_VERSION_MICRO 0)
ENDIF()
SET(LIBMONGOC_VERSION_STRING "${LIBMONGOC_VERSION_MAJOR}.${LIBMONGOC_VERSION_MINOR}.${LIBMONGOC_VERSION_MICRO}")
ENDIF()
# handle the QUIETLY and REQUIRED arguments and set LIBMONGOC_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libmongoc
REQUIRED_VARS LIBMONGOC_LIBRARY LIBMONGOC_INCLUDE_DIR
VERSION_VAR LIBMONGOC_VERSION_STRING
)
IF(LIBMONGOC_FOUND)
SET(LIBMONGOC_INCLUDE_DIRS ${LIBMONGOC_INCLUDE_DIR})
SET(LIBMONGOC_LIBRARIES ${LIBMONGOC_LIBRARY})
ENDIF()
#!/bin/bash
# By Fabian Peller 2021-06-10;
if [ "$#" -ne 1 ]; then
echo "Usage: $0 CLONE-DIRECTORY" >&2
exit 1
fi
extractDir="$1"
sourceDir="$extractDir/mongo-cxx-driver-r3.2.1"
installDir="$extractDir/mongo-cxx-driver-r3.2.1/build/install"
scriptDir="$(readlink -f "$(dirname "$0")")"
pwd="$(pwd)"
# You first have to install libbson-dev and libmongoc-dev (not necessary on the lab pcs)
#sudo apt install libbson-dev libmongoc-dev
# Then you have to update the symlinks (not necessary on the lab pcs)
# Update the symlinks because the default mongoc bson cmake configs are shitty
#sudo ln -s /usr/include/libbson-1.0/ /usr/lib/include/libbson-1.0
#sudo ln -s /usr/include/libbson-1.0/ /usr/lib/include/libbson-1.0
#sudo ln -s /usr/include/libmongoc-1.0/ /usr/lib/include/libmongoc-1.0
#sudo ln -s /usr/lib /usr/lib/lib
# Then you can build the mongocxx driver
mkdir $extractDir &> /dev/null || true
tar -xvf mongo-cxx-driver-r3.2.1.tar.gz -C $extractDir
cd $sourceDir
mkdir build &> /dev/null || true
cd build
cmake ..
cmake .. -DBSON_LIBRARY="/usr/lib/x86_64-linux-gnu/libbson-1.0.so" -DMONGOC_LIBRARY="/usr/lib/x86_64-linux-gnu/libmongoc-1.0.so" -DCMAKE_INSTALL_PREFIX="$installDir"
# install to $extractDir/build/install
make -j`nproc`
make install
# Finally, tell RobotAPI where to find mongocxx
echo "You need to cmake RobotAPI now with: cmake -DCMAKE_PREFIX_PATH=$installDir .."
#armarx-dev exec --no-deps RobotAPI "cd build && cmake -DCMAKE_PREFIX_PATH=$installDir ."
File added
......@@ -144,7 +144,7 @@ int main(int argc, char* argv[])
}
}
cppcodegenerator::Writer writer("AronTestSegment", reader.getCodeIncludes());
cppserializer::Writer writer("AronTestSegment", reader.getCodeIncludes());
if (verbose)
{
......
......@@ -392,6 +392,7 @@ namespace armarx
toAron(data.memoryLink, armem::MemoryID());
{
data.the_ivt_image = std::make_shared<CByteImage>();
CByteImage& image = *data.the_ivt_image;
image.Set(20, 10, CByteImage::ImageType::eRGB24);
simox::ColorMap cmap = simox::color::cmaps::plasma();
......
......@@ -61,9 +61,10 @@ namespace armarx
void ExampleMemory::onInitComponent()
{
workingMemory.name() = p.memoryName;
longtermMemory.name() = p.memoryName;
// Usually, the memory server will specify a number of core segments with a specific aron type.
workingMemory.addCoreSegment("ExampleData", armem::example::ExampleData::toInitialAronType());
workingMemory.addCoreSegment("ExampleData", armem::example::ExampleData::toAronType());
// For illustration purposes, we add more segments (without types).
bool trim = true;
......
......@@ -41,7 +41,7 @@
<EigenMatrix rows="4" cols="4" type="float" />
</ObjectChild>
<ObjectChild key='the_ivt_image'>
<IVTCByteImage type="GrayScale" />
<IVTCByteImage type="GrayScale" shared_ptr="true"/>
</ObjectChild>
<ObjectChild key='the_float_list'>
......
......@@ -39,7 +39,7 @@ namespace armem = armarx::armem;
BOOST_AUTO_TEST_CASE(test_ExampleData_type)
{
armarx::aron::typenavigator::ObjectNavigatorPtr type = ExampleData::toInitialAronType();
armarx::aron::typenavigator::ObjectNavigatorPtr type = ExampleData::toAronType();
BOOST_CHECK_EQUAL(type->childrenSize(), 15);
......
......@@ -49,7 +49,6 @@
#include <RobotAPI/libraries/armem_robot_state/aron/Transform.aron.generated.h>
#include <RobotAPI/libraries/core/FramedPose.h>
#include <RobotAPI/libraries/armem/core/Time.h>
#include <RobotAPI/libraries/aron/core/navigator/data/primitive/Primitive.h>
#include <RobotAPI/libraries/core/Pose.h>
namespace armarx::armem::server::robot_state
......
......@@ -70,8 +70,8 @@ namespace armarx
workingMemory.name() = p.memoryName;
{
armarx::armem::wm::CoreSegment& c = workingMemory.addCoreSegment(p.statechartCoreSegmentName, armarx::armem::arondto::Statechart::Transition::toInitialAronType());
c.addProviderSegment("Transitions", armarx::armem::arondto::Statechart::Transition::toInitialAronType());
armarx::armem::wm::CoreSegment& c = workingMemory.addCoreSegment(p.statechartCoreSegmentName, armarx::armem::arondto::Statechart::Transition::toAronType());
c.addProviderSegment("Transitions", armarx::armem::arondto::Statechart::Transition::toAronType());
}
}
......
......@@ -24,11 +24,16 @@
RUN_ARON_MACRO(String, string, STRING) \
RUN_ARON_MACRO(Bool, bool, BOOL)
#define ARON_VERSION "beta 0.2.2"
module armarx
{
module aron
{
const string VERSION = ARON_VERSION;
/*************************
* General Definitions ***
************************/
......@@ -43,23 +48,36 @@ module armarx
************************/
module type
{
class AronType { };
enum Maybe
{
eNone,
eOptional,
eRawPointer,
eUniquePointer,
eSharedPointer
};
class AronType {
//string VERSION = ARON_VERSION;
Maybe maybe = Maybe::eNone; // Every type can have a maye type flag or not
}
sequence<AronType> AronTypeList;
dictionary<string, AronType> AronTypeDict;
// Container types
class AronList extends AronType { AronType acceptedType; };
class AronTuple extends AronType { AronTypeList elementTypes; };
class AronPair extends AronType { AronType acceptedType1; AronType acceptedType2; };
class AronObject extends AronType { AronObject parent; string objectName; AronTypeDict elementTypes; };
class AronDict extends AronType { AronType acceptedType; };
class AronList extends AronType { AronType acceptedType; }
class AronTuple extends AronType { AronTypeList elementTypes; }
class AronPair extends AronType { AronType acceptedType1; AronType acceptedType2; }
class AronObject extends AronType { AronObject parent; string objectName; AronTypeDict elementTypes; }
class AronDict extends AronType { AronType acceptedType; }
// Complex Types (serialize to ndarray)
class AronEigenMatrix extends AronType { AronIntSequence dimensions; string typeName; };
class AronNDArray extends AronType { AronIntSequence dimensions; int elementSize; string typeName; }
class AronEigenMatrix extends AronType { int rows; int cols; string typeName; }
class AronEigenQuaternion extends AronType { string typeName; }
class AronIVTCByteImage extends AronType { int width; int height; string typeName; }
class AronOpenCVMat extends AronType { AronIntSequence dimensions; string typeName; }
class AronPCLPointCloud extends AronType { int width; int height; string typeName; }
class AronIVTCByteImage extends AronType { }
class AronOpenCVMat extends AronType { }
class AronPCLPointCloud extends AronType { string typeName; }
class AronPosition extends AronType { }
class AronOrientation extends AronType { }
class AronPose extends AronType { }
......@@ -81,7 +99,9 @@ module armarx
************************/
module data
{
class AronData { };
class AronData {
//string VERSION = ARON_VERSION;
};
sequence<AronData> AronDataList;
dictionary<string, AronData> AronDataDict;
......
......@@ -80,7 +80,7 @@ void armarx::objpose::fromAron(const arondto::ObjectPose& dto, ObjectPose& bo)
bo.confidence = dto.confidence;
bo.timestamp = IceUtil::Time::microSeconds(dto.timestamp);
bo.timestamp = dto.timestamp;
if (dto.localOOBBValid)
{
......@@ -122,7 +122,7 @@ void armarx::objpose::toAron(arondto::ObjectPose& dto, const ObjectPose& bo)
dto.confidence = bo.confidence;
dto.timestamp = bo.timestamp.toMicroSeconds();
dto.timestamp = bo.timestamp;
if (bo.localOOBB)
{
......
......@@ -3,6 +3,18 @@ set(LIB_NAME armem)
armarx_component_set_name("${LIB_NAME}")
armarx_set_target("Library: ${LIB_NAME}")
find_package(libmongocxx QUIET)
armarx_build_if(libmongocxx_FOUND "libmongocxx not available. Please use the installation script in RobotAPI/etc/mongocxx to install libmongocxx and libbsoncxx.")
find_package(libbsoncxx QUIET)
armarx_build_if(libbsoncxx_FOUND "libbsoncxx not available. Please use the installation script in RobotAPI/etc/mongocxx to install libmongocxx and libbsoncxx.")
#message("LIBMONGOCXX:")
#message("${LIBMONGOCXX_FOUND}")
#message("${LIBMONGOCXX_INCLUDE_DIRS}")
#message("${LIBMONGOCXX_LIBRARIES}")
set(LIBS
ArmarXCoreInterfaces ArmarXCore
RemoteGui
......@@ -41,6 +53,8 @@ set(LIB_FILES
core/workingmemory/Memory.cpp
core/workingmemory/ProviderSegment.cpp
core/workingmemory/ice_conversions.cpp
core/workingmemory/json_conversions.cpp
core/workingmemory/entityInstance_conversions.cpp
core/workingmemory/visitor/Visitor.cpp
core/workingmemory/visitor/FunctionalVisitor.cpp
......@@ -50,6 +64,7 @@ set(LIB_FILES
core/longtermmemory/EntitySnapshot.cpp
core/longtermmemory/Memory.cpp
core/longtermmemory/ProviderSegment.cpp
core/longtermmemory/mongodb/MongoDBConnectionManager.cpp
core/diskmemory/TypeIO.cpp
core/diskmemory/CoreSegment.cpp
......@@ -139,6 +154,8 @@ set(LIB_HEADERS
core/workingmemory/Memory.h
core/workingmemory/ProviderSegment.h
core/workingmemory/ice_conversions.h
core/workingmemory/json_conversions.h
core/workingmemory/entityInstance_conversions.h
core/workingmemory/visitor.h
core/workingmemory/visitor/Visitor.h
core/workingmemory/visitor/FunctionalVisitor.h
......@@ -212,19 +229,32 @@ set(LIB_HEADERS
)
armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}")
armarx_enable_aron_file_generation_for_target(
TARGET_NAME
${LIB_NAME}
armarx_add_library(
LIB_NAME
"${LIB_NAME}"
SOURCES
"${LIB_FILES}"
HEADERS
"${LIB_HEADERS}"
LIBS
"${LIBS}"
ARON_FILES
aron/MemoryID.xml
)
)
#armarx_enable_aron_file_generation_for_target(
# TARGET_NAME
# ${LIB_NAME}
# ARON_FILES
# aron/MemoryID.xml
#)
add_library(RobotAPI::armem ALIAS "${LIB_NAME}")
target_include_directories("${LIB_NAME}" PUBLIC ${LIBMONGOCXX_INCLUDE_DIRS})
target_include_directories("${LIB_NAME}" PUBLIC ${LIBBSONCXX_INCLUDE_DIRS})
# add unit tests
add_subdirectory(test)
......@@ -7,7 +7,7 @@ void armarx::armem::fromAron(const arondto::MemoryID& dto, MemoryID& bo)
bo.coreSegmentName = dto.coreSegmentName;
bo.providerSegmentName = dto.providerSegmentName;
bo.entityName = dto.entityName;
bo.timestamp = IceUtil::Time::microSeconds(dto.timestamp);
bo.timestamp = dto.timestamp;
bo.instanceIndex = dto.instanceIndex;
}
......@@ -17,7 +17,7 @@ void armarx::armem::toAron(arondto::MemoryID& dto, const MemoryID& bo)
dto.coreSegmentName = bo.coreSegmentName;
dto.providerSegmentName = bo.providerSegmentName;
dto.entityName = bo.entityName;
dto.timestamp = bo.timestamp.toMicroSeconds();
dto.timestamp = bo.timestamp;
dto.instanceIndex = bo.instanceIndex;
}
......
......@@ -4,12 +4,9 @@
#include <fstream>
#include "../../core/error.h"
#include "ArmarXCore/core/exceptions/LocalException.h"
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
#include <RobotAPI/libraries/aron/core/io/dataIO/converter/Converter.h>
#include <RobotAPI/libraries/aron/core/io/dataIO/visitor/Visitor.h>
#include <RobotAPI/libraries/aron/core/io/dataIO/reader/nlohmannJSON/NlohmannJSONReader.h>
#include <RobotAPI/libraries/aron/core/io/dataIO/writer/nlohmannJSON/NlohmannJSONWriter.h>
namespace armarx::armem::d_ltm
{
......@@ -69,13 +66,13 @@ namespace armarx::armem::d_ltm
{
std::ifstream ifs(d);
std::string file_content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
aron::dataIO::reader::NlohmannJSONReader dataReader(file_content);
aron::dataIO::writer::NavigatorWriter navWriter;
aron::dataIO::Converter::ReadAndConvert(dataReader, navWriter, expectedStructure);
aron::datanavigator::DictNavigatorPtr aron = aron::datanavigator::DictNavigator::DynamicCastAndCheck(navWriter.getResult());
return unwrapData(aron);
nlohmann::json j(file_content);
auto aron = std::make_shared<aron::datanavigator::DictNavigator>();
to_aron(aron, j, expectedStructure);
wm::EntityInstance e(id());
from_aron(aron, e);
return e;
}
else
{
......@@ -103,7 +100,16 @@ namespace armarx::armem::d_ltm
void EntityInstance::setTo(const wm::EntityInstance& m)
{
std::filesystem::path p = _fullPath();
std::filesystem::create_directories(p);
try
{
std::filesystem::create_directories(p);
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
return;
}
std::filesystem::path d = p / (std::string(DATA_FILENAME) + ".json");
......@@ -115,71 +121,12 @@ namespace armarx::armem::d_ltm
std::ofstream ofs;
ofs.open(d);
aron::datanavigator::DictNavigatorPtr aron = wrapData(m);
aron::dataIO::writer::NlohmannJSONWriter dataWriter;
aron::dataIO::Visitor::VisitAndSetup(dataWriter, aron);
std::string new_file_full_content = dataWriter.getResult().dump(2);
auto aron = std::make_shared<aron::datanavigator::DictNavigator>();
to_aron(aron, m);
nlohmann::json j;
from_aron(aron, j);
ofs << new_file_full_content;
ofs << j.dump(2);
ofs.close();
}
wm::EntityInstance EntityInstance::unwrapData(const aron::datanavigator::DictNavigatorPtr& dataWrapped) const
{
wm::EntityInstance e(id());
wm::EntityInstanceMetadata& metadata = e.metadata();
if (dataWrapped->hasElement(DATA_WRAPPER_DATA_FIELD))
{
aron::datanavigator::DictNavigatorPtr data = aron::datanavigator::DictNavigator::DynamicCastAndCheck(dataWrapped->getElement(DATA_WRAPPER_DATA_FIELD));
e.setData(data);
}
auto timeCreated = aron::datanavigator::LongNavigator::DynamicCastAndCheck(dataWrapped->getElement(DATA_WRAPPER_TIME_CREATED_FIELD));
metadata.timeCreated = Time::microSeconds(timeCreated->toAronLongPtr()->value);
auto timeSent = aron::datanavigator::LongNavigator::DynamicCastAndCheck(dataWrapped->getElement(DATA_WRAPPER_TIME_SENT_FIELD));
metadata.timeSent = Time::microSeconds(timeSent->toAronLongPtr()->value);
auto timeArrived = aron::datanavigator::LongNavigator::DynamicCastAndCheck(dataWrapped->getElement(DATA_WRAPPER_TIME_ARRIVED_FIELD));
metadata.timeArrived = Time::microSeconds(timeArrived->toAronLongPtr()->value);
auto confidence = aron::datanavigator::DoubleNavigator::DynamicCastAndCheck(dataWrapped->getElement(DATA_WRAPPER_CONFIDENCE_FIELD));
metadata.confidence = static_cast<float>(confidence->toAronDoublePtr()->value);
return e;
}
aron::datanavigator::DictNavigatorPtr EntityInstance::wrapData(const wm::EntityInstance& e) const
{
auto dataWrapped = std::make_shared<aron::datanavigator::DictNavigator>();
if (e.data())
{
dataWrapped->addElement(DATA_WRAPPER_DATA_FIELD, e.data());
}
auto timeWrapped = std::make_shared<aron::datanavigator::LongNavigator>();
timeWrapped->setValue(Time::now().toMicroSeconds());
dataWrapped->addElement(DATA_WRAPPER_TIME_STORED_FIELD, timeWrapped);
const wm::EntityInstanceMetadata& metadata = e.metadata();
auto timeCreated = std::make_shared<aron::datanavigator::LongNavigator>();
timeCreated->setValue(metadata.timeCreated.toMicroSeconds());
dataWrapped->addElement(DATA_WRAPPER_TIME_CREATED_FIELD, timeCreated);
auto timeSent = std::make_shared<aron::datanavigator::LongNavigator>();
timeSent->setValue(metadata.timeSent.toMicroSeconds());
dataWrapped->addElement(DATA_WRAPPER_TIME_SENT_FIELD, timeSent);
auto timeArrived = std::make_shared<aron::datanavigator::LongNavigator>();
timeArrived->setValue(metadata.timeArrived.toMicroSeconds());
dataWrapped->addElement(DATA_WRAPPER_TIME_ARRIVED_FIELD, timeArrived);
auto confidence = std::make_shared<aron::datanavigator::DoubleNavigator>();
confidence->setValue(static_cast<double>(metadata.confidence));
dataWrapped->addElement(DATA_WRAPPER_CONFIDENCE_FIELD, confidence);
return dataWrapped;
}
}
......@@ -5,6 +5,9 @@
#include "../base/EntityInstanceBase.h"
#include "../workingmemory/EntityInstance.h"
#include "../workingmemory/entityInstance_conversions.h"
#include "../workingmemory/json_conversions.h"
namespace armarx::armem::d_ltm
{
......@@ -51,19 +54,10 @@ namespace armarx::armem::d_ltm
std::filesystem::path _fullPath() const;
std::filesystem::path _fullPath(const std::filesystem::path&) const;
wm::EntityInstance unwrapData(const aron::datanavigator::DictNavigatorPtr&) const;
aron::datanavigator::DictNavigatorPtr wrapData(const wm::EntityInstance&) const;
public:
std::shared_ptr<std::filesystem::path> path;
private:
static const constexpr char* DATA_FILENAME = "data";
static constexpr const char* DATA_WRAPPER_DATA_FIELD = "__ARON_DATA";
static constexpr const char* DATA_WRAPPER_TIME_STORED_FIELD = "__WRITER_METADATA__TIME_STORED";
static constexpr const char* DATA_WRAPPER_TIME_CREATED_FIELD = "__ENTITY_METADATA__TIME_CREATED";
static constexpr const char* DATA_WRAPPER_TIME_SENT_FIELD = "__ENTITY_METADATA__TIME_SENT";
static constexpr const char* DATA_WRAPPER_TIME_ARRIVED_FIELD = "__ENTITY_METADATA__TIME_ARRIVED";
static constexpr const char* DATA_WRAPPER_CONFIDENCE_FIELD = "__ENTITY_METADATA__CONFIDENCE";
};
}
......@@ -69,7 +69,15 @@ namespace armarx::armem::d_ltm
void EntitySnapshot::setTo(const wm::EntitySnapshot& m)
{
std::filesystem::create_directories(_fullPath());
try
{
std::filesystem::create_directories(_fullPath());
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
return;
}
// We remove the contente here and reset it with new values
_container.clear();
......@@ -77,7 +85,15 @@ namespace armarx::armem::d_ltm
int i = 0;
for (const auto& s : m.instances())
{
std::filesystem::create_directory(_fullPath() / std::to_string(i));
try
{
std::filesystem::create_directory(_fullPath() / std::to_string(i));
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
continue;;
}
auto wms = _container.emplace_back(id().withInstanceIndex(i++));
wms.path = path;
......
......@@ -81,7 +81,18 @@ namespace armarx::armem::d_ltm
void ProviderSegment::append(const wm::ProviderSegment& m)
{
std::filesystem::create_directories(_fullPath());
try
{
std::filesystem::create_directories(_fullPath());
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
return;
}
TypeIO::writeAronType(_aronType, _fullPath());
for (const auto& [k, s] : m.container())
......@@ -92,7 +103,19 @@ namespace armarx::armem::d_ltm
}
else
{
std::filesystem::create_directory(_fullPath() / k);
try
{
std::filesystem::create_directory(_fullPath() / k);
continue;
}
catch (...)
{
ARMARX_WARNING << GetHandledExceptionString();
return;
}
auto wms = _container.emplace(std::make_pair(k, id().withEntityName(k)));
wms.first->second.path = path;
wms.first->second.append(s);
......
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