-
Notifications
You must be signed in to change notification settings - Fork 68
/
setJointPos.m
47 lines (36 loc) · 1.45 KB
/
setJointPos.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
function [] = setJointPos(KinDynModel,jointPos)
% SETJOINTPOS sets the joints configuration for kino-dynamic computations.
%
% This matlab function wraps a functionality of the iDyntree library.
% For further info see also: https://github.com/robotology/idyntree
%
% FORMAT: [] = setJointPos(KinDynModel,jointPos)
%
% INPUTS: - jointPos: [ndof x 1] vector representing the joints
% configuration in radians;
% - KinDynModel: a structure containing the loaded model and additional info.
%
% Author : Gabriele Nava ([email protected])
%
% SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
% SPDX-License-Identifier: BSD-3-Clause
%% ------------Initialization----------------
% Debug input
if KinDynModel.DEBUG
disp('[setJointPos]: debugging inputs...')
% check joints position vector size
if length(jointPos) ~= KinDynModel.NDOF
error('[setJointPos]: the length of jointPos is not KinDynModel.NDOF')
end
disp('[setJointPos]: done.')
end
for k = 0:length(jointPos)-1
KinDynModel.kinematics.jointPos_iDyntree.setVal(k,jointPos(k+1));
end
% set the current joint positions
ack = KinDynModel.kinDynComp.setJointPos(KinDynModel.kinematics.jointPos_iDyntree);
% check for errors
if ~ack
error('[setJointPos]: unable to set the joint positions.')
end
end