ros_sugar.ui_node.elements#

Module Contents#

Classes#

Task

Task (ROS2 Action) Element Class

Functions#

filter_tag_button

UI arrow button to use for show/hide toggle of a Div with a given ID

add_additional_ui_elements

Deserialize additional elements and add them

styled_main_service_clients_container

Creates a UI element for all service clients

input_topic_card

Creates a UI element for an input topic

styled_main_inputs_container

Creates main section for all the UI inputs

styled_inputs_grid

Creates a styled grid for the number of inputs

output_topic_card

Creates a UI element for an output topic

styled_main_outputs_container

Creates main section for all the UI outputs

styled_outputs_grid

Creates a styled grid for the number of outputs

output_logging_card

Creates a main container for the logging card and adds current logging

initial_logging_card

Creates an empty logging card with ‘Log Started’ text

remove_child_from_logging_card

Remove the last child in logging_card.children with a matching id.

augment_text_in_logging_card

Update the inner text of a child in logging_card.children with a matching id.

update_logging_card

Updates the logging card with a response text

update_logging_card_with_loading

Adds a robot ‘loading’ element to the main logging card. Used to add loading to the card until a response is received

settings_ui_element

Creates a UI element based on the setting’s type and validators

component_settings_div

Creates a UI element for a component to show and update the config parameters

nonvalidated_config

Sets up a UI element for a component settings element WITHOUT validators

validated_config

Sets up UI element for a component settings element with validators

parse_ui_elements_to_simple_and_nested

Parses the component settings element to determine if it is a simple type (int, float, etc.) or a nested type (for elements that are BaseAttrs classes themselves), then adds the element to the corresponding list

API#

class ros_sugar.ui_node.elements.Task(name: str, client_type: str, fields)#

Task (ROS2 Action) Element Class

update(*, status: str | None = None, feedback: Any = None, duration: float | None = None)#

Update the task current status

Parameters:

status (str) – New status

property card: FT#

Get a UI card element for the task tracking and request

Returns:

description

Return type:

FT

property feedback#

Get a UI element for the task feedback

ros_sugar.ui_node.elements.filter_tag_button(name: str, div_to_hide: str, **kwargs)#

UI arrow button to use for show/hide toggle of a Div with a given ID

Parameters:

div_to_toggle (Optional[str], optional) – Id of the Div to show/hide on button click, defaults to None

Returns:

UI Button Element

Return type:

FT

ros_sugar.ui_node.elements.add_additional_ui_elements(input_elements: List[Tuple] | None, output_elements: List[Tuple] | None)#

Deserialize additional elements and add them

ros_sugar.ui_node.elements.styled_main_service_clients_container(srv_clients_config: Sequence[Dict], container_name: str, column_class: str = '') FT#

Creates a UI element for all service clients

Parameters:
  • srv_clients_config (Sequence[Dict]) – Set of service clients configs

  • column_class (str, defaults to “”) – UI columns class

Returns:

Input Service Clients UI element

ros_sugar.ui_node.elements.input_topic_card(topic_name: str, topic_type: str, ros_msg_type: type, column_class: str = '') FT#

Creates a UI element for an input topic

Parameters:
  • topic_name (str) – Topic name

  • topic_type (str) – Topic message type

  • column_class (str) – CSS class for number of columns, if not set the Div will span over the whole parent width

Returns:

Input topic UI element

ros_sugar.ui_node.elements.styled_main_inputs_container(inputs_grid_div_id: str) FT#

Creates main section for all the UI inputs

Returns:

Main inputs card

Return type:

FT Card

ros_sugar.ui_node.elements.styled_inputs_grid(number_of_inputs: int) tuple#

Creates a styled grid for the number of inputs

Parameters:

number_of_inputs (int) – Number of input cards

Returns:

Styled Grid, Style class to use for each element in the grid

Return type:

tuple

ros_sugar.ui_node.elements.output_topic_card(topic_name: str, topic_type: str, column_class: str = '') FT#

Creates a UI element for an output topic

Parameters:
  • topic_name (str) – Topic name

  • topic_type (str) – Topic message type

Returns:

Output topic UI element

ros_sugar.ui_node.elements.styled_main_outputs_container(outputs_grid_div_id: str) FT#

