# Basics of Robot Kinematics

Publish Date: Dec 03, 2009 | 9 Ratings | 4.00 out of 5 |  PDF

## Overview

This tutorial provides an introduction to the Robotic Arm VIs included in the LabVIEW Robotics VIs palette. The Robotic Arm VIs are derived from robotics software previously developed by Peter Corke (www.petercorke.com/robot). Two examples are created in this tutorial – one for calculating the forward kinematics of a robotic arm and one for calculating the inverse kinematics of the same arm. John Craig’s textbook, Introduction to Robotics: Mechanics and Control, provides a detailed description of manipulator kinematics, dynamics, and control. A robotic arm is made up of links which are connected to each other with joints. Forward kinematics involves calculating the position and orientation of the robot end-effector given a set of prescribed joint angles. Inverse kinematics involves calculating a set of joint angles given a desired position and orientation of the end-effector. In this tutorial, LabVIEW is used to study the forward and inverse kinematics for a six degree-of-freedom Puma 560 robot used in many laboratory environments. This tutorial includes an attached .zip file with the Puma 560 kinematic and dynamic description VI as well as completed VIs. Additional kinematic and dynamic description VIs will be made available on ni.com in the future. A Puma 560 robot video is on YouTube.

### Forward Kinematics

1.       Create a new VI.

2.       Save the VI as My Kinematics Example VI.

3.       Right-click on the block diagram and navigate to Robotics»Robotic Arm»Kinematics and drag the Forward Kinematics VI onto the block diagram.

4.       Hover over the left side of the Forward Kinematics VI until the wiring tool appears and the joint positions input is highlighted.  Right-click on the joint positions input and select Create»Control.

5.       A joint positions array is created with uninitialized elements which looks like this on the front panel:

6.       To initialize the elements in the array to zeros, click inside each element and replace the dimmed 0 with a 0 that you type in.  Later in this tutorial, you will check the numeric result of the forward kinematics calculation for all of the joint positions equal to zero.  After this time, you will be able to change the joint positions to nonzero values, positive or negative, and observe different results.   The joint positions array should now look like this:

7.       Unzip the files attached to this tutorial and save them on your computer.  Drag the Create Puma560 VI from a folder on your computer directly to the block diagram.

8.       Wire the Puma560 Robot output of the Create Puma560 VI to the serial arm in input of the Forward Kinematics VI.  If you hover over the wire that is created, you will see that it is a Puma560 Robot class.  The Create Puma560 VI uses the Serial Arm Definition VIs to generate serial arm LabVIEW class objects.

9.       Hover over the right side of the Forward Kinematics VI until the wiring tool appears and the end effector transform output is highlighted.  Right-click on the end effector transform output and select Create»IndicatorThe end effector transform matrix is created on the front panel.  The homogeneous transform represents the position of the robotic arm end-effector given the joint positions.

10.       Your VI should now look like this:

11.       Run the VI to show numeric results for the end-effector transform matrix given a zero angle pose (all of the joint angles set to zero):

12.       Navigate to Robotics»Robotic Arm»Plots and drag the Initialize Plot VI to the block diagram.

13.       Connect the serial arm out output of the Forward Kinematics VI to the serial arm in input of the Initialize Plot VI.

14.       Go to Robotics»Robotic Arm»Plots and drag the Update Plot VI to the block diagram.

15.       Connect the serial arm out output of the Initialize Plot VI to the serial arm in input of the Update Plot VI.

16.       Hover over the joint positions wire until you see the wiring tool.  Connect the joint positions wire to the joint positions input of the Update Plot VI.

17.       Right-click on the front panel of the VI to display the Controls palette.

18.       On the Controls palette, navigate to Modern»Graph»3D Picture and drag the 3D Picture onto the front panel.  Make the 3D Picture large enough to fill up half of the front panel.

19.       Right-click on the 3D Picture on the front panel and select Camera Controller»Spherical

20.       On the block diagram, wire the 3D Picture to the serial arm scene output of the Update Plot VI.

21.    Go to Programming»Structures»While Loop and place a While Loop on the diagram around the existing code.

22.   Hover over the Loop Condition terminal at the bottom right of the loop, right-click, and select Create Control to put a Stop button on the front panel for the VI.

23.   The block diagram of your VI should look like this:

24.       Run the VI.  Adjust the 3D Picture control orientation of the robot on the front panel by left-clicking on it and dragging.  Adjust the 3D Picture control sizing for the robot by left-clicking while holding down the Shift key.  Adjust the placement of the robot by left-clicking while holding down the Ctrl key.  The front panel should look like this:

