Robotics CITS3241Exercise Sheet 4: Dressing Up Your Robot With Parametric SurfacesModify your puma forward kinematics function, puma3dof, to produce a picture like this!
MATLAB has provision for generating and drawing parametrically defined surfaces. A parametric surface is parameterized by two independent variables, i and j, which vary continuously over a rectangle. You can then specify functions x(i,j), y(i,j) z(i,j) which determine the way in which x, y and z coordinates vary with i and j over the surface. For example, the surface of the earth is parameterized in terms of longitude and latitude. You can draw a map of the earth as a flat rectangle, but at each longitude and latitude we can determine the x, y and z values that correspond to the actual location of that point in space.
In discrete terms, MATLAB represents parametric surfaces in terms of 2D arrays of X, Y and Z values that correspond to each (i, j) grid point on the surface. You can draw a parametrically defined surface in MATLAB using: surf(X,Y,Z)where X, Y and Z are matrices, defining x, y and z at each grid point over the surface. (Do a help on surf for more details). Actually it is much nicer to draw your surface using Lambertian shading under a lighting model using surfl(X,Y,Z), shading interp I have created the functions xcylinder.m and zcylinder.m which generate parametric surfaces of cylinders aligned with the x and z axes respectively for you to use. You should also download the functions superquad.m and transsurf.m as these are needed by the functions above. You may want to study and understand these function as they use some constructs and syntax that you may find useful elsewhere. Your task:Use these functions to construct and transform cylinders to represent the links and joints of your puma arm. Take care which coordinate frame each link's cylinder is attached to, and note where the origins of the frames are too. I suggest that you don't have too many sides on your cylinders (20 is plenty). Otherwise your images may take a while to render. Your puma3dof function should also be modified to take an extra argument to control the display of coordinate frames at the joints.
puma3dof(theta1, theta2, theta3, coordframe)
coordframe - An optional parameter to control display of the joint
coordinate frames.
0 - No frames displayed.
1 - Coordinate frames 0, 1, 2 and 3 are displayed
If omitted coordframe defaults to 0.
At this stage the link lengths, offsets, link diameters, etc can be simply specified
as fixed values within your function. However set these values as parameters that are
set up at the beginning of your function. For example
offset1 = 2; length1 = 0; twist1 = pi/2; linkdiameter = 0.2; etc etcThis way if you wish to change a parameter there is only one location in your code that needs to be changed. The shading pattern across your surfaces that you obtain through SURFL is Lambertian. That is, the brightness of each point in the image is proportional to the cosine of the angle between the surface normal and the incident light at each point. When the light is shining directly on a surface one obtains full brightness (cos(0) = 1) which reduces to zero where the incident light is tangential to a surface (cos(pi/2) = 0). Matte paint and sand dunes are approximations of Lambertian surfaces. The Moon, as viewed from Earth, is an interesting example of a non Lambertian surface. You can also experiment with different colormaps. I rather like the `copper' colormap colormap(copper);Do a help on graph3d to see the other possibilities. Also modify your stanford3dof code to produce a rendered image like this
stanford3dof(theta1, theta2, offset3, coordframe)
|
|
Copyright © 2002-2007 School of Computer Science & Software Engineering, The University of Western Australia. |
![]() |