From 0de388fde3830100d556ac258c557836a8117441 Mon Sep 17 00:00:00 2001 From: "geunee20@gmail.com" Date: Thu, 10 Feb 2022 17:26:03 -0500 Subject: [PATCH 1/3] v2 for udpport instead of udp --- netFT_getFreshData.m | 15 +++++++++------ netFT_getOffset.m | 8 ++++---- netFT_openConnection.m | 8 ++------ netFT_startStreaming.m | 8 +++++--- netFT_stopStreaming.m | 6 ++++-- 5 files changed, 24 insertions(+), 21 deletions(-) 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 From d1276ec4ccd65552f05c05fe775a25664eb22c6a Mon Sep 17 00:00:00 2001 From: "geunee20@gmail.com" Date: Fri, 11 Feb 2022 14:32:34 -0500 Subject: [PATCH 2/3] updated for get the most recent data as possible, reduce error --- netFT_getFreshData.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netFT_getFreshData.m b/netFT_getFreshData.m index 17ebc3e..50649aa 100644 --- a/netFT_getFreshData.m +++ b/netFT_getFreshData.m @@ -5,7 +5,7 @@ % 13:16 = Fx / 17:20 = Fy / 21:24 = Fz % 25:28 = Tx / 29:32 = Ty / 33:36 = Tz -flush(u, "input") +flush(u, "output") data = read(u, 36); ftdata = netFT_DataConversion(data) - ft_offset; From 071068dbcd390efed409b836ed82da27d6bbd499 Mon Sep 17 00:00:00 2001 From: "geunee20@gmail.com" Date: Fri, 11 Feb 2022 14:54:33 -0500 Subject: [PATCH 3/3] constant value for stability --- netFT_getFreshData.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netFT_getFreshData.m b/netFT_getFreshData.m index 50649aa..17ebc3e 100644 --- a/netFT_getFreshData.m +++ b/netFT_getFreshData.m @@ -5,7 +5,7 @@ % 13:16 = Fx / 17:20 = Fy / 21:24 = Fz % 25:28 = Tx / 29:32 = Ty / 33:36 = Tz -flush(u, "output") +flush(u, "input") data = read(u, 36); ftdata = netFT_DataConversion(data) - ft_offset;