From ccf061e51d299e464c2237254d9dcc1b08900531 Mon Sep 17 00:00:00 2001 From: Carlotta Date: Thu, 18 Apr 2024 18:38:30 +0200 Subject: [PATCH] balck formatting --- src/adam/casadi/computations.py | 2 +- src/adam/model/std_factories/std_model.py | 26 ++++++++++--------- .../parametric_factories/parametric_link.py | 4 +-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/adam/casadi/computations.py b/src/adam/casadi/computations.py index 6b3c9836..ca7a9e8d 100644 --- a/src/adam/casadi/computations.py +++ b/src/adam/casadi/computations.py @@ -27,7 +27,7 @@ def __init__( ) -> None: """ Args: - urdfstring (str): either path or string of the urdf + urdfstring (str): either path or string of the urdf joints_name_list (list): list of the actuated joints root_link (str, optional): the first link. Defaults to 'root_link'. """ diff --git a/src/adam/model/std_factories/std_model.py b/src/adam/model/std_factories/std_model.py index 0555159e..11f81e55 100644 --- a/src/adam/model/std_factories/std_model.py +++ b/src/adam/model/std_factories/std_model.py @@ -1,7 +1,7 @@ import pathlib from typing import List import xml.etree.ElementTree as ET -import os +import os import urdf_parser_py.urdf from adam.core.spatial_math import SpatialMath @@ -34,12 +34,12 @@ def __init__(self, urdf_string: str, math: SpatialMath): self.math = math isPath = False isUrdf = False - # Checking if it is a path or an urdf - if(type(urdf_string) is not(pathlib.Path)): - if(os.path.exists(urdf_string)): + # Checking if it is a path or an urdf + if type(urdf_string) is not (pathlib.Path): + if os.path.exists(urdf_string): urdf_string = pathlib.Path(urdf_string) - isPath= True - else: + isPath = True + else: root = ET.fromstring(urdf_string) robot_el = None for elem in root.iter(): @@ -50,16 +50,18 @@ def __init__(self, urdf_string: str, math: SpatialMath): elif urdf_string.exists(): isPath = True - if(not(isPath) and not(isUrdf)): - raise ValueError(f"Invalid urdf string: {urdf_string}. It is neither a path nor a urdf string") - - if(isPath): - if(not(urdf_string.exists())): + if not (isPath) and not (isUrdf): + raise ValueError( + f"Invalid urdf string: {urdf_string}. It is neither a path nor a urdf string" + ) + + if isPath: + if not (urdf_string.exists()): raise FileExistsError(path) urdf_string = pathlib.Path(urdf_string) xml_file = open(urdf_string, "r") xml_string = xml_file.read() - xml_file.close() + xml_file.close() # Read URDF, but before passing it to urdf_parser_py get rid of all sensor tags # sensor tags are valid elements of URDF (see ), # but they are ignored by urdf_parser_py, that complains every time it sees one. diff --git a/src/adam/parametric/model/parametric_factories/parametric_link.py b/src/adam/parametric/model/parametric_factories/parametric_link.py index c9ae02be..cfdf729f 100644 --- a/src/adam/parametric/model/parametric_factories/parametric_link.py +++ b/src/adam/parametric/model/parametric_factories/parametric_link.py @@ -162,7 +162,7 @@ def compute_volume(self, length_multiplier): volume = math.pi * visual_data_new[1] ** 2 * visual_data_new[0] elif self.geometry_type == Geometry.SPHERE: visual_data_new = self.visual_data.radius * length_multiplier - volume = 4 * math.pi * visual_data_new**3 / 3 + volume = 4 * math.pi * visual_data_new ** 3 / 3 return volume, visual_data_new def compute_mass(self): @@ -235,7 +235,7 @@ def compute_inertia_parametric(self): I.izz = I.iyy return I elif self.geometry_type == Geometry.SPHERE: - I.ixx = 2 * self.mass * self.visual_data_new**2 / 5 + I.ixx = 2 * self.mass * self.visual_data_new ** 2 / 5 I.iyy = I.ixx I.izz = I.ixx return I