Pick and place with Matlab

V.1.1

Pick and place Matlab Banner

Difficulty: hard

Time: ~45 min

Note

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

Introduction

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

Objectives

  • 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.

Requirements

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

Rosinit Setup

Rosinit setup

Otherwise, do this tutorial first.

Hint

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

What you will need

Note

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
rosinit(ipaddress)

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:

Note

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