I have a homework question that I cannot answer. Here is the question prompt:
- Define Eq. 8.3 and Eq. 8.4 in a function. This function should take a vector of joint angles (
and
) as input and should return a column vector containing the two functions (
and
) evaluated at those angles. The function should contain the link lengths and values of
and
for calculation. Include your code in your solution.
Equations 8.3 and 8.4 are:
(8.3)
(8.4)
where
Here is the function I wrote:
function F = rob_arm (alphag, betag)
F = (1).*cos(alphag)+ (1).*(cos(alphag+betag))-(1) ;
(1).*sin(alphag) + (1).*(sin(alphag+betag))-(1.1) ;
end
Because alpha
and beta
are matrices of different sizes, I used meshgrid
to create alphag
and betag
, and used those matrices to calculate the values of rob_arm
. After four hours of messing with this, I'm not even sure what the question is asking anymore, and the TA's are not currently answering emails. I wrote the following code, to try and force rob_arm
into a single column:
alpha = 0:pi/100:(pi/2); %define angle alpha
beta = 0:pi/100:pi; %define angle beta
[alphag, betag] = meshgrid (alpha, beta); %mesh grid alpha and beta b/c different matrix dimensions
arm_pos = rob_arm (alphag, betag);
for ii = 1:1:101
for k = 1:1:51
col_vec (1,1:1:5151) = arm_pos(ii,k);
end
end
Ignoring the query to create a column vector, the resulting output, arm_pos
is good output. I can graph it and I get a very pretty picture of all the possible points that this robot arm can 'reach.'
But because I am dumb and have been trying this for many hours, it's not saving successive values of rob_arm
into col_vec
, it just replaces it each time and I end up with a 1x1 matrix. Ultimately, the goal will be to use the Newton-Raphson method to determine the zeroes of this function, but that's a long ways off. I am thinking if I can get all of the values calculated by rob_arm
into a single column, then I can answer this question.
The next question is:
- Create a separate function that accepts input of a single row vector containing the pair of angles
and
. The output of the function should be the Jacobian (a 2 by 2 matrix). First, calculate the derivatives of Eqs. 8.3 – 8.4 by hand, then put them into your function. Include your function code in your solution
Which I will need to ask for clarification on, because I don't understand how a 1 x 51 matrix (alpha
) and a 1 x 102 matrix (beta
) could be accepted into a single row vector, that would then output a 2x2 matrix. I know what the Jacobian is, and it is the partial derivitives of my two functions, not a matrix of values.
If anyone wants to give me a hand, that would be super awesome.