Find endpoints of 3D arm links
0 solutions submitted (max: Unlimited)
Use the vector and rotation functions you created above to find the endpoints of the links in a 3D arm.
In addition to standard Matlab functions, your code may assume that you have access to the functions you created in previous assignments (some of these you will call directly in this assignment, some will only be called by other functions that you call). Remember that for these functions, the grading script will use the instructor's copy of the functions:
vector_set_rotate
vector_set_cumulative_sum
rotation_set_cumulative_product
threeD_rotation_set
Rz
Ry
Rx
Function
function [link_ends,…
R_joints,…
R_links,…
link_vectors_in_world,…
link_end_set,…
link_end_set_with_base] = threeD_robot_arm_endpoints(link_vectors,joint_angles,joint_axes)
% Take a set of link vectors and joint angles, and return a matrix whose
% columns are the endpoints of all of the links (including the point that
% is the first end of the first link, which should be placed at the
% origin).
%
% Inputs:
%
% link_vectors: a 1xn cell array, each element of which is a 2x1 vector
% describing the vector from the base of the corresponding link to
% its end
% joint_angles: a nx1 vector, each element of which is the joint angle
% preceeding the corresponding link
% joint_axes: a nx1 cell array, each entry of which is 'x','y', or 'z',
% designating the axis of the corresponding joint
%
% Outputs:
%
% link_ends: a 3x(n+1) matrix, whose first column is the location
% of the base of the first link (which should be at the origin), and
% whose remaining columns are the endpoints of the links
%
% Additional outputs (These are intermediate variables. Having the option
% to return them as outputs lets our automatic code checker tell you
% where problems are in your code):
%
% R_joints: The rotation matrices associated with the joints
% R_links: The rotation matrices for the link orientations
% link_vectors_in_world: The link vectors in their current orientations
% link_end_set: The endpoints of the links after taking the cumulative
% sum of link vectors
%%%%%%%%
% First, generate a cell array named 'R_joints' that contains a set of
% rotation matrices corresponding to the joint angles
%%%%%%%%
% Second, generate a cell array named 'R_links' that contains the
% orientations of the link frames by taking the cumulative products of
% the joint rotation matrices
%%%%%%%%
% Third, generate a cell array named 'link_vectors_in_world' that
% contains the link vectors rotated by the rotation matrices for the
% links
%%%%%%%%
% Fourth, generate a cell array named 'link_end_set' that contains the
% endpoints of each link, found by taking the cumulative sum of the
% link vectors
%%%%%%%%
% Fifth, add a cell containing a zero vector (for the origin point at
% the base of the first link) to the beginning oflink_end_set, saving
% the result in a cell array named 'link_end_set_with_base'
%%%%%%%%
% Sixth, convert the set of link vectors to a simple matrix using the
% [A{:}] syntax (using this syntax instead of the cell2mat command will
% allow us to use symbolic math in a later assignment)
end
1
2
3
4
5
6
7
8
9
10
11
12
Code to call your function
link_vectors = {[1;0;0],[1;0;0]};
joint_angles = [pi/4; -pi/2];
joint_axes = {'x','z'};
[link_ends,…
R_joints,…
R_links,…
link_vectors_in_world,…
link_end_set,…
link_end_set_with_base] = threeD_robot_arm_endpoints(link_vectors,joint_angles,joint_axes)
1
2
3
4
5