Controllers
  • 1 Minute to read

Controllers


Article summary

Controllers are one of the most basic and important entities in a robotic application. They act as the bridge enabling access to all the different functionalities that are available in the robot.

Each controller is identified by a unique name and you must declare that you are going to use a controller in setup() function in order to get permissions and be able to use it in your app.

Below the full list of controllers:

Basic Controllers:

ControllerNameDescription
SensorssensorsBasic sensors: temperature, humidity, compass, etc.
LiDARlidarLiDAR sensor at the base of the robot.
CamerascamerasRGB and Depth cameras.
MotionmotionMobile base and wheels.
SoundsoundSpeakers and microphone.
LEDsledscontrolling robot leds animations.
CommunicationcommunicationCommunication between client/server.

Advanced Controllers:

ControllerNameDescription
InteractionsinteractionsLED interactions.
NavigationnavigationMapping, localization and navigation.
ArmsarmsArms movement and objects manipulation.
UIuiController to display GUI screens
CVcvComputer vision controller.

Using controllers

Controllers are enabled through the enable_controller() method, and you will be allowed to enable them only if the application has the access permission to the specific functionality (see the Application Manifest page).

Controllers should be enabled in the setup() method:

from raya.application_base import RayaApplicationBase

class RayaApplication(RayaApplicationBase):
    async def setup(self):
        ...
        # Controller for motion of Gary
        self.motion = await self.enable_controller('motion')
        # Controller for Gary's Text to Speech engine
        self.voice = await self.enable_controller('sound')
        # Controller for Gary's Sensors
        self.sensors = await self.enable_controller('sensors')
        # Controller for Gary's Cameras
        self.cameras = await self.enable_controller('cameras')
        ...

enable_controller() is a inherited method of the RayaApplication class, and it returns a controller object that contains methods according to its functionality. For instance:

        # Gary starts moving fordward at 0.5 m/s
        self.motion.set_forward_velocity(0.5)
        # Gary says something
        self.voice.text_to_speech('hello from voice controller')

Also, you can synchronously retrieve information from the controllers:

        # Read the temperature sensor
        temp = self.sensors.get_sensor_value('/temperature/external')
        # Take a picture from the robot's chest camera
        img = self.cameras.get_snapshot(camera='chest')

These methods allows you to get information through a polling mechanism. To learn the way to asynchronously read sensors and retrieve information from controllers through a event-like mechanism, see the Learning Listeners page.

Exceptions

Controllers creation process can throw the following exceptions:

ExceptionCondition
RayaControllerExceptionException from controllers.

In addition, each specific controller can throw specific exceptions (see each controller documentation for more detailed information).

See the Full List of Exceptions


Was this article helpful?