# Create a Basic Robots Program

{% hint style="danger" %}
Sorry this tutorial is not finished yet!
{% endhint %}

This step-by-step article will guide you through making a basic robot program for the ABB IRB 120 at the MSD Robotics Lab. This article assumes a basic understanding of Rhino & Grasshopper.

Please make sure you have installed 'Robots' plugin for Grasshopper, if you have not, please read the instructions here:

{% content-ref url="../software/software/rhino-and-grasshopper-1/download-and-install-robots-for-grasshopper" %}
[download-and-install-robots-for-grasshopper](https://ms-kb.msd.unimelb.edu.au/msd-robotics-lab/software/software/rhino-and-grasshopper-1/download-and-install-robots-for-grasshopper)
{% endcontent-ref %}

## Create a Robot System

A **Robot System** specifies what robot we will be programming.

* Begin by opening Rhino & Grasshopper, we are going to add the robot system.
* Go to the **Robots (1)** tab in Grasshoppe&#x72;**,** select **Components (2)** and pick **Robot System (3)**.

![Load Robot System](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYdv5bjHvd5NPsjzGFe%2F-LYeDaDoLL9TXwmgZTs3%2FCreateRobotsProgram-02.png?alt=media\&token=91763ffc-b8cd-4436-860b-5b640a55014f)

* From the dropbox list **(4)** you may need to select UniMelb-IRB120
* Right click on the **Load Robot (4)** and select **preview** to turn the preview off, as this will interfere with our simulation later.

{% hint style="info" %}
If you cannot see UniMelb-IRB120 or the component is red, re-visit "Download & Install Robots for Grasshopper" and make sure you installed the **UniMelb.3dm** and **UniMelb.xml** files correctly.
{% endhint %}

## Create a Tool

We need to create a tool, we supply it with a name, a mesh, a TCP (Tool Centre Point), weight and centre of gravity.

* Go to the **Components (1)** section and click **Create Tool (2)**

![Create Tool](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYdv5bjHvd5NPsjzGFe%2F-LYeFChORhKz9ib7El_r%2FCreateRobotsProgram-03.png?alt=media\&token=e7bc9f99-7d04-4e24-a0c2-c1c790660d74)

* Next we need to create a physical tool in Rhino.
* Create a cylinder that points up that is 20mm in diameter and 100mm high, as shown below.

![Our "tool" is a cylinder](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYdv5bjHvd5NPsjzGFe%2F-LYeFnpZGnvmzEKQwSOG%2FCreateRobotsProgram-04.png?alt=media\&token=9087b8e9-aae1-4e7d-a91a-e06890eac3a4)

* Next add a **panel** and connect it to the **N (1)** of the tool component.
* Also add a **Point** parameter, and an **XY Plane** **(2)**, connect these as shown to the **P.**

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYdv5bjHvd5NPsjzGFe%2F-LYeGBG8ZriGPLbKy0nC%2FCreateRobotsProgram-05.png?alt=media\&token=7780cbc9-9beb-42b2-926d-1062276fb6b8)

* We need to set the point to the centre of the top of the cylinder as shown in this image:

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYdv5bjHvd5NPsjzGFe%2F-LYeH9ZnLyBx7DHqGvC7%2FCreateRobotsProgram-06.png?alt=media\&token=bfdab2a2-257b-47f8-8b7b-9a650b9e092f)

* Add panels for **Weight (1)** and **Centre of Gravity (2)**
* Make the weight **0.1** (this is 0.1kg) and the centre of gravity **0,0,50** (x,y,z)
* Connect the **Weight** to **W** and the **Centre of Gravity** to **C**

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYeI_z7UGsu-9-kji5b%2F-LYeJC3ODQdgpppKoDn3%2FCreateRobotsProgram-07.png?alt=media\&token=692b9083-0b1f-4169-bc27-d5a9b5b3d793)

* Finally we need to create a mesh out of our geometry.
* To do this, create a **Brep** component, a **mesh** component and a **Mesh Join** component.
* Connect them together as shown.
* Connect **Mesh Join** to the **M**
* Set **Brep** to the cylinder we previously made.

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYeI_z7UGsu-9-kji5b%2F-LYeK-QAXcomsiCa1WtN%2FCreateRobotsProgram-08.png?alt=media\&token=e2dfc97f-9526-4e08-bf02-a42ba133f913)

{% hint style="info" %}
We keep our geometry as surfaces and solids in case we need to change it. The mesh join is important to ensure the tool component only see's one mesh. Multiple meshes cause the plugin to generate multiple robot programs.
{% endhint %}

* Place a **Tool** parameter after the **Create Tool**

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYeI_z7UGsu-9-kji5b%2F-LYeLbxbc3-_8XXWJ-of%2FCreateRobotsProgram-09.png?alt=media\&token=2ac0ba23-cc01-438b-ba1d-83acd1ebf0da)

## Create a Home Position

Next we will create a Home Position, the Home Position will be where the robot moves to at the start and end of the program.

* Goto the **Robots** plugin, click **Components** and click **Create Target**

![Create a Target](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYeI_z7UGsu-9-kji5b%2F-LYeMkwNVAL0uCC7iHyB%2FCreateRobotsProgram-10.png?alt=media\&token=0b3d3749-5aa2-47bd-9cc8-d65faa988549)

* Once the **Target** component is placed. Right click on and and select **Joint Target (1)**
* A joint target allows us to specify 6 joint positions of the robot. This means we can get the robot to go to the exact same position every time.
* Also select **Speed Input (2)** and **Zone Input (3)**

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYeI_z7UGsu-9-kji5b%2F-LYePp5Q3a1Q3MhUV7W-%2FCreateRobotsProgram-11.png?alt=media\&token=68a53977-6c7f-4365-a4b8-3a48558172f3)

