icub_pybullet.utils
Utils for pyCub simulator
- Author:
Lukas Rustler
Attributes
Classes
Class to parse URDF file |
|
Class to parse and keep the config loaded from yaml file. |
|
Mini help class for Pose representation |
|
Custom formatter that assigns colors to logs |
Module Contents
- class icub_pybullet.utils.URDF(path: str, package_dir: str | None = None)
Class to parse URDF file
- ROOT_TAGS = []
- path = b'.'
- package_dir
- links = []
- joints = []
- robot_name
- new_urdf = ''
- find_root_tags() None
Finds tags that are ‘root’, i.e., they have child ‘inside’
- read(el: xml.etree.ElementTree, parent: xml.etree.ElementTree) None
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.
- dereference() None
Make parent/child again as names to allow urdf write
- make_references() None
Make parent/child in joint list as references to the given link
- expand_package_uris() None
Expand package:// mesh paths to absolute POSIX paths so cached URDFs load from any directory.
- fix_urdf() None
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 writable directory or user cache.
- write_attr(attr_name: str, attr: Any, level: int | None = 1, skip_header: bool | None = False) None
Write an attribute to the new URDF string.
- write_urdf() None
Write the URDF object to a string.
- class icub_pybullet.utils.Config(config_path: str)
Class to parse and keep the config loaded from yaml file. Supports optional parent: <base.yaml> inheritance so user-defined custom worlds can override only what they need.
- set_attribute(attr: str, value: Any, reference: int) int
Recursively assign dictionary entries as named attributes on
reference.- Parameters:
attr – Attribute name to assign.
value – Scalar or nested dictionary value.
reference – Target object or namedtuple receiving the attribute.
- class icub_pybullet.utils.Pose(pos: list, ori: list)
Mini help class for Pose representation
- pos
- ori
- to_string() str
Serialize position and orientation components as a semicolon-delimited string.
- class icub_pybullet.utils.CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)
Custom formatter that assigns colors to logs From https://stackoverflow.com/a/56944256
- grey = '\x1b[97;10m'
- yellow = '\x1b[33;20m'
- red = '\x1b[31;20m'
- bold_red = '\x1b[31;1m'
- reset = '\x1b[0m'
- format = '%(module)s %(levelname)s: %(message)s'
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.
- FORMATS
- icub_pybullet.utils.JOINTS
- icub_pybullet.utils.JOINTS_IDS
- icub_pybullet.utils.CHAINS