- 1 Minute to read
Controllers
- 1 Minute to read
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:
Controller | Name | Description |
---|---|---|
Sensors | sensors | Basic sensors: temperature, humidity, compass, etc. |
LiDAR | lidar | LiDAR sensor at the base of the robot. |
Cameras | cameras | RGB and Depth cameras. |
Motion | motion | Mobile base and wheels. |
Sound | sound | Speakers and microphone. |
LEDs | leds | controlling robot leds animations. |
Communication | communication | Communication between client/server. |
Advanced Controllers:
Controller | Name | Description |
---|---|---|
Interactions | interactions | LED interactions. |
Navigation | navigation | Mapping, localization and navigation. |
Arms | arms | Arms movement and objects manipulation. |
UI | ui | Controller to display GUI screens |
CV | cv | Computer 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:
Exception | Condition |
---|---|
RayaControllerException | Exception 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