33 #ifndef RC_PICK_CLIENT_JSON_CONVERSIONS_H
34 #define RC_PICK_CLIENT_JSON_CONVERSIONS_H
38 #include <rc_common_msgs/ReturnCode.h>
40 #include <rc_pick_client/Box.h>
41 #include <rc_pick_client/Item.h>
42 #include <rc_pick_client/ItemModel.h>
43 #include <rc_pick_client/LoadCarrier.h>
44 #include <rc_pick_client/SuctionGrasp.h>
45 #include <rc_pick_client/Compartment.h>
47 #include <rc_pick_client/ComputeGrasps.h>
48 #include <rc_pick_client/ComputeBoxGrasps.h>
49 #include <rc_pick_client/DetectItems.h>
55 j.at(
"value").get_to(r.value);
56 j.at(
"message").get_to(r.message);
72 j.at(
"x").get_to(r.x);
73 j.at(
"y").get_to(r.y);
74 j.at(
"z").get_to(r.z);
79 j[
"min_dimensions"] = r.min_dimensions;
80 j[
"max_dimensions"] = r.max_dimensions;
85 j.at(
"min_dimensions").get_to(r.min_dimensions);
86 j.at(
"max_dimensions").get_to(r.max_dimensions);
97 j.at(
"x").get_to(r.x);
98 j.at(
"y").get_to(r.y);
103 j[
"min_dimensions"] = r.min_dimensions;
104 j[
"max_dimensions"] = r.max_dimensions;
109 j.at(
"min_dimensions").get_to(r.min_dimensions);
110 j.at(
"max_dimensions").get_to(r.max_dimensions);
115 j.at(
"uuid").get_to(r.uuid);
116 j.at(
"item_uuid").get_to(r.item_uuid);
117 j.at(
"pose").get_to(r.pose.pose);
118 j.at(
"timestamp").get_to(r.pose.header.stamp);
119 j.at(
"pose_frame").get_to(r.pose.header.frame_id);
120 j.at(
"quality").get_to(r.quality);
121 j.at(
"max_suction_surface_length").get_to(r.max_suction_surface_length);
122 j.at(
"max_suction_surface_width").get_to(r.max_suction_surface_width);
128 if (r.type == r.UNKNOWN)
130 j[
"unknown"] = r.unknown;
132 else if (r.type == r.RECTANGLE)
134 j[
"rectangle"] = r.rectangle;
140 j.at(
"uuid").get_to(r.uuid);
141 j.at(
"grasp_uuids").get_to(r.grasp_uuids);
142 j.at(
"type").get_to(r.type);
143 j.at(
"rectangle").get_to(r.rectangle);
144 j.at(
"pose").get_to(r.pose.pose);
145 j.at(
"timestamp").get_to(r.pose.header.stamp);
146 j.at(
"pose_frame").get_to(r.pose.header.frame_id);;
152 j[
"outer_dimensions"] = r.outer_dimensions;
153 j[
"inner_dimensions"] = r.inner_dimensions;
154 j[
"rim_thickness"] = r.rim_thickness;
155 j[
"pose"] = r.pose.pose;
156 j[
"pose_frame"] = r.pose.header.frame_id;
162 j.at(
"id").get_to(r.id);
163 j.at(
"outer_dimensions").get_to(r.outer_dimensions);
164 j.at(
"inner_dimensions").get_to(r.inner_dimensions);
165 j.at(
"rim_thickness").get_to(r.rim_thickness);
166 j.at(
"pose").get_to(r.pose.pose);
167 j.at(
"pose_frame").get_to(r.pose.header.frame_id);
169 if (j.count(
"overfilled"))
170 j.at(
"overfilled").get_to(r.overfilled);
181 j[
"gripper_id"] = r.gripper_id;
182 if (r.pre_grasp_offset.x != 0 || r.pre_grasp_offset.y != 0 || r.pre_grasp_offset.z != 0)
184 j[
"pre_grasp_offset"] = r.pre_grasp_offset;
191 j[
"pose_frame"] = r.pose_frame;
192 if (r.pose_frame ==
"external")
194 j[
"robot_pose"] = r.robot_pose;
196 if (!r.region_of_interest_id.empty())
198 j[
"region_of_interest_id"] = r.region_of_interest_id;
200 if (!r.load_carrier_id.empty())
202 j[
"load_carrier_id"] = r.load_carrier_id;
203 j[
"load_carrier_compartment"] = r.load_carrier_compartment;
205 j[
"item_models"] = r.item_models;
206 j[
"suction_surface_length"] = r.suction_surface_length;
207 j[
"suction_surface_width"] = r.suction_surface_width;
208 if (!r.collision_detection.gripper_id.empty())
210 j[
"collision_detection"] = r.collision_detection;
216 j.at(
"timestamp").get_to(r.timestamp);
217 j.at(
"load_carriers").get_to(r.load_carriers);
218 j.at(
"grasps").get_to(r.grasps);
219 j.at(
"return_code").get_to(r.return_code);
224 j[
"pose_frame"] = r.pose_frame;
225 if (r.pose_frame ==
"external")
227 j[
"robot_pose"] = r.robot_pose;
229 if (!r.region_of_interest_id.empty())
231 j[
"region_of_interest_id"] = r.region_of_interest_id;
233 if (!r.load_carrier_id.empty())
235 j[
"load_carrier_id"] = r.load_carrier_id;
236 j[
"load_carrier_compartment"] = r.load_carrier_compartment;
238 if (!r.item_models.empty())
240 j[
"item_models"] = r.item_models;
242 j[
"suction_surface_length"] = r.suction_surface_length;
243 j[
"suction_surface_width"] = r.suction_surface_width;
244 if (!r.collision_detection.gripper_id.empty())
246 j[
"collision_detection"] = r.collision_detection;
252 j.at(
"timestamp").get_to(r.timestamp);
253 j.at(
"load_carriers").get_to(r.load_carriers);
254 j.at(
"items").get_to(r.items);
255 j.at(
"grasps").get_to(r.grasps);
256 j.at(
"return_code").get_to(r.return_code);
261 j[
"item_models"] = r.item_models;
262 j[
"pose_frame"] = r.pose_frame;
263 if (r.pose_frame ==
"external")
265 j[
"robot_pose"] = r.robot_pose;
267 if (!r.region_of_interest_id.empty())
269 j[
"region_of_interest_id"] = r.region_of_interest_id;
271 if (!r.load_carrier_id.empty())
273 j[
"load_carrier_id"] = r.load_carrier_id;
274 j[
"load_carrier_compartment"] = r.load_carrier_compartment;
280 j.at(
"timestamp").get_to(r.timestamp);
281 j.at(
"load_carriers").get_to(r.load_carriers);
282 j.at(
"items").get_to(r.items);
283 j.at(
"return_code").get_to(r.return_code);
288 #endif // RC_PICK_CLIENT_JSON_CONVERSIONS_H