diff --git a/source/armarx/navigation/core/CMakeLists.txt b/source/armarx/navigation/core/CMakeLists.txt index c9b92d2cbff44766fc100162486d948f27968742..d4eb48836d6d48e3635a3a2e376e2057fd6fc708 100644 --- a/source/armarx/navigation/core/CMakeLists.txt +++ b/source/armarx/navigation/core/CMakeLists.txt @@ -15,6 +15,7 @@ armarx_add_library(core types.cpp Graph.cpp aron_conversions.cpp + json_conversions.cpp time/ChronoMonotonicTimeServer.cpp HEADERS types.h @@ -27,6 +28,7 @@ armarx_add_library(core Graph.h TopologicScene.h aron_conversions.h + json_conversions.h time/ChronoMonotonicTimeServer.h time/TimeServerInterface.h DEPENDENCIES diff --git a/source/armarx/navigation/core/Graph.cpp b/source/armarx/navigation/core/Graph.cpp index c7cf378a3b6e1efe2e4c292ef5cc374b7e963a82..7bdd89bab7bb09d29f2fda394d66ea4bb7f5b76a 100644 --- a/source/armarx/navigation/core/Graph.cpp +++ b/source/armarx/navigation/core/Graph.cpp @@ -31,6 +31,7 @@ #include <RobotAPI/libraries/armem/core/wm/memory_definitions.h> #include <armarx/navigation/location/aron/Location.aron.generated.h> +#include <armarx/navigation/core/json_conversions.h> namespace armarx::navigation::core @@ -80,7 +81,7 @@ namespace armarx::navigation::core ss << " cost " << edge.attrib().cost() << ", type: " << static_cast<int>(edge.attrib().strategy) << " , has traj " - << edge.attrib().trajectory.has_value() << ", aron: " << edge.attrib().aron.toJSON(); + << edge.attrib().trajectory.has_value() << ", aron: " << nlohmann::json(edge.attrib().aron); return ss.str(); } diff --git a/source/armarx/navigation/core/json_conversions.cpp b/source/armarx/navigation/core/json_conversions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..30b8a70f492e70c2730d43fab23342709d84a06a --- /dev/null +++ b/source/armarx/navigation/core/json_conversions.cpp @@ -0,0 +1,45 @@ +/** + * 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 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 + */ + +#include "json_conversions.h" + +#include <RobotAPI/libraries/aron/core/data/rw/writer/nlohmannJSON/NlohmannJSONWriter.h> +#include <RobotAPI/libraries/aron/core/data/rw/reader/nlohmannJSON/NlohmannJSONReader.h> + + +namespace armarx::navigation::core +{ + + void arondto::to_json(nlohmann::json& j, const Edge& bo) + { + armarx::aron::data::writer::NlohmannJSONWriter writer; + j = bo.write(writer); + } + + + void arondto::from_json(const nlohmann::json& j, Edge& bo) + { + armarx::aron::data::reader::NlohmannJSONReader reader; + bo.read<armarx::aron::data::reader::NlohmannJSONReader::InputType>(reader, j); + } + + +} // namespace armarx::navigation::core diff --git a/source/armarx/navigation/core/json_conversions.h b/source/armarx/navigation/core/json_conversions.h new file mode 100644 index 0000000000000000000000000000000000000000..57cee75dfdffb6640c15b49053e0f35e20f7a306 --- /dev/null +++ b/source/armarx/navigation/core/json_conversions.h @@ -0,0 +1,36 @@ +/** + * 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 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 <armarx/navigation/core/aron/Graph.aron.generated.h> + + +namespace armarx::navigation::core::arondto +{ + + void to_json(nlohmann::json& j, const arondto::Edge& bo); + void from_json(const nlohmann::json& j, arondto::Edge& bo); + + +} // namespace armarx::navigation::graph