How to use joint velocities
2 views (last 30 days)
Show older comments
Hi.
I do not understand how to use the joint velocities specified in inverseDynamics documentation. jointVel
So does this mean I can specify a row vector of velocities for 'n' joints? Do I specify in meters / second?
Please give an example.
Also,I am not clear between the scenario where velocities are 0 by default and why one should define them at all.
0 Comments
Answers (2)
William Rose
on 2 Mar 2021
@NK,
The velocities should match the units used elsewhere in your model, for example the units used to specify forces and moments of inertia. So if you are using MKS units for forces and inertia, then the velocities whould be in radians/s for revolute (rotational) joints and m/s for prismatic (sliding) joints.
The length of the velocity vector equals the degrees of freedom in the model, which you can determine as the length of the torque vector, when there are no velocities specified. Here is anexampl of using inverseDynamicsto compute torques without velocities, with velocitis that are zero, with velocities that are all=1, and with velocities that are given by normal(mean=0,stdev=1) random numbers.
%inverseDynamicsRobot.m
%Compute joint torques for a simple robot, with and without joint velocities
%WCR 2021-03-02
rng(1); %fix random number generator seed for reproducible results
load exampleRobots.mat lbr %load a robot
lbr.DataFormat = 'row'; %define segments as rows (could have chosen columns)
lbr.Gravity = [0 0 -9.81]; %deifne gravity magnitude, direction
q=randomConfiguration(lbr); %randomize the joint angles
tau =inverseDynamics(lbr,q); %compute the torque vector for the random pose
jointVel=randn(1,7); %choose 7 because length(tau)=7
tau =inverseDynamics(lbr,q,jointVel); %torques with no velocities specified
jointVel0=zeros(1,7);
tauv0=inverseDynamics(lbr,q,jointVel0); %torques with velocity=0 specified
jointVel1=ones(1,7);
tauv1=inverseDynamics(lbr,q,jointVel1); %torques with velocity=1
jointVelR=randn(1,7);
tauvR=inverseDynamics(lbr,q,jointVelR); %torques with random velocities
disp([tau;tauv0;tauv1;tauvR]); %display results
The output is below:
>> inverseDynamicsRobot
0.6894 -17.6441 -5.5455 -0.4874 -0.5817 2.9946 0.5884
0.0000 -17.0954 -2.0821 -0.3977 -0.1771 1.1950 0
10.2351 -23.7290 0.4549 -8.5613 8.5743 -4.6716 4.1912
-5.0188 -25.1773 -12.4692 -7.4887 -4.0599 10.8511 9.1837
As you can see from the results above, the torques with velocity=0 (row 2 of results) is the same as when no velocities are specified (row 1) - which makes sense. The extra torque needed for non-zero velocity (rows 3 and 4) is complicated and depends on the current pose, relative to the external forces, if any (there arenone in this example), and the gravity vector. In a more realistic joint model than the one here, there would also be a frictional (also known as a damping) term in the torque, which would be proportional to (rotational) velocity. But this joint model does allow for damping.
5 Comments
William Rose
on 4 Mar 2021
@N, Weird. I just clicked on the links, in the answer posted above, and they worked fine for me. From the first link, you can find the second and third, by scrolling down. The first one is
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/538671/image.jpeg)
.
William Rose
on 4 Mar 2021
@N,
I'm sorry to hear that the link does not work. If you type in http://www2.ece.ohio-state.edu/~zhang/RoboticsClass/, it does not work? I do not know an alternative. Does it help if you precede the address with https://?
1 Comment
William Rose
on 4 Mar 2021
Another suggestion to access the content is to web search for "wei zhang ece5463". When I do that search on Google, or Bing, or even Yandex, the search returns links to the lectures.
See Also
Categories
Find more on Multibody Dynamics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!