Create your First App (Robot)
  • 1 Minute to read

Create your First App (Robot)

Article Summary


This section describes how to create a simple Ra-Ya app.

We are going to create an application that is going to be executed on a real robot, For now we are going to test that everything is installed correctly with a Hello world example.

Connecting to the robot

Let's start verifying that the robot is connected to the network, with the SDK installed open a new terminal and run

rayasdk scan

This will output a table with the available robots on the network, the output should look like this

Press enter to exit...

Robot ID              Serial                IP Address
--------------------  --------------------  --------------
GARYV2_OFFICE_08      SN-08       

Once that you see that the robot that you want to connect is present on the list, execute this

rayasdk connect --robot-id GARYV2_OFFICE_08

In case that the robot appears multiple times you will have to define the IP that should be use on the connection with

rayasdk connect --robot-ip

The command can prompt you to do certain actions, Once that the connection is successfully you should see

You have successfully connected to GARYV2_OFFICE_08

The connection is only necesary the first time, or each time that you want to run the application on a different robot, In case that the connection failed make sure that the robot is running Ra-Ya OS and is connected to your network.

Creating the app

An Ra-Ya app need a structure in order to execute, The SDK will help you with this, open a terminal and execute:

mkdir hello_world
cd hello_world
rayasdk init

Now you should see that the folder contains files and directories, open with any editor the file inside the src directory, replace the content with the following code:

from raya.application_base import RayaApplicationBase

class RayaApplication(RayaApplicationBase):

    async def setup(self):
        # Create local attributes and variables'Hello from setup()')

    async def loop(self):
        # Loop'Hello world')

    async def finish(self):
        # Finishing instructions
        self.log.warn(f'Hello from finish()')

Run your app

You just wrote your first Ra-Ya app. It's time to run it!

Open a terminal and go to the project folder, and execute:

rayasdk run

The app will be sent to the robot and is going to be launched, you should see on the output this

Syncing the app on the host ''...
Launching app...
(INFO)<> Hello from setup()
(INFO)<> Hello world
(WARNING)<> Hello from finish()

Congratulations you just executed an app.

Was this article helpful?