Last Updated on Friday, 28 October 2011 13:04 Written by Administrator Saturday, 08 May 2010 04:39
This tutorial will discuss some of the basic steps in creating a virtual robot control and simulation environment in Matlab

Dim lights Embed Embed this video on your site
Part 1: Using 3D graphics in Matlab
Matlab has several convenient tools to create 3D graphics, in general built on window open GL. The command we will use is the patch command. Everything you would ever want to know about patch can be found in the matlab helpdesk. We will use the following form of the patch command to draw and object:
» patch(‘Vertices’,vertices_link1,’Faces’,faces_link1,’faceColor’,[RGB values])
One final note is made in defining these objects. Each object is defined relative to its own frame and has an origin location. Subsequent rotation operations will act on this frame and about this origin. Therefore, locate the origin and z axis of the body to align with a joint that could be envisioned on the body.
Part 2: Manipulating 3D objects in Matlab:
Once the objects are created, they can easily be manipulated by operating on the vertices with rigid body transformations (rotation + translastion). Each vertex (corresponding to each row in the vertex matrix) is operated on. A few lines of pseudo code demonstrating this process follow:
For i=1 to # of rows of vertex_link1
vertex_link1(i,:) = (R *vertex_link_o(i,:)’)’ + d
end
where R is 3x3 rotation matrix, d is the 3x1 translation vector, and the ‘ indicates transpose. Note that the rotation operation provides a rigid body rotation to all vertices about the origin of the object, and the translation provides a rigid body translation or offset to all points
Part 3: Animating a robot move
Animation is simply a sequence of rigid body motions performed in a continuous manner. This can be performed by embedding the transformation and drawing commands in a loop that slowly increments the amount of rotation/translation. A few side notes on animation;
Part 4: Path/Trajectory generation
A nice feature you can add to your program would plot the path of end effector over a given move. This can be performed by saving the end effector positions in a matrix (each row a new position) and then using the plot3 command to plot these points. If you plot the current tool position matrix each time in your animation, you can generate the trajectory curve in real time.
Part 5: Inverse Kinematic control
With the inverse kinematics for a manipulator solved, you can use these equations to find the inputs (joint angles) necessary to plot your robot. You can define a trajectory in terms of a tool space move, say a straight-line move of the end effector, and then animate your robot over this move. As an example, say you define a 200 cm straightline move for the tool to occur over 5 seconds. You would like to show 10 frames per second. Divide the total move by the total number of frames to show (200/(5*10) = 4) to get the step size in tool space. Start the tool at 0, calculate the IK’s and draw the robot. Pause .1 seconds, move the tool to 4 cms, calculate the IK’s and redraw the robot. Continue until you have reached the final position of 200 cm.
Robots Simulation in Matlab
Dynamic simulation of Puma robot collapsing under gravity

Dim lights Embed Embed this video on your site
.
Cartesian space control

Dim lights Embed Embed this video on your site
.
Torque feedforward control

Dim lights Embed Embed this video on your site
.
2-link robot with flexible transmission

Dim lights Embed Embed this video on your site