How to interface Natural Point Motive (NatNet) with Simulink model?

20 visualizaciones (últimos 30 días)
I need to create interface between Simulink to Motive I already succeed to interface between Matlab and Motive through NatNet, I reviewed the sample available with NatNet SDK to do so but I'm having trouble to migrate it to Simulink, I tried using Matlab function block unsuccessfully, it's have problem to use the dll command.
the error i got from Simulink is : Undefined function or variable 'NatNetML.NatNetClientML'.
I want to thanks Glen Lichtwark sample that helped me writing interface to matlab http://www.mathworks.com/matlabcentral/fileexchange/26449-tracking-tools--optitrack-
the code i tried is the follwing:
function [x,y,z,yaw,pitch,roll] = Location_Orinteation_Motive_64bit(RigidBody_ID) %#codegen
coder.extrinsic('–sync:on','quaternion','fullfile','NET.addAssembly','addpath')
dllPath = fullfile('c:','NatNetSDK2.5','lib','x64','NatNetML.dll');
assemblyInfo = NET.addAssembly(dllPath);
addpath('E:\Motive')
dllPath = fullfile('c:','NatNetSDK2.5','lib','x64','NatNetML.dll');
assemblyInfo = NET.addAssembly(dllPath);
theClient = NatNetML.NatNetClientML(0); % Input = iConnectionType: 0 = Multicast, 1 = Unicast
% Connect to an OptiTrack server (e.g. Motive)
HostIP = char('127.0.0.1');
theClient.Initialize(HostIP, HostIP); % Flg = returnCode: 0 = Success
% data
frameOfData = theClient.GetLastFrameOfData()
rigidBodyData = frameOfData.RigidBodies(RigidBody_ID)
x=rigidBodyData.x
y=rigidBodyData.y
z=rigidBodyData.y
% angle
q = quaternion( rigidBodyData.qx, rigidBodyData.qy, rigidBodyData.qz, rigidBodyData.qw ); % extrnal file quaternion.m
qRot = quaternion( 0, 0, 0, 1); % rotate pitch 180 to avoid 180/-180 flip for nicer graphing
q = mtimes(q, qRot);
angles = EulerAngles(q,'zyx');
yaw = angles(2) * 180.0 / pi;
pitch = -angles(1) * 180.0 / pi; % must invert due to 180 flip above
roll = -angles(3) * 180.0 / pi; % must invert due to 180 flip above
thanks Or Hirshfeld

Respuesta aceptada

Or Hirshfeld
Or Hirshfeld el 26 de Abr. de 2015
  1 comentario
dhenke
dhenke el 12 de Feb. de 2016
How were you able to get that API to run? When I try all I get are errors.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Verification, Validation, and Test en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by