25.       Now, put in pi (3.14) for the 3rd joint position and the 3D Picture should now look like:

### Inverse Kinematics

1.       Save  My Kinematics Example VI created in the last section as My Inverse Kinematics Example VI

2.       Delete the following from the block diagram: joint positions, Forward Kinematics VI, and end effector transform.

3.       Hit Ctrl+B to clean up the broken wires.

4.       Delete the wires connecting Initialize Plot VI to Update Plot VI

5.       Move Create Puma560 VI and Initialize Plot VI to outside of the While Loop.

6.       Connect the serial arm out output of the Create Puma560 VI to the serial arm in input of the Initialize Plot VI

7.       Navigate to Robotics»Robotic Arm»Kinematics and drag theInverse Kinematics VI onto the block diagram.

8.       Connect the serial arm out output of the Inverse Kinematics VI to the serial arm in input of the Update Plot VI.

9.       Connect the serial arm out output of the Initialize Plot VI to the serial arm in input of the Inverse Kinematics VI.

10.   Your block diagram should look like the following:

11.       Navigate to Robotics»Robotic Arm»Homogenous Transforms and drag the Create Transform from Translation VI onto the block diagram.

12.       On the front panel, right-click to display the Controls palette.  Navigate to Modern»Numeric»Horizontal Pointer Slide and drag a Horizontal Pointer Slide onto the front panel.  While the name of the slide is highlighted, change it to x.

13.       Select the x slider on the front panel by drawing a box around it and copy it by pressing Ctrl+C.  Press Ctrl+V to paste the copy of the slider onto the front panel.  Label this slider as y.  Paste again and label the next slider as z.

14.       On the block diagram, wire the x, y, and z sliders to the x, y, and z inputs of the Create Transform from Translation VI.  These sliders represent the desired position of the end effector.

15.       On the front panel, click on the minimum number for the x slide and change it to 0.25.  Change the maximum number for the x slide to 0.5.  Repeat the process for the y slide with the same minimum and maximum values.

16.       On the front panel, change the minimum value for the z slide to be -0.5 and the maximum value to be 0.5.  The units for x, y, and z are meters.

17.       Wire the transform output of the Create Transform from Translation VI to the end effector transform input of the Inverse Kinematics VI.

18.       Hover over the current joint positions input of the Inverse Kinematics VI, then right-click and select Create»Constant.

19.       Drag the array constant outside of the While Loop.  The wire connecting the constant to Inverse Kinematics VI will break but that is okay.  Hit Ctrl+B to clean up the broken wires.

20.       Expand the array until 6 elements are shown.  Initialize the array to be zeros for each element.

21.       Right-click on the While Loop and select Add Shift Register.

22.       Wire the array constant to the shift register on the left-hand side of the While Loop

23.   Connect the shift register on the left-hand side of the While Loop to the current joint positions input of the Inverse Kinematics VI.

24.   Connect the joint positions output of the Inverse Kinematics VI to the joint positions input of the Update Plot VI.  Also, connect the wire you have just created to the shift register on the right-hand side of the While Loop.  This will update the current joint positions input for each iteration of the While Loop.

25.   Right-click on the diagram, navigate to Programming»Timing and drag Wait Until Next ms Multiple VI to the diagram.

26.   Right-click on the millisecond multiple input of the Wait Until Next ms Multiple VI and select Create»Constant.

27.   Click inside the constant and change it to 100.

28.   The block diagram and front panel of your VI should look like:

29.       Run the VI and adjust the 3D Picture control using the procedure described in step 29 of the Forward Kinematics section earlier in the tutorial.  The front panel of the VI should look like the version shown below.

30.       Adjust the x, y, and z sliders one at a time to change the position of the end effector.  The VI solves the inverse kinematics of the robot to determine the joint positions required to achieve the desired position of the end effector.  If desired, the calculated joint positions may be displayed on the front panel of the VI.

The Robotic Arm VIs will work with LabVIEW Real-Time and can be used to design, prototype, and deploy control systems for custom or off-the-shelf manipulators.  In addition, the Robotic Arm VIs can be used with the LabVIEW Control Design and Simulation Module for offline simulation or for prototyping and deployment of advanced control systems.  The Robotic Arm VIs can also be used with the NI SoftMotion Development Module and NI hardware.