diff --git a/netFT_getFreshData.m b/netFT_getFreshData.m index 652fc88..17ebc3e 100644 --- a/netFT_getFreshData.m +++ b/netFT_getFreshData.m @@ -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 \ No newline at end of file diff --git a/netFT_getOffset.m b/netFT_getOffset.m index bb2d76c..07fe549 100644 --- a/netFT_getOffset.m +++ b/netFT_getOffset.m @@ -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 \ No newline at end of file diff --git a/netFT_openConnection.m b/netFT_openConnection.m index c4a3dcf..6e9077e 100644 --- a/netFT_openConnection.m +++ b/netFT_openConnection.m @@ -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 \ No newline at end of file diff --git a/netFT_startStreaming.m b/netFT_startStreaming.m index ad9580a..f1cdb8e 100644 --- a/netFT_startStreaming.m +++ b/netFT_startStreaming.m @@ -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 \ No newline at end of file diff --git a/netFT_stopStreaming.m b/netFT_stopStreaming.m index f8fe6a9..979af3b 100644 --- a/netFT_stopStreaming.m +++ b/netFT_stopStreaming.m @@ -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 \ No newline at end of file