json_conversions.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Roboception GmbH
3  *
4  * Author: Elena Gambaro
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * 3. Neither the name of the copyright holder nor the names of its contributors
17  * may be used to endorse or promote products derived from this software without
18  * specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef RC_HAND_EYE_CALIB_JSON_CONVERSIONS_H
34 #define RC_HAND_EYE_CALIB_JSON_CONVERSIONS_H
35 
37 
38 #include <rc_hand_eye_calibration_client/SetCalibrationPose.h>
39 #include <rc_hand_eye_calibration_client/SetCalibration.h>
40 #include <rc_hand_eye_calibration_client/Calibration.h>
41 #include <rc_hand_eye_calibration_client/Trigger.h>
42 
44 {
45 inline void to_json(nlohmann::json& j, const TriggerRequest& r)
46 {
47  j = {};
48 }
49 
50 inline void from_json(const nlohmann::json& j, TriggerResponse& r)
51 {
52  j.at("success").get_to(r.success);
53  j.at("status").get_to(r.status);
54  j.at("message").get_to(r.message);
55 }
56 
57 inline void to_json(nlohmann::json& j, const SetCalibrationPoseRequest& r)
58 {
59  j["slot"] = r.slot;
60  j["pose"] = r.pose;
61 }
62 
63 inline void from_json(const nlohmann::json& j, SetCalibrationPoseResponse& r)
64 {
65  j.at("success").get_to(r.success);
66  j.at("status").get_to(r.status);
67  j.at("message").get_to(r.message);
68 }
69 
70 inline void to_json(nlohmann::json& j, const CalibrationRequest& r)
71 {
72  j = {};
73 }
74 
75 inline void from_json(const nlohmann::json& j, CalibrationResponse& r)
76 {
77  j.at("success").get_to(r.success);
78  j.at("status").get_to(r.status);
79  j.at("message").get_to(r.message);
80  j.at("pose").get_to(r.pose);
81  j.at("error").get_to(r.error);
82 
83  r.translation_error_meter=0;
84  if (j.count("translation_error_meter"))
85  {
86  j.at("translation_error_meter").get_to(r.translation_error_meter);
87  }
88 
89  r.rotation_error_degree=0;
90  if (j.count("rotation_error_degree"))
91  {
92  j.at("rotation_error_degree").get_to(r.rotation_error_degree);
93  }
94 
95  j.at("robot_mounted").get_to(r.robot_mounted);
96 }
97 
98 inline void to_json(nlohmann::json& j, const SetCalibrationRequest& r)
99 {
100  j["pose"] = r.pose;
101  j["robot_mounted"] = r.robot_mounted;
102 }
103 
104 inline void from_json(const nlohmann::json& j, SetCalibrationResponse& r)
105 {
106  j.at("success").get_to(r.success);
107  j.at("status").get_to(r.status);
108  j.at("message").get_to(r.message);
109 }
110 
111 } // namespace rc_hand_eye_calibration_client
112 
113 #endif // RC_HAND_EYE_CALIB_JSON_CONVERSIONS_H
void to_json(nlohmann::json &j, const TriggerRequest &r)
void from_json(const nlohmann::json &j, TriggerResponse &r)
nlohmann::json json


rc_hand_eye_calibration_client
Author(s): Christian Emmerich
autogenerated on Sat Feb 13 2021 03:41:55