u/ht: Port to using new zero/identity defines

This commit is contained in:
Ryan Pavlik 2021-04-26 15:04:47 -05:00 committed by Jakob Bornecrantz
parent edc6490d74
commit cb8925ae04

View file

@ -60,7 +60,7 @@ struct u_joint_curl_model
static struct u_joint_curl_model hand_joint_default_set_curl_model_defaults[XRT_HAND_JOINT_COUNT] = { static struct u_joint_curl_model hand_joint_default_set_curl_model_defaults[XRT_HAND_JOINT_COUNT] = {
// special cases: wrist and palm without bone lengths, offsets are // special cases: wrist and palm without bone lengths, offsets are
// absolute, relative to hand origin (palm) // absolute, relative to hand origin (palm)
[XRT_HAND_JOINT_PALM] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_PALM] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0, .bone_length = 0,
.radius = 0.018, .radius = 0.018,
@ -84,25 +84,25 @@ static struct u_joint_curl_model hand_joint_default_set_curl_model_defaults[XRT_
.radius = 0.015, .radius = 0.015,
.joint_id = XRT_HAND_JOINT_LITTLE_METACARPAL}, .joint_id = XRT_HAND_JOINT_LITTLE_METACARPAL},
[XRT_HAND_JOINT_LITTLE_PROXIMAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_LITTLE_PROXIMAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, DEG_TO_RAD(20), 0}, .axis_angle_offset = {0, DEG_TO_RAD(20), 0},
.bone_length = 0.035, .bone_length = 0.035,
.radius = 0.01, .radius = 0.01,
.joint_id = XRT_HAND_JOINT_LITTLE_PROXIMAL}, .joint_id = XRT_HAND_JOINT_LITTLE_PROXIMAL},
[XRT_HAND_JOINT_LITTLE_INTERMEDIATE] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_LITTLE_INTERMEDIATE] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.028, .bone_length = 0.028,
.radius = 0.009, .radius = 0.009,
.joint_id = XRT_HAND_JOINT_LITTLE_INTERMEDIATE}, .joint_id = XRT_HAND_JOINT_LITTLE_INTERMEDIATE},
[XRT_HAND_JOINT_LITTLE_DISTAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_LITTLE_DISTAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.022, .bone_length = 0.022,
.radius = 0.009, .radius = 0.009,
.joint_id = XRT_HAND_JOINT_LITTLE_DISTAL}, .joint_id = XRT_HAND_JOINT_LITTLE_DISTAL},
[XRT_HAND_JOINT_LITTLE_TIP] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_LITTLE_TIP] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0, .bone_length = 0,
.radius = 0.012, .radius = 0.012,
@ -115,25 +115,25 @@ static struct u_joint_curl_model hand_joint_default_set_curl_model_defaults[XRT_
.radius = 0.015, .radius = 0.015,
.joint_id = XRT_HAND_JOINT_RING_METACARPAL}, .joint_id = XRT_HAND_JOINT_RING_METACARPAL},
[XRT_HAND_JOINT_RING_PROXIMAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_RING_PROXIMAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, DEG_TO_RAD(10), 0}, .axis_angle_offset = {0, DEG_TO_RAD(10), 0},
.bone_length = 0.040, .bone_length = 0.040,
.radius = 0.012, .radius = 0.012,
.joint_id = XRT_HAND_JOINT_RING_PROXIMAL}, .joint_id = XRT_HAND_JOINT_RING_PROXIMAL},
[XRT_HAND_JOINT_RING_INTERMEDIATE] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_RING_INTERMEDIATE] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.031, .bone_length = 0.031,
.radius = 0.01, .radius = 0.01,
.joint_id = XRT_HAND_JOINT_RING_INTERMEDIATE}, .joint_id = XRT_HAND_JOINT_RING_INTERMEDIATE},
[XRT_HAND_JOINT_RING_DISTAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_RING_DISTAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.023, .bone_length = 0.023,
.radius = 0.01, .radius = 0.01,
.joint_id = XRT_HAND_JOINT_RING_DISTAL}, .joint_id = XRT_HAND_JOINT_RING_DISTAL},
[XRT_HAND_JOINT_RING_TIP] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_RING_TIP] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0, .bone_length = 0,
.radius = 0.013, .radius = 0.013,
@ -146,25 +146,25 @@ static struct u_joint_curl_model hand_joint_default_set_curl_model_defaults[XRT_
.radius = 0.012, .radius = 0.012,
.joint_id = XRT_HAND_JOINT_MIDDLE_METACARPAL}, .joint_id = XRT_HAND_JOINT_MIDDLE_METACARPAL},
[XRT_HAND_JOINT_MIDDLE_PROXIMAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_MIDDLE_PROXIMAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.042, .bone_length = 0.042,
.radius = 0.01, .radius = 0.01,
.joint_id = XRT_HAND_JOINT_MIDDLE_PROXIMAL}, .joint_id = XRT_HAND_JOINT_MIDDLE_PROXIMAL},
[XRT_HAND_JOINT_MIDDLE_INTERMEDIATE] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_MIDDLE_INTERMEDIATE] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.033, .bone_length = 0.033,
.radius = 0.01, .radius = 0.01,
.joint_id = XRT_HAND_JOINT_MIDDLE_INTERMEDIATE}, .joint_id = XRT_HAND_JOINT_MIDDLE_INTERMEDIATE},
[XRT_HAND_JOINT_MIDDLE_DISTAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_MIDDLE_DISTAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.024, .bone_length = 0.024,
.radius = 0.01, .radius = 0.01,
.joint_id = XRT_HAND_JOINT_MIDDLE_DISTAL}, .joint_id = XRT_HAND_JOINT_MIDDLE_DISTAL},
[XRT_HAND_JOINT_MIDDLE_TIP] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_MIDDLE_TIP] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0, .bone_length = 0,
.radius = 0.01, .radius = 0.01,
@ -177,25 +177,25 @@ static struct u_joint_curl_model hand_joint_default_set_curl_model_defaults[XRT_
.radius = 0.012, .radius = 0.012,
.joint_id = XRT_HAND_JOINT_INDEX_METACARPAL}, .joint_id = XRT_HAND_JOINT_INDEX_METACARPAL},
[XRT_HAND_JOINT_INDEX_PROXIMAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_INDEX_PROXIMAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, DEG_TO_RAD(-10), 0}, .axis_angle_offset = {0, DEG_TO_RAD(-10), 0},
.bone_length = 0.040, .bone_length = 0.040,
.radius = 0.011, .radius = 0.011,
.joint_id = XRT_HAND_JOINT_INDEX_PROXIMAL}, .joint_id = XRT_HAND_JOINT_INDEX_PROXIMAL},
[XRT_HAND_JOINT_INDEX_INTERMEDIATE] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_INDEX_INTERMEDIATE] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.031, .bone_length = 0.031,
.radius = 0.01, .radius = 0.01,
.joint_id = XRT_HAND_JOINT_INDEX_INTERMEDIATE}, .joint_id = XRT_HAND_JOINT_INDEX_INTERMEDIATE},
[XRT_HAND_JOINT_INDEX_DISTAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_INDEX_DISTAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.023, .bone_length = 0.023,
.radius = 0.01, .radius = 0.01,
.joint_id = XRT_HAND_JOINT_INDEX_DISTAL}, .joint_id = XRT_HAND_JOINT_INDEX_DISTAL},
[XRT_HAND_JOINT_INDEX_TIP] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_INDEX_TIP] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0, .bone_length = 0,
.radius = 0.01, .radius = 0.01,
@ -208,20 +208,20 @@ static struct u_joint_curl_model hand_joint_default_set_curl_model_defaults[XRT_
.radius = 0.0175, .radius = 0.0175,
.joint_id = XRT_HAND_JOINT_THUMB_METACARPAL}, .joint_id = XRT_HAND_JOINT_THUMB_METACARPAL},
[XRT_HAND_JOINT_THUMB_PROXIMAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_THUMB_PROXIMAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, DEG_TO_RAD(-12), 0}, .axis_angle_offset = {0, DEG_TO_RAD(-12), 0},
.bone_length = 0.038, .bone_length = 0.038,
.radius = 0.017, .radius = 0.017,
.joint_id = XRT_HAND_JOINT_THUMB_PROXIMAL}, .joint_id = XRT_HAND_JOINT_THUMB_PROXIMAL},
// no intermediate // no intermediate
[XRT_HAND_JOINT_THUMB_DISTAL] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_THUMB_DISTAL] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0.028, .bone_length = 0.028,
.radius = 0.017, .radius = 0.017,
.joint_id = XRT_HAND_JOINT_THUMB_DISTAL}, .joint_id = XRT_HAND_JOINT_THUMB_DISTAL},
[XRT_HAND_JOINT_THUMB_TIP] = {.position_offset = {.x = 0, .y = 0, .z = 0}, [XRT_HAND_JOINT_THUMB_TIP] = {.position_offset = XRT_VEC3_ZERO,
.axis_angle_offset = {0, 0, 0}, .axis_angle_offset = {0, 0, 0},
.bone_length = 0, .bone_length = 0,
.radius = 0.016, .radius = 0.016,
@ -325,7 +325,7 @@ u_hand_joint_compute_next_by_curl(struct u_hand_tracking *set,
//! @todo more axis rotations & make sure order is right //! @todo more axis rotations & make sure order is right
//! @todo handle velocities //! @todo handle velocities
struct xrt_pose offset_pose; struct xrt_pose offset_pose = XRT_POSE_IDENTITY;
if (hand == XRT_HAND_LEFT) { if (hand == XRT_HAND_LEFT) {
quat_from_angle_vector_clockwise(defaults.axis_angle_offset[1], &y_axis, &offset_pose.orientation); quat_from_angle_vector_clockwise(defaults.axis_angle_offset[1], &y_axis, &offset_pose.orientation);
offset_pose.position = defaults.position_offset; offset_pose.position = defaults.position_offset;
@ -385,7 +385,7 @@ u_hand_joint_compute_next_by_curl(struct u_hand_tracking *set,
math_quat_finite_difference(&old_relation.pose.orientation, &out_joint->relation.pose.orientation, math_quat_finite_difference(&old_relation.pose.orientation, &out_joint->relation.pose.orientation,
time_diff_s, &out_joint->relation.angular_velocity); time_diff_s, &out_joint->relation.angular_velocity);
} else { } else {
out_joint->relation.angular_velocity = (struct xrt_vec3){0, 0, 0}; out_joint->relation.angular_velocity = (struct xrt_vec3)XRT_VEC3_ZERO;
} }
out_joint->relation.relation_flags = POSE_VALID_FLAGS | VELOCIY_VALID_FLAGS; out_joint->relation.relation_flags = POSE_VALID_FLAGS | VELOCIY_VALID_FLAGS;
@ -403,7 +403,7 @@ u_hand_joints_update_curl(struct u_hand_tracking *set,
float curl_index = curl_values->index; float curl_index = curl_values->index;
float curl_thumb = curl_values->thumb; float curl_thumb = curl_values->thumb;
const struct xrt_quat identity_quat = {0, 0, 0, 1}; const struct xrt_quat identity_quat = XRT_QUAT_IDENTITY;
//! @todo: full relations with velocities //! @todo: full relations with velocities
@ -411,15 +411,15 @@ u_hand_joints_update_curl(struct u_hand_tracking *set,
set->joints.wrist.relation.pose = (struct xrt_pose){ set->joints.wrist.relation.pose = (struct xrt_pose){
.position = hand_joint_default_set_curl_model_defaults[XRT_HAND_JOINT_WRIST].position_offset, .position = hand_joint_default_set_curl_model_defaults[XRT_HAND_JOINT_WRIST].position_offset,
.orientation = identity_quat}; .orientation = identity_quat};
set->joints.wrist.relation.linear_velocity = (struct xrt_vec3){0, 0, 0}; set->joints.wrist.relation.linear_velocity = (struct xrt_vec3)XRT_VEC3_ZERO;
set->joints.wrist.relation.angular_velocity = (struct xrt_vec3){0, 0, 0}; set->joints.wrist.relation.angular_velocity = (struct xrt_vec3)XRT_VEC3_ZERO;
set->joints.wrist.relation.relation_flags = POSE_VALID_FLAGS | VELOCIY_VALID_FLAGS; set->joints.wrist.relation.relation_flags = POSE_VALID_FLAGS | VELOCIY_VALID_FLAGS;
set->joints.palm.relation.pose = (struct xrt_pose){ set->joints.palm.relation.pose = (struct xrt_pose){
.position = hand_joint_default_set_curl_model_defaults[XRT_HAND_JOINT_PALM].position_offset, .position = hand_joint_default_set_curl_model_defaults[XRT_HAND_JOINT_PALM].position_offset,
.orientation = identity_quat}; .orientation = identity_quat};
set->joints.palm.relation.linear_velocity = (struct xrt_vec3){0, 0, 0}; set->joints.palm.relation.linear_velocity = (struct xrt_vec3)XRT_VEC3_ZERO;
set->joints.palm.relation.angular_velocity = (struct xrt_vec3){0, 0, 0}; set->joints.palm.relation.angular_velocity = (struct xrt_vec3)XRT_VEC3_ZERO;
set->joints.palm.relation.relation_flags = POSE_VALID_FLAGS | VELOCIY_VALID_FLAGS; set->joints.palm.relation.relation_flags = POSE_VALID_FLAGS | VELOCIY_VALID_FLAGS;
struct u_joint_space_relation *prev = &set->joints.wrist; struct u_joint_space_relation *prev = &set->joints.wrist;
@ -704,13 +704,13 @@ u_hand_joints_offset_valve_index_controller(enum xrt_hand hand, struct xrt_vec3
} }
struct xrt_quat hand_rotation_y = {0, 0, 0, 1}; struct xrt_quat hand_rotation_y = XRT_QUAT_IDENTITY;
math_quat_from_angle_vector(hand_on_handle_y_rotation, &y, &hand_rotation_y); math_quat_from_angle_vector(hand_on_handle_y_rotation, &y, &hand_rotation_y);
struct xrt_quat hand_rotation_z = {0, 0, 0, 1};
math_quat_from_angle_vector(hand_on_handle_z_rotation, &z, &hand_rotation_z); math_quat_from_angle_vector(hand_on_handle_z_rotation, &z, &hand_rotation_z);
struct xrt_quat hand_rotation_z = XRT_QUAT_IDENTITY;
struct xrt_quat hand_rotation_x = {0, 0, 0, 1}; struct xrt_quat hand_rotation_x = XRT_QUAT_IDENTITY;
math_quat_from_angle_vector(hand_on_handle_x_rotation, &x, &hand_rotation_x); math_quat_from_angle_vector(hand_on_handle_x_rotation, &x, &hand_rotation_x);
struct xrt_quat hand_rotation; struct xrt_quat hand_rotation;