Platform
  • RVC
  • Features
  • Depth
  • Deployment
  • Camera Sensors
  • Calibration
  • Environmental Testing
  • Comparisons

ON THIS PAGE

  • RAE SDK
  • Requirements
  • Robot
  • Robot Options
  • SDK Components
  • LED
  • Display
  • Audio
  • Navigation
  • State
  • ROS Interface
  • Resources

RAE SDK

RAE Python SDK contains a set of Python classes and functions that allow you to interact with the RAE robot. Underneath, it uses ROS2 interfaces for communication with peripherals, as well as ROS libraries.

Requirements

To be able to use the RAE SDK in Luxonis Hub, you need to:
  • Upgrade your robot's firmware to the latest version (Luxonis OS 1.14).
  • Specify correct image in robotapp.toml file. As of the moment of writing this guide, latest image is ghcr.io/luxonis/rae-ros:v0.2.2-humble.

Robot

Robot class is the main entry point for the SDK. It provides access to all the robot's components and allows you to control them. It contains following properties (more on them in later sections):
  • ROS Interface
  • LED
  • Display
  • Audio
  • Movement
  • Perception system
Initializing Robot class also by default launches hardware drivers for peripherals and for wheels unless specified otherwise in robot's options.
Python
1from rae_sdk.robot import Robot
2
3robot = Robot()

Robot Options

You can pass options to the Robot class to customize its behavior. Example showing all available options:
Python
1from rae_sdk.robot import Robot, RobotOptions
2
3options = RobotOptions(name='rae_sdk', namespace='', launch_controllers=True, start_hardware=True, launch_mock=False)
4
5robot = Robot(options)
  • name - name of the ROS node that will be created by the Robot class. Default: rae_sdk
  • namespace - namespace of the ROS node that will be created by the Robot class. Default: ''
  • launch_controllers - whether to initialize SDK Components such as LED, Display, Audio, Navigation, State. Default: True
  • launch_mock - whether to launch mock hardware drivers instead of real ones, mostly used for testing. Default: False
  • start_hardware - whether to start hardware drivers for peripherals and wheels. Default: True
To ensure clean shutdown of the robot, you should call robot.stop() at the end of your program.

SDK Components

For the complete list of API methods and properties, please refer to the API Reference.

LED

LED class provides access to the robot's LED. It allows you to set the color of the LED and turn it on and off.
Python
1from rae_sdk.robot import Robot
2
3robot = Robot()
4
5robot.led.set_leds('#FF0000', 100, 'solid', 1)  # set color to red
You can also use the LEDControl message directly:
Python
1from rae_sdk.robot import Robot
2from rae_msgs.msg import LEDControl, ColorPeriod
3
4robot = Robot()
5
6led_control = LEDControl()
7
8color_msg = ColorPeriod()
9color_msg.frequency = 1.0
10color_msg.color.a = 1.0
11color_msg.color.r = 1.0
12color_msg.color.g = 0.0
13color_msg.color.b = 0.0
14led_msg.data = [color_msg]
15
16led_msg.control_type = LEDControl.CTRL_TYPE_ALL
17
18robot.set_leds_from_msg(led_msg)

Display

Display class provides access to the robot's display. It allows you to display text and images on the display.
Python
1import cv2
2from rae_sdk.robot import Robot
3
4robot = Robot()
5
6img = cv2.imread('image.jpg')
7robot.display.display_image(img)

Audio

Audio class provides access to the robot's audio system. It allows you to play audio files and text-to-speech.
Python
1from rae_sdk.robot import Robot
2
3robot = Robot()
4
5robot.audio.play_audio_file('file.mp3')

Navigation

Navigation class provides access to the robot's movement & navigation system. It allows you to control the robot's wheels and read it's position.
Python
1from rae_sdk.robot import Robot
2
3robot = Robot()
4
5robot.navigation.move(0.5, 0.5)  # move forward with 0.5 m/s speed and 0.5 rad/s angular speed
6
7position = robot.navigation.get_odom_position()

State

State class provides access to the robot's state. It allows you to read the robot's battery level and charging status.
Python
1from rae_sdk.robot import Robot
2
3robot = Robot()
4
5battery_level = robot.state.battery_state.capacity

ROS Interface

ROS Interface is a class that provides access to ROS2 interfaces for communication with peripherals, as well as ROS libraries. It uses rclpy library to spin up its own executor and node for communication with ROS2. It also uses ROS2 launch system to bring up robot nodes. It is abstracted away from the user, but it is possible to access it via robot.ros_interface property. For example, let's create a publisher that publishes a message to /test_topic topic with a frequency of 1 Hz:
Python
1from rae_sdk.robot import Robot
2from std_msgs.msg import String
3
4robot = Robot()
5
6def timer_callback():
7    msg = String()
8    msg.data = 'Hello world!'
9    robot.ros_interface.publish('/test_topic', msg)
10
11robot.ros_interface.create_publisher('/test_topic', String)
12robot.ros_interface.create_timer(1.0, timer_callback)
You can also create a subscriber that listens to /test_topic topic:
Python
1from rae_sdk.robot import Robot
2from std_msgs.msg import String
3
4def callback(msg):
5    print(msg.data)
6
7robot = Robot()
8
9robot.ros_interface.create_subscription('/test_topic', String, callback)
Creating a service client is also simple:
Python
1from rae_sdk.robot import Robot
2from std_srvs.srv import Trigger
3
4robot = Robot()
5
6robot.ros_interface.create_service_client('/test_service', Trigger)
7robot.ros_interface.call_async_srv('/test_service', Trigger.Request())
Similarly for action clients, if you want you can override default callbacks for accepting the goals, handling feedback, and handling results. You can also cancel the goal:
Python
1from rae_sdk.robot import Robot
2from example_interfaces.action import Fibonacci
3
4def feedback_callback(feedback_msg):
5    print('Feedback received:', feedback_msg.feedback.sequence)
6
7def result_callback(future):
8    result = future.result().result
9    print('Result received:', result.sequence)
10
11robot = Robot()
12
13robot.ros_interface.create_action_client('/test_action', Fibonacci)
14robot.ros_interface.call_async_action("/fibonacci", Fibonacci.Goal(order=10), None, self.result_cb, self.feedback_cb)
15
16# cancel the goal robot.ros_interface.cancel_action("/fibonacci")

Resources

We also provide a set of example resources that you can utilize in your applications. You can find them in the assets folder of the SDK. For now those resources include a set of face images for the robot and some example audio files that can be used for basic interaction.