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

18 次查看(过去 30 天)
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

采纳的回答

Or Hirshfeld
Or Hirshfeld 2015-4-26

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Verification, Validation, and Test 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by