Auxiliary Scripts
Here you can find a description of all the scripts that provide supporting functionality for the core elements. These auxiliary modules implement common tools and abstractions which are used in this type of nodes.
File
Python script to implement a file handler, which is responsible for writing files with data of the cognitive architecture. The files avaliable to write are:
Goodness: A file where several goodness statistics about an experiment are stored.
P-Nodes Sucess: A file that records wether a P-node’s activation has been successful or not.
Trials Sucess: A file that record de number of trials to ahieve a goal and whether it was successful or not.
P-Nodes Content: A file that saves the contents of the P-Nodes every 100 iterations.
Last Iteration P-Nodes Content: A file that saves the contents of the P-Nodes at the last iteration of an experiment.
Goals Content: A file that saves the contents of the Goals every 100 iterations.
Last Iteration Goals Content: A file that saves the contents of the Goals at the last iteration of an experiment.
Neighbors: File specific to track the subgoals created by effectance.
Neighbors Full: A file that saves the full neighbor tree at the end of an experiment.
The desired ouput files can be specified in the configuration file of the experiment.
- class core.file.FileDrivesPerceptions(ident, file_name, node, **params)[source]
Bases:
FileA file where several drive evaluation statistics about an experiment are stored.
- class core.file.FileEpisodesDataset(**kwargs)[source]
Bases:
FileA file that records the episodes published
- class core.file.FileGoalsContent(ident, file_name, node, save_interval=100, **params)[source]
Bases:
FileA file that saves the contents of the Goals at the end of an experiment.
- create_goal_client(goal_name)[source]
Create client to request Goal’s space.
- Parameters:
goal_name (str) – Name of the Goal.
- class core.file.FileGoodness(ident, file_name, node, **params)[source]
Bases:
FileA file where several goodness statistics about an experiment are stored.
- class core.file.FileLastIterationGoalsContent(ident, file_name, node, save_interval=100, **params)[source]
Bases:
FileGoalsContentA file that saves the contents of the Goals at the end of an experiment.
- class core.file.FileLastIterationPNodesContent(ident, file_name, node, save_interval=100, **params)[source]
Bases:
FilePNodesContentA file that saves the contents of the P-nodes at the end of an experiment.
- class core.file.FileNeighbors(ident, file_name, node, **params)[source]
Bases:
FileA file that saves the neighbors of each node (Method specific to track the subgoals created by effectance).
- class core.file.FileNeighborsFull(ident, file_name, node, **params)[source]
Bases:
FileA file that saves the full neighbor tree at the end of an experiment.
- class core.file.FilePNodesContent(ident, file_name, node, save_interval=100, **params)[source]
Bases:
FileA file that saves the contents of the P-nodes.
- create_pnode_client(pnode_name)[source]
Create client to request P-Node’s space.
- Parameters:
pnode_name (str) – Name of the P-Node.
- class core.file.FilePNodesSuccess(ident, file_name, node, **params)[source]
Bases:
FileA file that records whether a P-node’s activation has been successful or not.
- class core.file.FileSaveModels(ident, file_name, node, save_interval=100, **params)[source]
Bases:
FileA file that triggers the saving of models in nodes.
Service client
Python script to implement a service client, which is responsible for sending requests to the services of the system.
- class core.service_client.ServiceClient(*args: Any, **kwargs: Any)[source]
Bases:
NodeA generic service client class.
Utils
Python script which implements auxiliary functions used into the scripts of the core.
- class core.utils.EncodableDecodableEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumEnum class that can be encoded and decoded to/from a normalized value.
- classmethod decode(value, normalized=True) str[source]
Decodes a normalized class value back to the corresponding string.
- Parameters:
value (float) – The encoded value to decode.
normalized (bool) – Whether the value is normalized, defaults to True.
- Raises:
ValueError – If no matching class is found for the value.
- Returns:
The string representation of the enum member.
- Return type:
str
- classmethod encode(value: str, normalized=True) float[source]
Encodes a string to a normalized class value.
- Parameters:
value (str) – The string representation of the enum member.
normalized (bool) – Whether to normalize the encoded value, defaults to True.
- Raises:
ValueError – If the provided value is not a valid enum member.
- Returns:
The encoded value as a float
- Return type:
float
- core.utils.actuation_dict_to_msg(actuation_dict)[source]
Transform an actuation dictionary into a ROS message.
- Parameters:
actuation_dict (dict) – Dictionary that contais the actuation signal.
- Returns:
The ROS message with the actuation.
- Return type:
cognitve_node_interfaces.msg.Actuation
- core.utils.actuation_msg_to_dict(msg)[source]
Transform a ROS message that contains an actuation into a dictionary.
- Parameters:
msg (cognitve_node_interfaces.msg.Actuation) – The ROS message with the perception.
- Returns:
The dictionary with the actuation.
- Return type:
dict
- core.utils.class_from_classname(class_name)[source]
Return a class object from a class name.
- Parameters:
class_name (str) – The name of the class.
- Returns:
The class object.
- Return type:
type
- core.utils.compare_perceptions(input_1, input_2, thresh=0.01)[source]
Return True if both perceptions have the same value. False otherwise.
- Parameters:
sensing (dict) – Sensing in the current iteration.
old_sensing (dict) – Sensing in the last iteration.
- Returns:
Boolean that indicates if there is a sensorial change.
- Return type:
bool
- core.utils.dict_to_msg(msg, object_dict)[source]
Transform an object dictionary into a ROS message.
- Parameters:
msg (cognitve_node_interfaces.msg.Perception or cognitve_node_interfaces.msg.Actuation) – Message to transform
object_dict (dict) – Dictionary that contais the data.
- Returns:
The ROS message with the perception.
- Return type:
cognitve_node_interfaces.msg.Perception or cognitve_node_interfaces.msg.Actuation
- core.utils.msg_to_dict(msg)[source]
Transform a ROS message that contains an object list into a dictionary.
- Parameters:
msg (cognitve_node_interfaces.msg.Perception or cognitve_node_interfaces.msg.Actuation) – The ROS message containing the object list.
- Returns:
A dictionary representation of the object list.
- Return type:
dict
- core.utils.perception_dict_to_msg(perception_dict)[source]
Transform a perception dictionary into a ROS message.
- Parameters:
perception_dict (dict) – Dictionary that contais the perceptions.
- Returns:
The ROS message with the perception.
- Return type:
cognitve_node_interfaces.msg.Perception