Skip to content
Snippets Groups Projects
Commit 9201e171 authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

copy ltm iterator function, added ltm vector representation converter

parent 5c645cfe
No related branches found
No related tags found
1 merge request!321Merge of all branches of Fabian PK (related to skills)
......@@ -59,11 +59,11 @@ namespace armarx::armem::server::ltm
}
/// iterate over all entity snapshots of this ltm
virtual bool forEachSnapshot(std::function<void(EntitySnapshotT&)>&& func) const = 0;
virtual bool forEachSnapshotInIndexRange(long first, long last, std::function<void(EntitySnapshotT&)>&& func) const = 0;
virtual bool forEachSnapshotInTimeRange(const Time& min, const Time& max, std::function<void(EntitySnapshotT&)>&& func) const = 0;
virtual bool forEachSnapshotBeforeOrAt(const Time& time, std::function<void(EntitySnapshotT&)>&& func) const = 0;
virtual bool forEachSnapshotBefore(const Time& time, std::function<void(EntitySnapshotT&)>&& func) const = 0;
virtual bool forEachSnapshot(std::function<void(EntitySnapshotT&)> func) const = 0;
virtual bool forEachSnapshotInIndexRange(long first, long last, std::function<void(EntitySnapshotT&)> func) const = 0;
virtual bool forEachSnapshotInTimeRange(const Time& min, const Time& max, std::function<void(EntitySnapshotT&)> func) const = 0;
virtual bool forEachSnapshotBeforeOrAt(const Time& time, std::function<void(EntitySnapshotT&)> func) const = 0;
virtual bool forEachSnapshotBefore(const Time& time, std::function<void(EntitySnapshotT&)> func) const = 0;
/// find entity snapshot segment
virtual std::shared_ptr<EntitySnapshotT> findSnapshot(const Time&) const = 0;
......
......@@ -126,7 +126,7 @@ namespace armarx::armem::server::ltm
virtual bool forEachCoreSegment(std::function<void(CoreSegmentT&)>&& func) const = 0;
/// find core segment
virtual std::shared_ptr<CoreSegmentT> findCoreSegment(const std::string&) const = 0;
virtual std::shared_ptr<CoreSegmentT> findCoreSegment(const std::string&) const = 0; // TODO make unique!!
/// default parameters. Implementation should use the configuration to configure
virtual void createPropertyDefinitions(PropertyDefinitionsPtr& defs, const std::string& prefix)
......
......@@ -21,7 +21,7 @@ namespace armarx::armem::server::ltm::disk
{
}
bool Entity::forEachSnapshot(std::function<void(EntitySnapshot&)>&& func) const
bool Entity::forEachSnapshot(std::function<void(EntitySnapshot&)> func) const
{
auto mPath = getMemoryBasePathForMode(currentMode, currentExport);
auto relPath = getRelativePathForMode(currentMode);
......@@ -75,7 +75,7 @@ namespace armarx::armem::server::ltm::disk
return true;
}
bool Entity::forEachSnapshotInIndexRange(long first, long last, std::function<void(EntitySnapshot&)>&& func) const
bool Entity::forEachSnapshotInIndexRange(long first, long last, std::function<void(EntitySnapshot&)> func) const
{
ARMARX_WARNING << "PLEASE NOTE THAT QUERYING THE LTM INDEX WISE MAY BE BUGGY BECAUSE THE FILESYSTEM ITERATOR IS UNSORTED!";
......@@ -106,7 +106,7 @@ namespace armarx::armem::server::ltm::disk
return forEachSnapshot(std::move(f));
}
bool Entity::forEachSnapshotInTimeRange(const Time& min, const Time& max, std::function<void(EntitySnapshot&)>&& func) const
bool Entity::forEachSnapshotInTimeRange(const Time& min, const Time& max, std::function<void(EntitySnapshot&)> func) const
{
auto f = [&](EntitySnapshot& e)
{
......@@ -120,7 +120,7 @@ namespace armarx::armem::server::ltm::disk
return forEachSnapshot(std::move(f));
}
bool Entity::forEachSnapshotBeforeOrAt(const Time& time, std::function<void(EntitySnapshot&)>&& func) const
bool Entity::forEachSnapshotBeforeOrAt(const Time& time, std::function<void(EntitySnapshot&)> func) const
{
auto f = [&](EntitySnapshot& e)
{
......@@ -134,7 +134,7 @@ namespace armarx::armem::server::ltm::disk
return forEachSnapshot(std::move(f));
}
bool Entity::forEachSnapshotBefore(const Time& time, std::function<void(EntitySnapshot&)>&& func) const
bool Entity::forEachSnapshotBefore(const Time& time, std::function<void(EntitySnapshot&)> func) const
{
auto f = [&](EntitySnapshot& e)
{
......
......@@ -18,11 +18,11 @@ namespace armarx::armem::server::ltm::disk
public:
Entity(const std::filesystem::path& parentPath, const MemoryID& id, const std::shared_ptr<Processors>& p, const DiskMemoryItem::MemoryEncodingMode mode, const unsigned long e);
bool forEachSnapshot(std::function<void(EntitySnapshot&)>&& func) const override;
bool forEachSnapshotInIndexRange(long first, long last, std::function<void(EntitySnapshot&)>&& func) const override;
bool forEachSnapshotInTimeRange(const Time& min, const Time& max, std::function<void(EntitySnapshot&)>&& func) const override;
bool forEachSnapshotBeforeOrAt(const Time& time, std::function<void(EntitySnapshot&)>&& func) const override;
bool forEachSnapshotBefore(const Time& time, std::function<void(EntitySnapshot&)>&& func) const override;
bool forEachSnapshot(std::function<void(EntitySnapshot&)> func) const override;
bool forEachSnapshotInIndexRange(long first, long last, std::function<void(EntitySnapshot&)> func) const override;
bool forEachSnapshotInTimeRange(const Time& min, const Time& max, std::function<void(EntitySnapshot&)> func) const override;
bool forEachSnapshotBeforeOrAt(const Time& time, std::function<void(EntitySnapshot&)> func) const override;
bool forEachSnapshotBefore(const Time& time, std::function<void(EntitySnapshot&)> func) const override;
std::shared_ptr<EntitySnapshot> findSnapshot(const Time&) const override;
std::shared_ptr<EntitySnapshot> findLatestSnapshot() const override;
......
set(LIB_NAME aronivtconverter)
armarx_component_set_name("${LIB_NAME}")
armarx_set_target("Library: ${LIB_NAME}")
armarx_build_if(IVT_FOUND "IVT not available")
armarx_build_if(OpenCV_FOUND "OpenCV not available")
set(LIBS
aron
ivt
ivtopencv
${IVT_LIBRARIES}
)
set(LIB_FILES
IVTConverter.cpp
)
set(LIB_HEADERS
IVTConverter.h
)
armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}")
if(IVT_FOUND)
target_include_directories(aronivtconverter
SYSTEM PUBLIC
${IVT_INCLUDE_DIRS}
)
endif()
add_library(RobotAPI::aron::converter::ivt ALIAS aronivtconverter)
/*
* This file is part of ArmarX.
*
* Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
* Karlsruhe Institute of Technology (KIT), all rights reserved.
*
* 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/>.
*
* @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu)
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
// STD/STL
#include <numeric>
// Header
#include "IVTConverter.h"
namespace armarx::aron::converter
{
std::shared_ptr<CByteImage> AronIVTConverter::ConvertToCByteImage(const data::NDArrayPtr& nav)
{
ARMARX_CHECK_NOT_NULL(nav);
if (nav->getShape().size() != 3) // +1 for bytes per pixel
{
throw error::AronException(__PRETTY_FUNCTION__, "The size of an NDArray does not match.", nav->getPath());
}
auto dims = nav->getShape();
auto ret = std::make_shared<CByteImage>();
ret->Set(dims[0], dims[1], static_cast<CByteImage::ImageType>(std::stoi(nav->getType())));
memcpy(reinterpret_cast<unsigned char*>(ret->pixels), nav->getData(), std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>()));
return ret;
}
data::NDArrayPtr ConvertFromCByteImage(const std::shared_ptr<CByteImage>& img)
{
// TODO:
return nullptr;
}
}
/*
* 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/>.
*
* @author Fabian Peller (fabian dot peller at kit dot edu)
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
// STD/STL
#include <memory>
#include <string>
// IVT
#include <Image/ByteImage.h>
// ArmarX
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
#include <RobotAPI/interface/aron.h>
#include <RobotAPI/libraries/aron/core/data/variant/complex/NDArray.h>
namespace armarx::aron::converter
{
class AronIVTConverter
{
AronIVTConverter() = delete;
public:
static std::shared_ptr<CByteImage> ConvertToCByteImage(const data::NDArrayPtr&);
static data::NDArrayPtr ConvertFromCByteImage(const std::shared_ptr<CByteImage>&);
};
}
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