-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathget_joint_state.m
36 lines (31 loc) · 1.24 KB
/
get_joint_state.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
% get_joint_state.m
% Copyright (C) 2018 Niryo
% All rights reserved.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
% this function read executed trajectory
function [jointStateMsg,time]=get_joint_state(handles,thero_trajectory_data,jointState)
theorTime=thero_trajectory_data.Header.Stamp.Sec+(thero_trajectory_data.Header.Stamp.Nsec)/10^9;
A=[thero_trajectory_data.Goal.Trajectory.Points(:,1).Positions];
k=size(A);
k=k(2);
array_time=[thero_trajectory_data.Goal.Trajectory.Points(:,1).TimeFromStart];
x=[array_time.Nsec]/10^9+[array_time.Sec];
jointStateMsg=rosmessage(jointState);
i=1;
time(i)=0;
while (time(i)< x(k))
i=i+1;
jointStateMsg(i)=receive(jointState);
time(i)=(jointStateMsg(i).Header.Stamp.Sec+(jointStateMsg(i).Header.Stamp.Nsec)/10^9)-theorTime;
end
for j=1:i
time(j)=time(j)-time(1);
end
time(i) = [];