d/psmv: Introduce proper grip and aim poses

Correctly rotate the grip pose to follow the spec more closely.
This commit is contained in:
Jakob Bornecrantz 2020-08-27 10:29:08 +01:00
parent d1c8084e4c
commit deb5633bf9
4 changed files with 34 additions and 22 deletions

View file

@ -0,0 +1,3 @@
psmv: Introduce proper grip and aim poses, correctly rotate the grip pose to
follow the spec more closely. The aim poses replaces the previous ball tip pose
that was used before for aim.

View file

@ -71,9 +71,10 @@ enum psmv_input_index
PSMV_INDEX_CIRCLE_CLICK,
PSMV_INDEX_TRIANGLE_CLICK,
PSMV_INDEX_TRIGGER_VALUE,
PSMV_INDEX_GRIP_POSE,
PSMV_INDEX_AIM_POSE,
PSMV_INDEX_BODY_CENTER_POSE,
PSMV_INDEX_BALL_CENTER_POSE,
PSMV_INDEX_BALL_TIP_POSE,
};
/*!
@ -886,13 +887,19 @@ psmv_device_get_tracked_pose(struct xrt_device *xdev,
*out_relation_timestamp_ns = now;
}
// Adjust from the normal body center pose to the ball tip.
if (name != XRT_INPUT_PSMV_BALL_TIP_POSE) {
/*
* Both the grip and aim pose needs adjustments, the grip is a rotated
* body center pose, while the aim pose needs to rotated and translated
* to the tip of the ball.
*/
if (name != XRT_INPUT_PSMV_AIM_POSE &&
name != XRT_INPUT_PSMV_GRIP_POSE) {
return;
}
float y = PSMV_BALL_FROM_IMU_Y_M;
if (name == XRT_INPUT_PSMV_BALL_TIP_POSE) {
float y = 0.0;
if (name == XRT_INPUT_PSMV_AIM_POSE) {
y += PSMV_BALL_FROM_IMU_Y_M;
y += PSMV_BALL_DIAMETER_M / 2.0;
}
@ -967,7 +974,7 @@ psmv_found(struct xrt_prober *xp,
enum u_device_alloc_flags flags = U_DEVICE_ALLOC_TRACKING_NONE;
struct psmv_device *psmv =
U_DEVICE_ALLOCATE(struct psmv_device, flags, 12, 1);
U_DEVICE_ALLOCATE(struct psmv_device, flags, 13, 1);
psmv->base.destroy = psmv_device_destroy;
psmv->base.update_inputs = psmv_device_update_inputs;
psmv->base.get_tracked_pose = psmv_device_get_tracked_pose;
@ -1019,9 +1026,10 @@ psmv_found(struct xrt_prober *xp,
SET_INPUT(CIRCLE_CLICK);
SET_INPUT(TRIANGLE_CLICK);
SET_INPUT(TRIGGER_VALUE);
SET_INPUT(GRIP_POSE);
SET_INPUT(AIM_POSE);
SET_INPUT(BODY_CENTER_POSE);
SET_INPUT(BALL_CENTER_POSE);
SET_INPUT(BALL_TIP_POSE);
// We only have one output.
psmv->base.outputs[0].name = XRT_OUTPUT_NAME_PSMV_RUMBLE_VIBRATION;

View file

@ -475,9 +475,10 @@ enum xrt_input_name
XRT_INPUT_PSMV_CIRCLE_CLICK = XRT_INPUT_NAME(0x0026, BOOLEAN),
XRT_INPUT_PSMV_TRIANGLE_CLICK = XRT_INPUT_NAME(0x0027, BOOLEAN),
XRT_INPUT_PSMV_TRIGGER_VALUE = XRT_INPUT_NAME(0x0028, VEC1_ZERO_TO_ONE),
XRT_INPUT_PSMV_BODY_CENTER_POSE = XRT_INPUT_NAME(0x0029, POSE),
XRT_INPUT_PSMV_BALL_CENTER_POSE = XRT_INPUT_NAME(0x002A, POSE),
XRT_INPUT_PSMV_BALL_TIP_POSE = XRT_INPUT_NAME(0x002B, POSE),
XRT_INPUT_PSMV_GRIP_POSE = XRT_INPUT_NAME(0x0029, POSE),
XRT_INPUT_PSMV_AIM_POSE = XRT_INPUT_NAME(0x002A, POSE),
XRT_INPUT_PSMV_BODY_CENTER_POSE = XRT_INPUT_NAME(0x002B, POSE),
XRT_INPUT_PSMV_BALL_CENTER_POSE = XRT_INPUT_NAME(0x002C, POSE),
XRT_INPUT_HYDRA_1_CLICK = XRT_INPUT_NAME(0x0030, BOOLEAN),
XRT_INPUT_HYDRA_2_CLICK = XRT_INPUT_NAME(0x0031, BOOLEAN),

View file

@ -93,7 +93,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
},
.inputs =
{
XRT_INPUT_PSMV_BODY_CENTER_POSE,
XRT_INPUT_PSMV_GRIP_POSE,
XRT_INPUT_HYDRA_POSE,
XRT_INPUT_DAYDREAM_POSE,
XRT_INPUT_INDEX_GRIP_POSE,
@ -111,7 +111,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
},
.inputs =
{
XRT_INPUT_PSMV_BALL_TIP_POSE,
XRT_INPUT_PSMV_AIM_POSE,
XRT_INPUT_HYDRA_POSE,
XRT_INPUT_DAYDREAM_POSE,
XRT_INPUT_INDEX_AIM_POSE,
@ -180,7 +180,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
},
.inputs =
{
XRT_INPUT_PSMV_BODY_CENTER_POSE,
XRT_INPUT_PSMV_GRIP_POSE,
XRT_INPUT_HYDRA_POSE,
XRT_INPUT_DAYDREAM_POSE,
XRT_INPUT_INDEX_GRIP_POSE,
@ -198,7 +198,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
},
.inputs =
{
XRT_INPUT_PSMV_BALL_TIP_POSE,
XRT_INPUT_PSMV_AIM_POSE,
XRT_INPUT_HYDRA_POSE,
XRT_INPUT_DAYDREAM_POSE,
XRT_INPUT_INDEX_AIM_POSE,
@ -303,7 +303,7 @@ static struct binding_template google_daydream_controller_bindings[12] = {
.inputs =
{
#if 0
XRT_INPUT_PSMV_BODY_CENTER_POSE,
XRT_INPUT_PSMV_GRIP_POSE,
XRT_INPUT_HYDRA_POSE,
#endif
(enum xrt_input_name)0,
@ -320,7 +320,7 @@ static struct binding_template google_daydream_controller_bindings[12] = {
.inputs =
{
#if 0
XRT_INPUT_PSMV_BALL_TIP_POSE,
XRT_INPUT_PSMV_AIM_POSE,
XRT_INPUT_HYDRA_POSE,
#endif
(enum xrt_input_name)0,
@ -394,7 +394,7 @@ static struct binding_template google_daydream_controller_bindings[12] = {
.inputs =
{
#if 0
XRT_INPUT_PSMV_BODY_CENTER_POSE,
XRT_INPUT_PSMV_GRIP_POSE,
XRT_INPUT_HYDRA_POSE,
#endif
(enum xrt_input_name)0,
@ -411,7 +411,7 @@ static struct binding_template google_daydream_controller_bindings[12] = {
.inputs =
{
#if 0
XRT_INPUT_PSMV_BALL_TIP_POSE,
XRT_INPUT_PSMV_AIM_POSE,
XRT_INPUT_HYDRA_POSE,
#endif
(enum xrt_input_name)0,
@ -567,7 +567,7 @@ static struct binding_template mndx_ball_on_a_stick_controller_bindings[26] = {
},
.inputs =
{
XRT_INPUT_PSMV_BODY_CENTER_POSE,
XRT_INPUT_PSMV_GRIP_POSE,
(enum xrt_input_name)0,
},
},
@ -595,7 +595,7 @@ static struct binding_template mndx_ball_on_a_stick_controller_bindings[26] = {
},
.inputs =
{
XRT_INPUT_PSMV_BALL_TIP_POSE,
XRT_INPUT_PSMV_AIM_POSE,
(enum xrt_input_name)0,
},
},
@ -748,7 +748,7 @@ static struct binding_template mndx_ball_on_a_stick_controller_bindings[26] = {
},
.inputs =
{
XRT_INPUT_PSMV_BODY_CENTER_POSE,
XRT_INPUT_PSMV_GRIP_POSE,
(enum xrt_input_name)0,
},
},
@ -776,7 +776,7 @@ static struct binding_template mndx_ball_on_a_stick_controller_bindings[26] = {
},
.inputs =
{
XRT_INPUT_PSMV_BALL_TIP_POSE,
XRT_INPUT_PSMV_AIM_POSE,
(enum xrt_input_name)0,
},
},