forked from lyphix/High_Level_Control
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
XI LUO
committed
May 23, 2023
1 parent
354b315
commit 7eec7fb
Showing
5 changed files
with
180 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
%% Clean | ||
clc; | ||
clear; | ||
close all; | ||
|
||
%% Instantiate client object to run Motive API commands | ||
|
||
% Check list: | ||
% 1.Broadcast Frame Date | ||
% 2.Network Interface: Local Loopback | ||
|
||
% https://optitrack.com/software/natnet-sdk/ | ||
% Create Motive client object | ||
dllPath = fullfile('d:','StDroneControl','NatNetSDK','lib','x64','NatNetML.dll'); | ||
assemblyInfo = NET.addAssembly(dllPath); % Add API function calls | ||
theClient = NatNetML.NatNetClientML(0); | ||
|
||
% Create connection to localhost, data is now being streamed through client object | ||
HostIP = '127.0.0.1'; | ||
theClient.Initialize(HostIP, HostIP); | ||
|
||
Dog_ID = 1; % Rigid body ID of the drone from Motive | ||
|
||
%% initialized | ||
|
||
real_time=0; | ||
run_time=1; | ||
|
||
time=0; | ||
|
||
[init_time,x,z,yaw] = Get_Dog_Postion(theClient, Dog_ID); %[time, x, z, yaw] | ||
Dog_Pos_Record = [0,x,z,yaw]; | ||
i=1; | ||
%% Main Loop | ||
while true | ||
[time,x,z,yaw] = Get_Dog_Postion(theClient, Dog_ID); %[time, x, z, yaw] | ||
real_time=time-init_time; | ||
if ~isequal(Dog_Pos_Record(end,:),[real_time,x,z,yaw]) | ||
i=i+1; | ||
Dog_Pos_Record=[Dog_Pos_Record ; real_time,x,z,yaw]; | ||
real_time = Dog_Pos_Record(i-1,1)-Dog_Pos_Record(1,1); | ||
if real_time>run_time | ||
break | ||
end | ||
end | ||
|
||
end | ||
|
||
%% figure | ||
|
||
figure; | ||
plot(Dog_Pos_Record(:,2),Dog_Pos_Record(:,3)); | ||
xlabel('X'); | ||
ylabel('Z'); | ||
set(gca,'XDir','reverse'); | ||
xlim([-3,3]); | ||
ylim([-2,2]); | ||
daspect([1 1 1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.