Pick and place with Matlab


Pick and place Matlab Banner

Difficulty: hard

Time: ~45 min


This tutorial is working from:
The version v4.1.0 of the ned_ros_stack
The version v4.1.0 of Niryo Studio


This process consists in taking any type of object at a specific location and placing it at another location in a more orderly fashion.


  • Show one of the examples of applications you can do with Matlab and Ned/Ned2

  • Have a first approach with industrial processes which can be realized with Ned/Ned2

  • Learn the basics of Matlab programming while using the Ned/Ned2.


You have to be in this situation to start this tutorial:

Rosinit Setup

Rosinit setup

Otherwise, do this tutorial first.


We advise you to do this tutorial before starting and to practice moving the robot.

What you will need


To do this example we used Windows10, Matlab2022a and a Ned2.

Details of the script

First of all, you have to connect the robot in Wi-Fi mode and connect it with ROS.
(Normally this is already done if you have followed the previous tutorials: setup and use Ned/Ned2 with Matlab).
ipaddress = "http://IP_OF_NED:11311"; %IP of the Ned
rosshutdown; %to be sure that an other ROS network is not actually working
setenv('ROS_MASTER_URI',ipaddress) %IP of the Ned
setenv('ROS_IP','IP_HOST_COMPUTER') %IP of the computer

You have to be in this situation.

Rosinit Setup

Rosinit setup

First, try to open and close the gripper using the Ros toolbox. In the same way as for moving the robot, you must create and send a Ros message. This time the subject of the message is not a Point, but a ToolGoal.

Try to write the code yourself. If you struggle too much, you can find a code sample in the drop-down window below:

To make the program as clear as possible, make Matlab functions to call them several times easily. Here, the best way is to make one function per action (move, pick and place) in order to separate the steps (but you can also do everything together):

To complete this example, try to make a loop to repeat the movement. So you can reproduce the movement as in a production line. Here is the code:


You can find all the information concerning the use of Ned/Ned2 with Matlab and the ROS Toolbox by following the two tutorials below: