# API reference

### rae_sdk

Kind: Package

#### robot

Kind: Package

##### api

Kind: Package

###### performance

Kind: Module

###### measure_performance() -> Callable

Kind: Function

###### default_value_10_000_000() -> float

Kind: Function

###### list_of_durations

Kind: Variable

###### maximum_duration: dict[Any, float]

Kind: Variable

###### minimum_duration: dict[Any, float]

Kind: Variable

###### last_report_at: dict[Any, float]

Kind: Variable

###### measure_average_performance() -> Callable

Kind: Function

###### last_call_at

Kind: Variable

###### last_report_call_frequency_at

Kind: Variable

###### call_frequency_memory

Kind: Variable

###### measure_call_frequency() -> Callable

Kind: Function

###### with_sql_exception_handling() -> Callable

Kind: Function

###### trace_memory() -> Callable

Kind: Function

###### ros

Kind: Package

###### ros_interface

Kind: Module

###### QOS_PROFILE: int

Kind: Constant

###### rae_sdk.robot.api.ros.ros_interface.ROSInterface

Kind: Class

A class that manages ROS2 functionalities for a robot or a system.

It includes initializing ROS2 context,
creating and managing nodes, publishers, and subscribers.
It also handles the startup and shutdown processes
for ROS2.

Attributes
----------
_name (str): Name of the ROS2 node.
_context (rclpy.context.Context | None): The ROS2 context.
_node (rclpy.node.Node | None): The ROS2 node.
_publishers (dict[str, Publisher]): Dictionary of ROS2 publishers.
_subscribers (dict[str, Subscription]): Dictionary of ROS2 subscribers.
_service_clients (dict[str, Client]): Dictionary of ROS2 service clients.
_action_clients (dict[str, dict[ActionClient]]): Dictionary of ROS2 action clients.
_timers (dict[str, Timer]): Dictionary of ROS2 timers.
_tf_buffer: The TF2 buffer.
_tf_listener: The TF2 listener.
_executor (Executor): The ROS2 executor.
_executor_thread (threading.Thread): The thread for the ROS2 executor.
_launch_service (LaunchService): The ROS2 launch service.
_stop_event (multiprocessing.Event): The event for stopping the ROS2 launch service.
_process (multiprocessing.Process): The process for running the ROS2 launch service.

Methods
-------
start_hardware_process(): Starts the hardware process for ROS2.
start(): Initializes and starts the ROS2 node and executor.
stop_ros_process(): Stops the ROS2 hardware process.
stop(): Shuts down the ROS2 node and context.
create_publisher(topic_name, msg_type, qos_profile): Creates a publisher for a given topic.
publish(topic_name, msg): Publishes a message on a given topic.
create_subscriber(topic_name, msg_type, callback, qos_profile): Creates a subscriber for a given topic.
create_timer(timer_name, period, callback): Creates a timer for a given topic.
create_service_client(srv_name, srv_type): Creates a service client for a given service.
call_async_srv(srv_name, req): Calls a service asynchronously.
create_action_client(action_name, action_type): Creates an action client for a given action.
call_async_action_simple(action_name, goal): Calls an action asynchronously.
call_async_action(action_name, goal, goal_response_callback, goal_result_callback, goal_feedback_callback): Calls an action
asynchronously.

###### __init__(robot_options: RobotOptions = RobotOptions())

Kind: Method

###### node

Kind: Property

###### start_hardware_process()

Kind: Method

###### start()

Kind: Method

###### stop_ros_process()

Kind: Method

###### stop()

Kind: Method

###### create_publisher(qos_profile: int = QOS_PROFILE)

Kind: Method

###### create_service_client()

Kind: Method

###### call_async_srv()

Kind: Method

###### publish()

Kind: Method

###### create_subscriber(callback = None, qos_profile: int = QOS_PROFILE)

Kind: Method

###### create_timer()

Kind: Method

###### create_action_client()

Kind: Method

###### call_async_action_simple() -> ClientGoalHandle

Kind: Method

###### call_async_action(goal_response_callback = None, goal_result_callback = None, goal_feedback_callback = None) ->
ClientGoalHandle

Kind: Method

###### cancel_action()

Kind: Method

###### get_frame_position() -> TransformStamped

Kind: Method

##### audio

Kind: Module

###### rae_sdk.robot.audio.AudioController

Kind: Class

A class for controlling the robot's audio.

