ros2_snapshot.snapshot.builders.node_builder module

Module for NodeBuilder.

Represent ROS Entities and are responsible for allowing themselves to be populated with basic information and then further populating themselves from that information for the purpose of extracting metamodel instances

class ros2_snapshot.snapshot.builders.node_builder.NodeBuilder(name)

Bases: _EntityBuilder

Define a NodeBuilder.

Represents a ROS Node and is responsible for allowing itself to be populated with basic information relevant to a Node and then further populating itself from that information for the purpose of extracting a metamodel instance

property action_clients

Return the set of Action names for which this ROS Node is a Client.

Returns:

Action names where this ROS Node is a Client

Return type:

set{str}

property action_servers

Return the set of Action names associated to this ROS Node.

Returns:

Action names where this ROS Node is a Server

Return type:

set{str}

add_action_client(action_name)

Add list of action client names to node_bank.

Action_name:

the action name

add_action_server(action_name)

Add list of action server names to node_bank.

Action_name:

the action name

add_info(node)

Set node name of the builder.

Node:

the node name of our builder

add_parameter_name(parameter_name)

Associate parameters with the ROS Node.

Parameters:

parameter_name (str) – the name of the Parameter

add_service_name_and_type(service_name, service_type)

Associate the name of a Service with the ROS Node.

Parameters:
  • service_name (str) – the name of the associated Service

  • service_type (str) – the ROS Service type

add_topic_name(topic_name, status, topic_type, remap)

Associate a ‘published’ or ‘subscribed’ Topic with a ROS Node.

Parameters:
  • topic_name (str) – the name of the Topic

  • status (str) – the relationship or status (‘subscribed’ or ‘published’) of the Topic to the ROS Node

  • topic_type (str) – the ROS Topic Type

  • remap – name used by node specification

“type remap: str”

property all_topic_names

Return the name of all Topics either published or subscribed to by the ROS Node.

Including those that were removed from the basic Published / Subscribed store since they were related to either a Nodelet / Nodelet Manager interaction or an Action

Returns:

all Topic names

Return type:

set{str}

property executable_cmdline

Return the ROS Node executable command line.

Returns:

the ROS Node executable command line

Return type:

str

property executable_cpu_percent

Return the ROS Node executable cpu percent.

Returns:

the ROS Node executable cpu percent

Return type:

str

property executable_file

Return the ROS Node executable.

Returns:

the ROS Node executable

Return type:

str

property executable_memory_info

Return the ROS Node executable memory_info.

Returns:

the ROS Node executable memory_info

Return type:

str

property executable_memory_percent

Return the ROS Node executable memory percent.

Returns:

the ROS Node executable memory percent

Return type:

str

property executable_name

Return the ROS Node executable name.

Returns:

the ROS Node executable

Return type:

str

property executable_num_threads

Return the ROS Node executable number threads.

Returns:

the ROS Node executable number threads

Return type:

str

extract_metamodel()

Extract metamodel.

Allows the NodeBuilder to create / extract either a Node, or Component Manager, instance from its internal state

Returns:

the created / extracted metamodel instance

Return type:

Node or ComponentManager

get_node_pid(namespace, node_name, guess=False)

Return the PID number give node_name.

This is a best effort “fuzzy” process given process names that do not necessarily match node names. It is not based on static code analysis, and needs improvement.

Returns:

the ROS Node process id

Return type:

int

classmethod get_processes()

Return list of processes.

Returns:

dictionary of system processes data

Return type:

dict

property machine

Extract the machine ID from the uri information.

Returns:

machine ID as string

property namespace

Return the namespace of this node.

Returns:

namespace

Return type:

string

property node

Return the package/node name of this node.

Returns:

package/node name

Return type:

string

property parameter_names

Return parameter names for metamodel extraction.

prepare(**kwargs)

Allow this NodeBuilder to prepare its internal state.

Used for eventual metamodel extraction; internal changes to the state of the class instance occur here

Parameters:
  • topic_bank_builder (TopicBankBuilder) – the TopicBankBuilder to use for Action-related Topic name removal (from kwargs)

  • action_bank_builder (ActionBankBuilder) – the ActionBankBuilder to use for Action-related Topic name removal and Action Server / Client reference

property published_topic_names

Return the names of the Topics published by the ROS Node.

Returns:

published Topic names

Return type:

dict{name:remap}

remove_topic_name(topic_name, status)

Remove either a ‘published’ or ‘subscribed’ association.

Between a Topic name and the ROS Node

Parameters:
  • topic_name (str) – the name of the Topic

  • status (str) – the relationship or status (‘subscribed’ or ‘published’) of the Topic to the ROS Node

property service_names

Return the name of all Services associated with the ROS Node.

Returns:

associated Service names

Return type:

set{str}

property service_names_to_types

Return the mapping of all Service names to their Service type.

Returns:

all Service names to their mapped ROS Service Type

Return type:

dict{str: str}

property service_names_with_remap

Return the name of all Services associated with the ROS Node.

As dictionary to remapped service id (None at this point)

Returns:

associated Service names

Return type:

dict{str:str}

set_comp_yaml(isTrue, manager_name)

Set Component to true or false.

Used for differentiation later

Parameters:

isTrue – boolean determined if self.name

found in our @TODO

set_component_list(components_list)

Set Component list.

@TODO

set_manager_yaml(isTrue)

Set ComponentManager to true or false.

Used for differentiation later

Parameters:

isTrue – boolean determined if self.name

found in our :param results: component list results @TODO

set_node_name(name)

Set the package/node name for this node.

Parameters:

name – package/node name

property subscribed_topic_names

Return the names of the Topics subscribed to by the ROS Node.

Returns:

subscribed Topic names

Return type:

set{str}

property topic_names_to_types

Return the mapping of all added Topic names to their ROS type.

Returns:

all Topic names to their mapped ROS Topic Type

Return type:

dict{str: str}