* Next create a **Degrees to Radians** component

![Degrees to Radians Component](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYeI_z7UGsu-9-kji5b%2F-LYeT4bMkCjTrOHQVIXh%2FCreateRobotsProgram-12.png?alt=media\&token=9c4e6707-c0cb-4927-a3ae-dc0b542cf13a)

{% hint style="info" %}
The **Degrees to Radians** component in Robots is special, and the standard Grasshopper degrees to radians component won't work. This is due to how robot manufacturers define the 0 point of their robot axes.
{% endhint %}

* Connect the Robot System to the **R** on the **Degrees to Radians** component.
* Create a **panel (1)** for the axis values. We need to make it **Multiline data (2)** by right clicking on it.
* Enter the numbers as&#x20;

```
0
5
-5
0
20
0
```

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYeI_z7UGsu-9-kji5b%2F-LYeWxCuFfGZ6bK_wlq_%2FCreateRobotsProgram-13.png?alt=media\&token=f30c6fde-d1b0-4710-ab30-fe47372aab77)

## Add Create Program Component

The create program component is what creates the program, we are doing this now so you can generate a simulation.

* Add the **Create Program (1)** component

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LYiMZzm2qdaIQbLD7p2%2F-LYj06tJOCFBMEiYJnQ6%2FCreateRobotsProgram-14.png?alt=media\&token=8f5fa358-91fb-4075-982a-93aeb0d28581)

* Create a **panel (1)** for the program name. The program name should change with each new version of code you upload to the robot. Always start with a lowercase letter and avoid spaces, use underscores instead.
* Connect the **panel** to **N (2).**
* Connect the **robot system** to **R (2).**
* Connect the **targets** to **T1 (2).**
* T1 is the first robot, while T2 would be a second robot. We only have single robots at the moment.

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LZ7DocSAMWR4dI_iHhI%2F-LZ7E3U9OrGppqKVWgJr%2FCreateRobotsProgram-15.png?alt=media\&token=25392b7e-f069-4de8-9dca-1036efa8a5ac)

## Add Program Simulation Component

The simulation component allows you to view how the robot acts and allows you to identify errors. It is a good idea to add this early on to catch errors early.

* Add the **Program Simulation** component from the robots plugin.

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LZ7DocSAMWR4dI_iHhI%2F-LZ7MCIBArBIiEiDkfm-%2FCreateRobotsProgram-16.png?alt=media\&token=44fbc0c2-d1f2-4a7a-8ab2-e8ab7f5e4501)

* Connect a **slider (1)** that goes from 0.00 to 1.00 to **T (2)**. This will be our time simulation. 0.00 being the start and 1.00 being the end of the program.
* If there is an error, 1.00 will become where the error first happens.
* Connect the **P** from the **program component** to the **P (2)** of the **simulation component**.
* After doing this, you should see a robot in&#x20;

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LZ7DocSAMWR4dI_iHhI%2F-LZ7MGhtihQO7I3KK_lR%2FCreateRobotsProgram-17.png?alt=media\&token=13b99f38-654b-452c-8ee7-330b75de2004)

## Create a Tool Path

We will create a tool path for the Robot to follow. The easiest way to do this is to create a curve and divide it into points.

* Place a **Curve (1)** parameter in Grasshopper
* Drawing an interpolated curve with **InterpCrv** **(2)** on the ground.
* Right click on the **curve (1)** componet and select **select one curve**. Then select the curve you just drew.

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LZ7DocSAMWR4dI_iHhI%2F-LZ7PsSDxhXOtLNOkD4R%2FCreateRobotsProgram-18.png?alt=media\&token=f64e5fe8-87bf-4086-954a-792c1999f3ad)

## Divide Tool Path

To divide the tool path we will use the **Divide Curve** component. There are a number of other ways to divide the curve. The point of dividing the curve is to get origins for planes. We then create a plane at that point.

* Add the **Divide Curve (1)** component.
* Connect the **Crv** parameter to the **C (1)** of the **Divide Curve** component.
* Make a **panel (2)** and connect it to the **N (1)** of the **Divide Curve** component.
* Specify the number of points you wish to divide the curve by in the **panel**. In this case we picked 20.
* Create an **XY Plane** component and connect the **P (1)** from the **Divide Curve** component to the **O (3)** of the XY Plane.

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LZ7qH_s4YU0_TkOodui%2F-LZ7qQDaW_kJNCL-UshB%2FCreateRobotsProgram-19.png?alt=media\&token=4d84e3ee-a316-4a62-83be-ab6e01bed7e2)

* Next we need to add a **Rotate Plane (1)** component. This allows us to control the rotation of the tool.
* Plug a **panel (2)** into the **A (1)** of the plane rotate. Here we lave the angle as 0 to begin with.
* Since Grasshopper normally works in Radians, we need to right click on the **A (1)** and specify degrees.

![](https://4272289040-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LX1vLsN599YET5HV1Ju%2F-LZ7qH_s4YU0_TkOodui%2F-LZ7smRbu9Dh0yE-85pF%2FCreateRobotsProgram-20.png?alt=media\&token=71a63a94-10e7-430a-8ba6-159acc224d40)

## Create Targets

## Add a Zone

## Add a Speed

## Merge Commands together

## Simulate the Program

## Save a Program


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ms-kb.msd.unimelb.edu.au/msd-robotics-lab/troubleshooting/create-a-basic-robot-program.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