Attributes
----------
ros_interface (ROSInterface): An object for managing ROS2 communications and functionalities.
audio_client (Client): A ROS2 client for playing audio.
assets_path (str): The path to the robot's assets directory.

Methods
-------
play_audio_file(audio_file_path): Plays an audio file.
honk(): Plays a horn sound.
play_random_sfx(): Plays a random sound effect.

###### __init__()

Kind: Method

###### play_audio_file()

Kind: Method

###### honk()

Kind: Method

###### play_random_sfx()

Kind: Method

##### display

Kind: Module

###### quaternion_to_rotation_matrix()

Kind: Function

###### rae_sdk.robot.display.DisplayController

Kind: Class

A class for controlling the robot's display.

Attributes
----------
_ros_interface (ROSInterface): An object for managing ROS2 communications and functionalities.
_bridge (CvBridge): An object for converting between ROS2 and OpenCV image formats.
_screen_width (int): The width of the robot's display.
_screen_height (int): The height of the robot's display.
_assets_path (str): The path to the robot's assets directory.

Methods
-------
stop(): Stops the display.
display_default(): Displays the default image on the robot's display.
display_face(payload): Displays a face on the robot's display.
display_image(image_data): Displays an image on the robot's display.
display_imu_data(imu_data): Displays IMU data on the robot's display.
display_animation(): Displays an animation on the robot's display.
ball_callback(): Callback method for displaying an animation on the robot's display.

###### __init__()

Kind: Method

###### stop()

Kind: Method

###### display_image()

Kind: Method

###### display_default()

Kind: Method

###### display_face()

Kind: Method

###### display_imu_data()

Kind: Method

###### display_animation()

Kind: Method

###### ball_callback()

Kind: Method

###### ball_size

Kind: Instance Variable

###### ball_color

Kind: Instance Variable

###### x

Kind: Instance Variable

###### y

Kind: Instance Variable

###### vx

Kind: Instance Variable

###### vy

Kind: Instance Variable

##### led

Kind: Module

###### rae_sdk.robot.led.LEDController

Kind: Class

A class for controlling the robot's LEDs.

Attributes
----------
ros_interface (ROSInterface): An object for managing ROS2 communications and functionalities.

Methods
-------
set_leds(payload): Sets the robot's LEDs to a given color.

###### __init__()

Kind: Method

###### hex_to_rgb()

Kind: Method

###### normalize()

Kind: Method

###### set_leds_from_payload()

Kind: Method

###### set_leds(brightness: int = 100, effect: str = 'solid', interval: int = 5)

Kind: Method

###### set_leds_from_msg()

Kind: Method

##### navigation

Kind: Module

###### rae_sdk.robot.navigation.NavigationController

Kind: Class

A class for controlling the robot's movement.

Attributes
----------
ros_interface (ROSInterface): An object for managing ROS2 communications and functionalities.

Methods
-------
move(linear, angular): Moves the robot in a given direction.

###### __init__()

Kind: Method

###### move()

Kind: Method

###### get_odom_position() -> TransformStamped

Kind: Method

##### perception

Kind: Package

###### detections

Kind: Module

###### labelMap: list[str]

Kind: Variable

###### rae_sdk.robot.perception.detections.Detections

Kind: Class

###### target: Optional[dai.ImgDetection]

Kind: Class Variable

###### other: List[dai.ImgDetection]

Kind: Class Variable

###### create_detection_metadata()

Kind: Function

###### perception_system

Kind: Module

###### ROBOTHUB_AVAILABLE: bool

Kind: Variable

###### rae_sdk.robot.perception.perception_system.PerceptionSystem

Kind: Class

A class for managing camera functionalities in a robot, interfacing with both depthai and robothub libraries.

It includes initialization and management of camera streams, publishing capabilities, and camera device control.

Attributes
----------
ros_context_manager (dai_ros.ROSContextManager): Manager for ROS context.
dai_node (dai_ros.ROSNode): ROS node for depthai operations.
device_mxid (str): The serial number of the depthai device.
device_info (dai.DeviceInfo): Information about the depthai device.
device (dai.Device): The depthai device instance.
cal_handler: Calibration handler for the depthai device.
pipeline: The pipeline for camera data processing.
rh_stream_handles (dict): Handles for RobotHub video streams.
ros_stream_handles (dict): Handles for ROS video streams.

Methods
-------
stop(): Closes the depthai device connection.
add_rh_stream(stream_name): Adds a RobotHub stream with the given name.
add_ros_img_stream(stream_name): Adds a ROS Image stream with the given name.
add_ros_imu_stream(stream_name): Adds a ROS IMU stream with the given name.
add_queue(name, callback): Adds a queue to the device for handling callbacks.
add_composable_node(package_name, plugin_name, options): Adds a composable node to the ROS context manager.
start_pipeline(pipeline): Starts the camera pipeline and initializes ROS node and context.
publish_rh(name, color_frame, timestamp, metadata): Publishes video data to RobotHub.
publish_ros(name, msg): Publishes a message to a ROS topic.
get_image(stream_name): Retrieves an image from the specified stream.

###### __init__(namespace = '')

Kind: Method

###### __del__()

Kind: Method

###### set_executor_type()

Kind: Method

###### connect_to_device() -> bool

Kind: Method

###### start()

Kind: Method

###### stop()

Kind: Method

###### add_rh_stream()

Kind: Method

###### add_ros_img_stream(width = -1, height = -1, convertFromBitStream = False, frame_type = dai.RawImgFrame.Type.BGR888i)

Kind: Method

###### add_ros_imu_stream()

Kind: Method

###### add_ros_feature_stream()

Kind: Method

###### add_queue(callback = None)

Kind: Method

###### add_composable_node(options = dai_ros.ROSNodeOptions())

Kind: Method

###### start_pipeline()

Kind: Method

###### opts

Kind: Instance Variable

###### publish_rh()

Kind: Method

###### publish_ros()

Kind: Method

###### get_image() -> np

Kind: Method

###### stream_name_to_socket()

Kind: Method

###### setup_sai_slam()

Kind: Method

###### setup_rtabmap()

Kind: Method

###### scan_front_opts

Kind: Instance Variable

###### opts_rectify

Kind: Instance Variable

###### opts_rtabmap

Kind: Instance Variable

###### pipeline

Kind: Module

###### BLOB_PATH

Kind: Constant

###### build_pipeline() -> dai

Kind: Function

###### rtabmap_pipeline()

Kind: Function

###### sai_pipeline()

Kind: Function

##### robot

Kind: Module

###### rae_sdk.robot.robot.Robot

Kind: Class

A class representing a robot, integrating various controllers for movement, display, and LED management and interfacing with ROS2
for communication and control.

Attributes
----------
ros_interface (ROSInterface): An object for managing ROS2 communications and functionalities.
led (LEDController): Controls the robot's LEDs.
display (DisplayController): Manages the robot's display.
navigation (NavigationController): Handles the robot's movement.
audio (AudioController): Controls the robot's audio.
state (StateController): Manages the robot's state information.
perception (PerceptionSystem): Handles the robot's perception system.

Methods
-------
start(): Initializes the robot's components and starts ROS2 communications.
stop(): Stops the ROS2 communications and shuts down the robot's components.

###### __init__(robot_options: RobotOptions = RobotOptions())

Kind: Method

###### __del__()

Kind: Method

###### stop()

Kind: Method

###### state

Kind: Property

###### perception

Kind: Property

Create perception system if it doesn't exist and return it.

###### ros_interface

Kind: Property

###### led

Kind: Property

###### display

Kind: Property

###### navigation

Kind: Property

###### audio

Kind: Property

##### robot_options

Kind: Module

###### rae_sdk.robot.robot_options.RobotOptions

Kind: Class

A class for storing the robot's options.

Attributes
----------
start_hardware (bool): Whether to start the robot's hardware.
launch_mock (bool): Whether to launch the robot's mock interfaces if start_hardware=True.
name (str): The robot's name.
namespace (str): The robot's namespace.
launch_controllers (bool): Whether to launch the robot's controllers.

###### __init__(name = 'rae_api', namespace = '', launch_controllers = True, start_hardware = True, launch_mock = False)

Kind: Method

###### start_hardware

Kind: Property

###### launch_mock

Kind: Property

###### name

Kind: Property

###### namespace

Kind: Property

###### launch_controllers

Kind: Property

##### state

Kind: Module

###### rae_sdk.robot.state.StateController

Kind: Class

A class for managing the robot's state.

Attributes
----------
ros_interface (ROSInterface): An object for managing ROS2 communications and functionalities.
battery_state (BatteryState): Stores the current state of the robot's battery.

Methods
-------
battery_state_cb(data): Callback method for updating battery state.

###### __init__()

Kind: Method

###### battery_state_cb()

Kind: Method

###### battery_state

Kind: Property
