Introduction: Control of a Simulated Robotic Arm in Matlab

About: Robotics and Automation Engineering student

In this Instructable I want to show a simple simulation I created to test a control algorithm before implementing it on the real robot and possibly destroy it.

The nice thing is that the robotic arm is completely simulated, while the inputs are given from real joystick controlled with an Arduino.


The control algorithm is an advancement of my previous, and most common, control strategy for robotic arms, where a joystick controls the angular position of every joint.

(Here is a link to my previous Instructable on how to build, connect and control the very same robot with the joysticks:

This algorithm is very simple to implement but it is also quite limited:

- The human control will be all but immediate, since your brain works with cartesian coordinates, not the angular positions of many joints of a kinematic chain.

- It might also be physically hard to control the robot, since most robotic arms have 5 or more joints and, assuming you use the 2 axis of a joystick to control 2 different joint, you will probably end up needing 3 or more joystick, which is a bit of a problem since a human being has only 2 hands.

With that in mind I developed this control algorithm, it still uses joystick but now, instead controlling the position of the servos (this is usually called joint space of the robot), it controls the coordinates of the end effector (usually called work space of the robot).

So now there is one joystick to control the x position and y position, and another joystick to control the z position and close/open of the grip: for a total of 2 joysticks, meaning only 2 thumbs!

As I said at the beginning, before implementing this code on the robot, I wanted to be sure it was safe, hence the simulator!


To create the simulated robotic arm, I will use the “Robotics Toolbox” for Matlab.

It is available for free at this link:

I also suggest this book, written by the author of the toolbox itself, which is really well written and with plenty of matlab examples, for many things:

(don’t worry it is not an amazon reference link, feel more than free to look for it on other website or mysterious sources)

In this section you can find the code I used to perform the simulation and control the joysticks and a video of the simulation itself:

To actually use this toolbox a little knowledge of robot kinematics is required. If many people show interest I may consider creating a video on YouTube (I think a video will be way more explanatory than a whole bunch of written words) that explains the functions I used and the logic behind them.

So if you are interested in that write it in the comments and subscribe to the YouTube channel so you will not miss the video!

If you have any question obviously don’t hesitate to ask them in the comments here, I will be more than happy to help you