Creates main section for all the UI outputs

Returns:

Main outputs card

Return type:

FT Card

ros_sugar.ui_node.elements.styled_outputs_grid(number_of_outputs: int) tuple#

Creates a styled grid for the number of outputs

Parameters:

number_of_outputs (int) – Number of output cards

Returns:

Styled Grid, Style class to use for each element in the grid

Return type:

tuple

ros_sugar.ui_node.elements.output_logging_card(current_log)#

Creates a main container for the logging card and adds current logging

Parameters:

current_log (FT) – Current logging card

Returns:

Logging card main container

Return type:

FT

ros_sugar.ui_node.elements.initial_logging_card()#

Creates an empty logging card with ‘Log Started’ text

Returns:

Empty logging card

Return type:

FT

ros_sugar.ui_node.elements.remove_child_from_logging_card(logging_card, target_id='loading-dots')#

Remove the last child in logging_card.children with a matching id.

ros_sugar.ui_node.elements.augment_text_in_logging_card(logging_card, new_txt: str, target_id='text')#

Update the inner text of a child in logging_card.children with a matching id.

ros_sugar.ui_node.elements.update_logging_card(logging_card, output: str, data_type: str, data_src: str = 'info')#

Updates the logging card with a response text

Parameters:
  • logging_card (FT) – Main logging card to update

  • output (str) – Text to add to the card

  • data_type (str) – Type of the data (String/error)

  • data_src (str, optional) – Source of the data (info, error, robot, etc.), defaults to “info”

Returns:

Updated logging card

Return type:

FT

ros_sugar.ui_node.elements.update_logging_card_with_loading(logging_card)#

Adds a robot ‘loading’ element to the main logging card. Used to add loading to the card until a response is received

ros_sugar.ui_node.elements.settings_ui_element(setting_name: str, setting_details: dict, field_type, type_args, input_name=None)#

Creates a UI element based on the setting’s type and validators

Parameters:
  • setting_name (str) – Config parameter name

  • setting_details (dict) – Details of the parsed config

Returns:

Setting parameter UI element

ros_sugar.ui_node.elements.component_settings_div(component_name: str, settings_col_cls: str, ui_elements, nested_ui_elements)#

Creates a UI element for a component to show and update the config parameters

Parameters:
  • component_name (str) – Name of the component (ROS2 node name)

  • settings_col_cls (str) – UI Div columns span in the display grid

  • ui_elements (List) – A set ot UI elements for each parameter in the component config

Returns:

Component config UI element

ros_sugar.ui_node.elements.nonvalidated_config(setting_name: str, value: Any, field_type: str, type_args, input_name: str)#

Sets up a UI element for a component settings element WITHOUT validators

Parameters:
  • setting_name (str) – Name of the settings field

  • value (Any) – Value of the settings field

  • field_type (type) – Type of the settings field

  • type_args (type) – Type arguments (if any)

  • input_name (type) – Corresponding input name

Returns:

UI input element

Return type:

FT

ros_sugar.ui_node.elements.validated_config(setting_name: str, value: Any, attrs_validators: List[Dict], field_type, type_args, input_name)#

Sets up UI element for a component settings element with validators

Parameters:
  • setting_name (str) – Name of the settings field

  • value (Any) – Value of the settings field

  • attrs_validators (List[Dict]) – Validators of the settings field

  • field_type (type) – Type of the settings field

  • type_args (type) – Type arguments (if any)

  • input_name (type) – Corresponding input name

Returns:

UI input element

Return type:

FT

ros_sugar.ui_node.elements.parse_ui_elements_to_simple_and_nested(component_name: str, setting_name: str, setting_details: Any, simple_ui_elements: list, nested_ui_elements: list)#

Parses the component settings element to determine if it is a simple type (int, float, etc.) or a nested type (for elements that are BaseAttrs classes themselves), then adds the element to the corresponding list

Parameters:
  • component_name (str) – Name of the component

  • setting_name (str) – Name of the settings field

  • setting_details (Any) – Value of the settings field

  • simple_ui_elements (list) – Set of component’s simple UI elements to populate

  • nested_ui_elements (list) – Set of component’s nested UI elements to populate