forked from Modi1987/KST-Kuka-Sunrise-Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetMeasuredTorqueAtJoint.m
50 lines (40 loc) · 1.08 KB
/
getMeasuredTorqueAtJoint.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [ torque ] = getMeasuredTorqueAtJoint( t,k )
%% This function is used to get the measured torque at some joint, for the KUKA iiwa 7 R 800.
%% Syntax:
% [ torque ] = getMeasuredTorqueAtJoint( t,k )
%% About:
% This function is used to get torque measurment form the torque sensor of
% some joint of the robot.
%% Arreguments:
% t: is the TCP/IP connection
% k: is joint index. A number from 1 to 7.
% torque: is the value of the torque measured at joint (k) due to external
% force/moment acting on the robot. Unit (Newton.meter)
% Copyright, Mohammad SAFEEA, 11th of May 2017
if(k>7)
disp('Error KUKA has only 7 joints');
return;
end
if(k<1)
return;
end
theCommand='Torques_m_J';
fprintf(t, theCommand);
message=fgets(t);
torques=getDoubleFromString(message);
torque=torques{k};
end
function jPos=getDoubleFromString(message)
n=max(max(size(message)));
j=0;
numString=[];
for i=1:n
if message(i)=='_'
j=j+1;
jPos{j}=str2num(numString);
numString=[];
else
numString=[numString,message(i)];
end
end
end