Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

Implementing (untested) head-above-torso tracking

parent edf06eab
...@@ -252,22 +252,27 @@ classdef itaVA < handle ...@@ -252,22 +252,27 @@ classdef itaVA < handle
VAMatlab( 'set_tracked_sound_receiver', this.handle, sound_receiver_id ); VAMatlab( 'set_tracked_sound_receiver', this.handle, sound_receiver_id );
end end
function set_tracked_sound_receiver_rigid_body_index( this, index ) function set_tracked_sound_receiver_head_rigid_body_index( this, index )
% Sets the index of the rigid body to be tracked for sound receiver (default is 1) % Sets the index of the rigid body to be tracked for sound receiver (default is 1)
VAMatlab( 'set_tracked_sound_receiver_rigid_body_index', this.handle, index ) VAMatlab( 'set_tracked_sound_receiver_head_rigid_body_index', this.handle, index )
end end
function set_tracked_sound_receiver_rigid_body_translation( this, translation ) function set_tracked_sound_receiver_torso_rigid_body_index( this, index )
% Sets the index of the rigid body to be tracked for sound receiver's absolute torso orientation (default is 1)
VAMatlab( 'set_tracked_sound_receiver_torso_rigid_body_index', this.handle, index )
end
function set_tracked_sound_receiver_head_rigid_body_translation( this, translation )
% Sets the pivot point translation for the tracked sound receiver rigid body % Sets the pivot point translation for the tracked sound receiver rigid body
% %
% Parameters: % Parameters:
% %
% translation [double-3x1] Translation in local coordinate system of rigid body [m] % translation [double-3x1] Translation in local coordinate system of rigid body [m]
% %
VAMatlab( 'set_tracked_sound_receiver_rigid_body_translation', this.handle, translation ) VAMatlab( 'set_tracked_sound_receiver_head_rigid_body_translation', this.handle, translation )
end end
function set_tracked_sound_receiver_rigid_body_rotation( this, rotation ) function set_tracked_sound_receiver_head_rigid_body_rotation( this, rotation )
% Sets the rotation of orientation for the tracked sound receiver rigid body % Sets the rotation of orientation for the tracked sound receiver rigid body
% %
% Given rotation has to be a Matlab quaternion type (order: w(real), i, j, k) % Given rotation has to be a Matlab quaternion type (order: w(real), i, j, k)
...@@ -276,7 +281,7 @@ classdef itaVA < handle ...@@ -276,7 +281,7 @@ classdef itaVA < handle
% %
% rotation [quaternion] Rotation of rigid body % rotation [quaternion] Rotation of rigid body
% %
VAMatlab( 'set_tracked_sound_receiver_rigid_body_rotation', this.handle, rotation ) VAMatlab( 'set_tracked_sound_receiver_head_rigid_body_rotation', this.handle, rotation )
end end
% -- Tracked real-world sound receiver -- % % -- Tracked real-world sound receiver -- %
...@@ -291,22 +296,27 @@ classdef itaVA < handle ...@@ -291,22 +296,27 @@ classdef itaVA < handle
VAMatlab( 'set_tracked_real_world_sound_receiver', this.handle, sound_receiver_id ); VAMatlab( 'set_tracked_real_world_sound_receiver', this.handle, sound_receiver_id );
end end
function set_tracked_real_world_sound_receiver_rigid_body_index( this, index ) function set_tracked_real_world_sound_receiver_head_rigid_body_index( this, index )
% Sets the index of the rigid body to be tracked for real-world sound receiver (default is 1) % Sets the index of the rigid body to be tracked for real-world sound receiver (default is 1)
VAMatlab( 'set_tracked_real_world_sound_receiver_rigid_body_index', this.handle, index ) VAMatlab( 'set_tracked_real_world_sound_receiver_rigid_body_index', this.handle, index )
end end
function set_tracked_real_world_sound_receiver_torso_rigid_body_index( this, index )
% Sets the index of the rigid body to be tracked for real-world sound receiver' torso (default is 1)
VAMatlab( 'set_tracked_real_world_sound_receiver_torso_rigid_body_index', this.handle, index )
end
function set_tracked_real_world_sound_receiver_rigid_body_translation( this, translation ) function set_tracked_real_world_sound_receiver_head_rigid_body_translation( this, translation )
% Sets the pivot point translation for the tracked real-world sound receiver rigid body % Sets the pivot point translation for the tracked real-world sound receiver rigid body
% %
% Parameters: % Parameters:
% %
% translation [double-3x1] Translation in local coordinate system of rigid body [m] % translation [double-3x1] Translation in local coordinate system of rigid body [m]
% %
VAMatlab( 'set_tracked_real_world_sound_receiver_rigid_body_translation', this.handle, translation ) VAMatlab( 'set_tracked_real_world_sound_receiver_head_rigid_body_translation', this.handle, translation )
end end
function set_tracked_real_world_sound_receiver_rigid_body_rotation( this, rotation ) function set_tracked_real_world_sound_receiver_head_rigid_body_rotation( this, rotation )
% Sets the rotation of orientation for the tracked real-world sound receiver rigid body % Sets the rotation of orientation for the tracked real-world sound receiver rigid body
% %
% Given rotation has to be a Matlab quaternion type (order: w(real), i, j, k) % Given rotation has to be a Matlab quaternion type (order: w(real), i, j, k)
...@@ -315,7 +325,7 @@ classdef itaVA < handle ...@@ -315,7 +325,7 @@ classdef itaVA < handle
% %
% rotation [quaternion] Rotation of rigid body % rotation [quaternion] Rotation of rigid body
% %
VAMatlab( 'set_tracked_real_world_sound_receiver_rigid_body_rotation', this.handle, rotation ) VAMatlab( 'set_tracked_real_world_sound_receiver_head_rigid_body_rotation', this.handle, rotation )
end end
% -- Tracked source -- % % -- Tracked source -- %
......
This diff is collapsed.
...@@ -34,60 +34,106 @@ void TrackerDataHandler( sFrameOfMocapData* sFrame, void* pUserData ) ...@@ -34,60 +34,106 @@ void TrackerDataHandler( sFrameOfMocapData* sFrame, void* pUserData )
// SoundReceiver // SoundReceiver
int iTrackedReceiverID = pVAMatlabTracker->iTrackedSoundReceiverID; int iTrackedReceiverID = pVAMatlabTracker->iTrackedSoundReceiverID;
int iTrackedReceiverRigidBodyIndex = pVAMatlabTracker->iTrackedSoundReceiverRigidBodyIndex; int iTrackedReceiverRigidBodyIndex = pVAMatlabTracker->iTrackedSoundReceiverHeadRigidBodyIndex;
int iTrackedReceiverHATORigidBodyIndex = pVAMatlabTracker->iTrackedSoundReceiverTorsoRigidBodyIndex;
if( ( iTrackedReceiverID != -1 ) && ( iTrackedReceiverRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedReceiverRigidBodyIndex > 0 ) ) if( iTrackedReceiverID != -1 )
{ {
try // Tracked receiver
if( ( iTrackedReceiverRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedReceiverRigidBodyIndex > 0 ) )
{ {
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedSoundReceiverTranslation; try
VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedSoundReceiverRotation; {
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedSoundReceiverTranslation;
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedReceiverRigidBodyIndex - 1 ] ); VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedSoundReceiverRotation;
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw ); const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedReceiverRigidBodyIndex - 1 ] );
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw; VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir(); VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw;
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem ); VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir();
VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem );
pVACore->SetSoundReceiverPosition( iTrackedReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ) ); VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
pVACore->SetSoundReceiverOrientationVU( iTrackedReceiverID, VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) );
pVACore->SetSoundReceiverPosition( iTrackedReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ) );
pVACore->SetSoundReceiverOrientationVU( iTrackedReceiverID, VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) );
}
catch( ... )
{
}
} }
catch( ... )
// HATO orientation
if( ( iTrackedReceiverHATORigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedReceiverHATORigidBodyIndex > 0 ) )
{ {
try
{
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedReceiverHATORigidBodyIndex - 1 ] );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
// Convert absolute orientation to relative HATO orientation
VAQuat qOrient = pVACore->GetSoundReceiverOrientation( iTrackedReceiverID );
VistaQuaternion qHeadOrient( qOrient.comp );
VistaQuaternion qHATOOrient = qOrientRaw * qHeadOrient;
VAQuat qFinalHATO = VAQuat( qHATOOrient[ Vista::X ], qHATOOrient[ Vista::Y ], qHATOOrient[ Vista::Z ], qHATOOrient[ Vista::W ] );
pVACore->SetSoundReceiverHeadAboveTorsoOrientation( iTrackedReceiverID, qFinalHATO );
}
catch( ... )
{
}
} }
} }
// Real-world listener // Real-world sound receiver
int iTrackedRealWorldSoundReceiverID = pVAMatlabTracker->iTrackedRealWorldSoundReceiverID; int iTrackedRealWorldSoundReceiverID = pVAMatlabTracker->iTrackedRealWorldSoundReceiverID;
int iTrackedRealWorldSoundReceiverRigidBodyIndex = pVAMatlabTracker->iTrackedRealWorldSoundReceiverRigidBodyIndex; int iTrackedRealWorldSoundReceiverRigidBodyIndex = pVAMatlabTracker->iTrackedRealWorldSoundReceiverRigidBodyIndex;
int iTrackedRealWorldSoundReceiverHATORigidBodyIndex = pVAMatlabTracker->iTrackedRealWorldSoundReceiverTorsoRigidBodyIndex;
if( ( iTrackedRealWorldSoundReceiverID != -1 ) && ( iTrackedRealWorldSoundReceiverRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedRealWorldSoundReceiverRigidBodyIndex > 0 ) ) if( iTrackedRealWorldSoundReceiverID != -1 )
{ {
try // Real world receiver tracking
if( ( iTrackedRealWorldSoundReceiverRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedRealWorldSoundReceiverRigidBodyIndex > 0 ) )
{ {
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation; try
VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation; {
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation;
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedRealWorldSoundReceiverRigidBodyIndex - 1 ] ); VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation;
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw ); const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedRealWorldSoundReceiverRigidBodyIndex - 1 ] );
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw; VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir(); VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw;
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem ); VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir();
VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem );
pVACore->SetSoundReceiverRealWorldPositionOrientationVU( iTrackedRealWorldSoundReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ), VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) ); VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
pVACore->SetSoundReceiverRealWorldPositionOrientationVU( iTrackedRealWorldSoundReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ), VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) );
}
catch( ... )
{
}
} }
catch( ... )
// Real world receiver HATO orientation
if( ( iTrackedRealWorldSoundReceiverHATORigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedRealWorldSoundReceiverHATORigidBodyIndex > 0 ) )
{ {
try
{
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedRealWorldSoundReceiverHATORigidBodyIndex - 1 ] );
VAQuat qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
pVACore->SetSoundReceiverRealWorldTorsoOrientation( iTrackedReceiverID, qOrientRaw );
}
catch( ... )
{
}
} }
} }
...@@ -136,12 +182,14 @@ CVAMatlabTracker::CVAMatlabTracker() ...@@ -136,12 +182,14 @@ CVAMatlabTracker::CVAMatlabTracker()
void CVAMatlabTracker::Reset() void CVAMatlabTracker::Reset()
{ {
iTrackedSoundReceiverID = -1; iTrackedSoundReceiverID = -1;
iTrackedSoundReceiverRigidBodyIndex = 1; iTrackedSoundReceiverHeadRigidBodyIndex = 1;
iTrackedSoundReceiverTorsoRigidBodyIndex = 1;
vTrackedSoundReceiverTranslation.SetToZeroVector(); vTrackedSoundReceiverTranslation.SetToZeroVector();
qTrackedSoundReceiverRotation.SetToNeutralQuaternion(); qTrackedSoundReceiverRotation.SetToNeutralQuaternion();
iTrackedRealWorldSoundReceiverID = -1; iTrackedRealWorldSoundReceiverID = -1;
iTrackedRealWorldSoundReceiverRigidBodyIndex = 1; iTrackedRealWorldSoundReceiverRigidBodyIndex = 1;
iTrackedRealWorldSoundReceiverTorsoRigidBodyIndex = 1;
vTrackedRealWorldSoundReceiverTranslation.SetToZeroVector(); vTrackedRealWorldSoundReceiverTranslation.SetToZeroVector();
qTrackedRealWorldSoundReceiverRotation.SetToNeutralQuaternion(); qTrackedRealWorldSoundReceiverRotation.SetToNeutralQuaternion();
......
...@@ -38,12 +38,14 @@ public: ...@@ -38,12 +38,14 @@ public:
IVAInterface* pVACore; //!< Pointer to (networked) core instance IVAInterface* pVACore; //!< Pointer to (networked) core instance
int iTrackedSoundReceiverID; //!< -1 if deactivated, will be preferred over source int iTrackedSoundReceiverID; //!< -1 if deactivated, will be preferred over source
int iTrackedSoundReceiverRigidBodyIndex; //!< Starts with 1 (default) int iTrackedSoundReceiverHeadRigidBodyIndex; //!< Starts with 1 (default)
int iTrackedSoundReceiverTorsoRigidBodyIndex; //!< Starts with 1 (default)
VistaVector3D vTrackedSoundReceiverTranslation; //!< Position offset from pivot point (default NatNet rigid body barycenter) VistaVector3D vTrackedSoundReceiverTranslation; //!< Position offset from pivot point (default NatNet rigid body barycenter)
VistaQuaternion qTrackedSoundReceiverRotation; //!< Orientation rotation from default orientation (initial NatNet rigid body orientation) VistaQuaternion qTrackedSoundReceiverRotation; //!< Orientation rotation from default orientation (initial NatNet rigid body orientation)
int iTrackedRealWorldSoundReceiverID; //!< -1 if deactivated int iTrackedRealWorldSoundReceiverID; //!< -1 if deactivated
int iTrackedRealWorldSoundReceiverRigidBodyIndex; //!< Starts with 1 (default) int iTrackedRealWorldSoundReceiverRigidBodyIndex; //!< Starts with 1 (default)
int iTrackedRealWorldSoundReceiverTorsoRigidBodyIndex; //!< Starts with 1 (default)
VistaVector3D vTrackedRealWorldSoundReceiverTranslation; //!< Position offset from pivot point (default NatNet rigid body barycenter) VistaVector3D vTrackedRealWorldSoundReceiverTranslation; //!< Position offset from pivot point (default NatNet rigid body barycenter)
VistaQuaternion qTrackedRealWorldSoundReceiverRotation; //!< Orientation rotation from default orientation (initial NatNet rigid body orientation) VistaQuaternion qTrackedRealWorldSoundReceiverRotation; //!< Orientation rotation from default orientation (initial NatNet rigid body orientation)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment