display_interactive_map()
  • 2 Minutes to read

display_interactive_map()


Article summary

This function displays an interactive map component.

Interactive map components display the map area of the robot and the current location of the robot, typically used when the robot performs a navigation task

For the example below, an informative title(s) on the top is being used to display information about the map. A map of an apartment is shown below, where the user might desire the robot to navigate around. The component can fetch a map, display robot location, and handle user-map interactions.

Reference

Screenshot 2023-06-20 at 1.23.45 PM.png

Explore more about this component here

Arguments

ArgumentsTypeDefault ValueDescription
titlestringTitle of the display (mandatory)
title_sizeenumUI_TITLE_SIZE.MEDIUMSize of the title
subtitlestringNonesubtitle of the display (optional)
map_namestrNonename of map to fetch
show_robot_positionboolFalseShow the current robot position
view_onlyboolFalseThe navigate to point modal is disable
show_back_buttonboolFalseShow a button to go back
back_button_textstring"Back"Text of the back button
button_sizeint1Button size (1 = SMALL, 2 = MEDIUM, 3 = LARGE)
languageslistNonea list of languages to be displayed on the screen (optional)
chosen_languageAny (str)Noneif language list given, a value representing the chosen language
themeenumUI_THEME_TYPE.DARKEnum to define the theme of the screen, check UI_THEME_TYPE
custom_styledictNoneDictionary containing custom styles for the modal (optional)
waitboolTrueboolean indicating to wait for user response (optional)
callbackcallableNonecallable function handling response (optional)

See the complete list of general enumerations.

Return

Dictionary that contains the action performed by the user. For interactive map, the second entry contains the coordinates of where the user selected.

Example:
{'action': 'navigate', 'coordinates': {'x': 662, 'y': 167}, 'app_id': 'APP ID’}
or
{'selected_option': {'id': 2, 'name': 'Red'}, 'action': 'item_selected', 'app_id': 'doctest'}

Exceptions

  • RayaUIMissingValue
  • RayaNeedCallback

See the complete list of ui exceptions and the complete list of general exceptions.

Callback Arguments

callback

ArgumentTypeDescription
datadictDict containing the result of the action

Example

Screenshot 2023-06-20 at 1.23.45 PM.png

...

class RayaApplication(RayaApplicationBase):

    async def setup(self):
        self.UI = await self.enable_controller('ui')
        ....
        
    async def loop(self):
     ....
        response = await self.UI.display_interactive_map(
               title = "Title goes here!",
               subtitle =  "Here we can write a nice subtitle explaining a bit more",
               map_name =  "unity_apartment",
               show_robot_position = True,
               view_only = False,
               show_back_button = True
       )
       self.log.info(response)
      ...
      
    async def finish(self):
      ...

...
"""
This shows:
{'action': 'navigate', 'coordinates': {'x': 662, 'y': 167}, 'app_id': 'APP ID’}  when the corresponding coordinate is clicked.
"""

Was this article helpful?