utils
- class utils.Config(config_path)[source]
Bases:
object
Class to parse and keep the config loaded from yaml file
- Parameters:
config_path (str) – path to the config file
- set_attribute(attr, value, reference)[source]
Function to recursively fill the instance variables from dictionary. When value is non-dict, it is directly assigned to a variable. Else, the dict is recursively parsed.
- Parameters:
attr (str) – name of the attribute
value (str, float, int, dict, list, ... - and other that can be loaded from yaml) – value of the attribute
reference (pointer or whatever it is called in Python) – reference to the parent class. “self” for the upper attributes, pointer to namedtuple for inner attributes
- Returns:
0
- Return type:
int
- class utils.CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]
Bases:
Formatter
Custom formatter that assigns colors to logs From https://stackoverflow.com/a/56944256
Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.
Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting,
str.format()
({}
) formatting orstring.Template
formatting in your format string.Changed in version 3.2: Added the
style
parameter.- FORMATS = {10: '\x1b[38;20m%(module)s %(levelname)s: %(message)s\x1b[0m', 20: '\x1b[38;20m%(module)s %(levelname)s: %(message)s\x1b[0m', 30: '\x1b[33;20m%(module)s %(levelname)s: %(message)s\x1b[0m', 40: '\x1b[31;20m%(module)s %(levelname)s: %(message)s\x1b[0m', 50: '\x1b[31;1m%(module)s %(levelname)s: %(message)s\x1b[0m'}
- bold_red = '\x1b[31;1m'
- format(record)[source]
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- grey = '\x1b[38;20m'
- red = '\x1b[31;20m'
- reset = '\x1b[0m'
- yellow = '\x1b[33;20m'
- class utils.Pose(pos, ori)[source]
Bases:
object
Mini help class for Pose representation
Init function that takes position and orientation and saves them as attributes
- Parameters:
pos (list) – x,y,z position
ori (list) – rpy orientation
- class utils.URDF(path)[source]
Bases:
object
Class to parse URDF file
- Parameters:
path (str) – path to the URDF file
- ROOT_TAGS = []
- fix_urdf()[source]
Fix the URDF file by converting non-mesh geometries to mesh and saving them as .obj files. If changes were made, write the new URDF to a file.
- read(el, parent)[source]
Recursive function to read the URDF file. When there are no children, it reads the attributes and saves them.
- Parameters:
el (xml.etree.ElementTree.Element) – The current element in the XML tree.
parent (xml.etree.ElementTree.Element) – The parent element in the XML tree.
- write_attr(attr_name, attr, level=1, skip_header=False)[source]
Write an attribute to the new URDF string.
- Parameters:
attr_name (str) – The name of the attribute.
attr (any) – The attribute value.
level (int, optional, default=1) – The indentation level for the attribute.
skip_header (bool, optional, default=False) – Whether to skip writing the attribute header.