Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions netFT_getFreshData.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
function [ ftdata ] = netFT_getFreshData( u, ft_offset )
%get the most recent force/torque data from the sensor and return after
%offset compensation
% get the most recent force/torque data from the sensor and return after
% offset compensation
% 1:4 = rdt_sequence / 5:8 = ft_sequence / 9:12 = status
% 13:16 = Fx / 17:20 = Fy / 21:24 = Fz
% 25:28 = Tx / 29:32 = Ty / 33:36 = Tz

flushinput(u)
data = fscanf(u);
ftdata = netFT_DataConversion(data)-ft_offset;
end
flush(u, "input")
data = read(u, 36);
ftdata = netFT_DataConversion(data) - ft_offset;

end
8 changes: 4 additions & 4 deletions netFT_getOffset.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
%get offsets and return as 1x6 vector

ft_offset = zeros(1,6);
for i = 1:numOffsetSamples
ft_offset = ft_offset + netFT_getFreshData(u,0)/numOffsetSamples;
end
end
for i = 1:numOffsetSamples
ft_offset = ft_offset + netFT_getFreshData(u,0) / numOffsetSamples;
end

end
8 changes: 2 additions & 6 deletions netFT_openConnection.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
function [ u ] = netFT_openConnection( )
%Open and return a UDP connection to the Sensor

netFT = '192.168.1.1';
port = 49152;
u = udp(netFT,port);
fopen(u);
end

u = udpport('byte', 'IPV4');
end
8 changes: 5 additions & 3 deletions netFT_startStreaming.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
function [ ] = netFT_startStreaming( u )
%send the start streaming command
% send the start streaming command

startRequest = ['12';'34';'00';'02';'00';'00';'00';'00'];
startCommand = hexlistToString(startRequest);
fwrite(u, startCommand) % send message to start rdt streaming
end
netFT = "192.168.1.1";
port = 49152;
write(u, startCommand, "string", netFT, port) % send message to start rdt streaming

end
6 changes: 4 additions & 2 deletions netFT_stopStreaming.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

stopRequest = ['12';'34';'00';'00';'00';'00';'00';'00'];
stopCommand = hexlistToString(stopRequest);
fwrite(u, stopCommand) % send message to stop rdt streaming
end
netFT = "192.168.1.1";
port = 49152;
write(u, stopCommand, "string", netFT, port) % send message to stop rdt streaming

end