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

조회 수: 18 (최근 30일)
Or Hirshfeld
Or Hirshfeld 2014년 10월 6일
댓글: dhenke 2016년 2월 12일
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일
  댓글 수: 1
dhenke
dhenke 2016년 2월 12일
How were you able to get that API to run? When I try all I get are errors.

댓글을 달려면 로그인하십시오.

추가 답변 (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