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

Add SceneSnapshot class with JSON serialization

parent 03ea4190
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,8 @@ armarx_add_library(
aron_conversions.h
aron_forward_declarations.h
SceneSnapshot.h
server/class/FloorVis.h
server/class/Segment.h
......@@ -46,6 +48,8 @@ armarx_add_library(
SOURCES
aron_conversions.cpp
SceneSnapshot.cpp
server/class/FloorVis.cpp
server/class/Segment.cpp
......
#include "SceneSnapshot.h"
#include <SimoxUtility/json.h>
namespace armarx::armem::obj
{
}
void armarx::armem::obj::to_json(nlohmann::json& j, const SceneSnapshot::Object& rhs)
{
j["class"] = rhs.classID.str();
j["collection"] = rhs.collection;
j["postion"] = rhs.postion;
j["orientation"] = rhs.orientation;
}
void armarx::armem::obj::from_json(const nlohmann::json& j, SceneSnapshot::Object& rhs)
{
rhs.classID = ObjectID(j.at("class").get<std::string>());
rhs.collection = j.at("collection");
j.at("postion").get_to(rhs.postion);
j.at("orientation").get_to(rhs.orientation);
}
void armarx::armem::obj::to_json(nlohmann::json& j, const SceneSnapshot& rhs)
{
j["objects"] = rhs.objects;
}
void armarx::armem::obj::from_json(const nlohmann::json& j, SceneSnapshot& rhs)
{
j.at("objects").get_to(rhs.objects);
}
/*
* 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::ObjectMemory
* @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
* @date 2021
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <SimoxUtility/json/json.hpp>
#include <Eigen/Geometry>
#include <RobotAPI/libraries/ArmarXObjects/ObjectID.h>
namespace armarx::armem::obj
{
struct SceneSnapshot
{
struct Object
{
ObjectID classID;
std::string collection;
Eigen::Vector3f postion = Eigen::Vector3f::Zero();
Eigen::Quaternionf orientation = Eigen::Quaternionf::Identity();
};
std::vector<Object> objects;
};
void to_json(nlohmann::json& j, const SceneSnapshot::Object& rhs);
void from_json(const nlohmann::json& j, SceneSnapshot::Object& rhs);
void to_json(nlohmann::json& j, const SceneSnapshot& rhs);
void from_json(const nlohmann::json& j, SceneSnapshot& rhs);
}
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