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

Add JSON conversions for Names

parent 263780ee
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,8 @@ set(LIBS RobotAPIInterfaces ArmarXCoreObservers ArmarXCoreStatechart ArmarXCoreE
)
set(LIB_FILES
json_conversions.cpp
PIDController.cpp
Trajectory.cpp
TrajectoryController.cpp
......@@ -62,6 +64,7 @@ set(LIB_FILES
set(LIB_HEADERS
forward_declarations.h
json_conversions.h
PIDController.h
MultiDimPIDController.h
......@@ -113,8 +116,6 @@ set(LIB_HEADERS
#diffik/NaturalDiffIK.h
#diffik/SimpleDiffIK.h
json_conversions.h
)
add_subdirectory(test)
......
#include "json_conversions.h"
#include <RobotAPI/libraries/core/FramedPose.h>
#include <RobotAPI/libraries/core/Names.h>
void
armarx::to_json(nlohmann::json& j, const FramedPose& fp)
{
j = nlohmann::json{{"agent", fp.agent},
{"frame", fp.frame},
{"qw", fp.orientation->qw},
{"qx", fp.orientation->qx},
{"qy", fp.orientation->qy},
{"qz", fp.orientation->qz},
{"x", fp.position->x},
{"y", fp.position->y},
{"z", fp.position->z}};
}
void
armarx::from_json(const nlohmann::json& j, FramedPose& fp)
{
j.at("agent").get_to(fp.agent);
j.at("frame").get_to(fp.frame);
j.at("qw").get_to(fp.orientation->qw);
j.at("qx").get_to(fp.orientation->qx);
j.at("qy").get_to(fp.orientation->qy);
j.at("qz").get_to(fp.orientation->qz);
j.at("x").get_to(fp.position->x);
j.at("y").get_to(fp.position->y);
j.at("z").get_to(fp.position->z);
}
void
armarx::to_json(simox::json::json& j, const Names& value)
{
j["recognized"] = value.recognized;
j["spoken"] = value.spoken;
}
void
armarx::from_json(const simox::json::json& j, Names& value)
{
j.at("recognized").get_to(value.recognized);
j.at("spoken").get_to(value.spoken);
}
......@@ -20,45 +20,18 @@
* GNU General Public License
*/
#pragma once
// Simox
#include <SimoxUtility/json.h>
// RobotAPI
#include <RobotAPI/libraries/core/FramedPose.h>
#include <RobotAPI/libraries/core/forward_declarations.h>
namespace armarx
{
void to_json(nlohmann::json& j, const FramedPose& fp)
{
j = nlohmann::json
{
{"agent", fp.agent},
{"frame", fp.frame},
{"qw", fp.orientation->qw},
{"qx", fp.orientation->qx},
{"qy", fp.orientation->qy},
{"qz", fp.orientation->qz},
{"x", fp.position->x},
{"y", fp.position->y},
{"z", fp.position->z}
};
}
void to_json(nlohmann::json& j, const FramedPose& fp);
void from_json(const nlohmann::json& j, FramedPose& fp);
void to_json(simox::json::json& j, const Names& value);
void from_json(const simox::json::json& j, Names& value);
void from_json(const nlohmann::json& j, FramedPose& fp)
{
j.at("agent").get_to(fp.agent);
j.at("frame").get_to(fp.frame);
j.at("qw").get_to(fp.orientation->qw);
j.at("qx").get_to(fp.orientation->qx);
j.at("qy").get_to(fp.orientation->qy);
j.at("qz").get_to(fp.orientation->qz);
j.at("x").get_to(fp.position->x);
j.at("y").get_to(fp.position->y);
j.at("z").get_to(fp.position->z);
}
}
} // namespace armarx
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