Greetings, everybody!
Salutations! My name is Shivam Bajpai and I am a Master of Science student in Aerospace Engineering here at the University of Cincinnati. With the help of Simulink and a TurtleBot3, I'm creating a path tracking algorithm. Incorporating real-time pose data from my TurtleBot3 utilizing an Optitrack motion capture equipment is essential for effectively testing my algorithm.
Optitrack and MATLAB are both linked to my local network, and I had already configured them to broadcast data. But getting Optitrack and Simulink to communicate reliably is a real challenge.
I need some help getting the Optitrack live posture data into MATLAB/Simulink. It would be much appreciated if you could provide some code samples or recommendations.
The Importance of Optitrack Data for Path Tracking in MATLAB/Simulink
-
- Posts: 1
- Joined: Sun May 05, 2024 9:07 pm
- Location: https://gorillatag.io/
Re: The Importance of Optitrack Data for Path Tracking in MATLAB/Simulink
% Add the NatNet SDK library path io games
addpath('path_to_NatNet_SDK');
% Create a NatNet client
client = NatNetClient();
% Connect to the OptiTrack server
client.Connect('127.0.0.1', '127.0.0.1'); % Adjust IP as needed
% Define a callback function to handle data
function poseCallback(data)
% Extract position and orientation from data
position = data.Position; % [x, y, z]
orientation = data.Orientation; % [qx, qy, qz, qw]
% Process the data (e.g., store or visualize)
disp(['Position: ', num2str(position)]);
disp(['Orientation: ', num2str(orientation)]);
end
% Subscribe to the data stream
client.Subscribe(@poseCallback);
% Start receiving data
disp('Receiving data... Press Ctrl+C to stop.');
% Keep the script running
while true
pause(0.1); % Adjust the pause duration as needed
end
addpath('path_to_NatNet_SDK');
% Create a NatNet client
client = NatNetClient();
% Connect to the OptiTrack server
client.Connect('127.0.0.1', '127.0.0.1'); % Adjust IP as needed
% Define a callback function to handle data
function poseCallback(data)
% Extract position and orientation from data
position = data.Position; % [x, y, z]
orientation = data.Orientation; % [qx, qy, qz, qw]
% Process the data (e.g., store or visualize)
disp(['Position: ', num2str(position)]);
disp(['Orientation: ', num2str(orientation)]);
end
% Subscribe to the data stream
client.Subscribe(@poseCallback);
% Start receiving data
disp('Receiving data... Press Ctrl+C to stop.');
% Keep the script running
while true
pause(0.1); % Adjust the pause duration as needed
end