mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
u/json: Add u_json_get_pose
This commit is contained in:
parent
d91975299d
commit
b31eb76718
|
@ -262,6 +262,23 @@ u_json_get_quat(const cJSON *json, struct xrt_quat *out_quat)
|
|||
return true;
|
||||
}
|
||||
|
||||
// note: you should be using "position" and "orientation" and lower-case xyz(w)
|
||||
bool
|
||||
u_json_get_pose(const cJSON *json, struct xrt_pose *out_pose)
|
||||
{
|
||||
struct xrt_pose tmp;
|
||||
|
||||
bool good = true;
|
||||
good = good && u_json_get_vec3(u_json_get(json, "position"), &tmp.position);
|
||||
good = good && u_json_get_quat(u_json_get(json, "orientation"), &tmp.orientation);
|
||||
|
||||
if (good) {
|
||||
*out_pose = tmp;
|
||||
}
|
||||
return good;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
u_json_get_float_array(const cJSON *json_array, float *out_array, size_t max_size)
|
||||
{
|
||||
|
|
|
@ -101,6 +101,15 @@ u_json_get_vec3_f64_array(const cJSON *json, struct xrt_vec3_f64 *out_vec3);
|
|||
bool
|
||||
u_json_get_quat(const cJSON *json, struct xrt_quat *out_quat);
|
||||
|
||||
/*!
|
||||
* @brief Parse a pose from a JSON object, composed of a vec3 named "position" and a quat named "orientation".
|
||||
*
|
||||
* @return true if successful, false if not.
|
||||
*/
|
||||
bool
|
||||
u_json_get_pose(const cJSON *json, struct xrt_pose *out_pose);
|
||||
|
||||
|
||||
/*!
|
||||
* @brief Parse up to max_size floats from a JSON array.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue