Skip to content

Commit

Permalink
balck formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlottaSartore committed Apr 18, 2024
1 parent 58eda31 commit ccf061e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/adam/casadi/computations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
"""
Expand Down
26 changes: 14 additions & 12 deletions src/adam/model/std_factories/std_model.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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():
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ccf061e

Please sign in to comment.