Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: "3.10"

- name: Install Python tools
run: pip install build twine
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
# - "3.11"
- "3.11"

steps:

Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: '🐍 Initialize Python'
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.10"

- name: "📝 Black Code Formatter"
uses: psf/black@stable
Expand All @@ -42,7 +42,10 @@ jobs:
- name: '🐍 Initialize Python'
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.10"

# Workaround for https://github.com/isort/isort-action/issues/70
- run: pip install colorama

- name: "📝 isort"
uses: isort/isort-action@master
Expand Down
1 change: 0 additions & 1 deletion src/rod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


def _is_editable():

import importlib.util
import pathlib
import site
Expand Down
Empty file added src/rod/builder/__init__.py
Empty file.
13 changes: 0 additions & 13 deletions src/rod/kinematics/kinematic_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@

@dataclasses.dataclass(frozen=True)
class KinematicTree(DirectedTree):

model: "rod.Model"

joints: List[TreeEdge] = dataclasses.field(default_factory=list)
frames: List[TreeFrame] = dataclasses.field(default_factory=list)

def __post_init__(self):

# Initialize base class
super().__post_init__()

Expand Down Expand Up @@ -49,7 +47,6 @@ def joint_names(self) -> List[str]:

@staticmethod
def build(model: "rod.Model", is_top_level: bool = True) -> "KinematicTree":

logging.debug(msg=f"Building kinematic tree of model '{model.name}'")

if model.model is not None:
Expand Down Expand Up @@ -130,7 +127,6 @@ def build(model: "rod.Model", is_top_level: bool = True) -> "KinematicTree":

# Use joints to connect nodes by defining their parent and children
for joint in model.joints():

if joint.child == TreeFrame.WORLD:
msg = f"A joint cannot have '{TreeFrame.WORLD}' as child"
raise RuntimeError(msg)
Expand Down Expand Up @@ -184,7 +180,6 @@ def build(model: "rod.Model", is_top_level: bool = True) -> "KinematicTree":
expected_num_extra_joints = 1 if model.is_fixed_base() else 0

if found_num_extra_joints != expected_num_extra_joints:

if model.is_fixed_base() and found_num_extra_joints == 0:
raise RuntimeError("Failed to find joint connecting the model to world")

Expand All @@ -193,7 +188,6 @@ def build(model: "rod.Model", is_top_level: bool = True) -> "KinematicTree":

# Handle connection to world of fixed-base models
if model.is_fixed_base():

assert len(joints_not_in_tree) == 1
world_to_base_joint = joints_not_in_tree[0]

Expand Down Expand Up @@ -227,7 +221,6 @@ def build(model: "rod.Model", is_top_level: bool = True) -> "KinematicTree":
assert world_node is not None

else:

# Remove the world node from the nodes dictionary since it's unconnected...
world_node = nodes_links_dict.pop(TreeFrame.WORLD)

Expand Down Expand Up @@ -260,7 +253,6 @@ def build(model: "rod.Model", is_top_level: bool = True) -> "KinematicTree":
def remove_edge(
edge: TreeEdge, keep_parent: bool = True
) -> Tuple[DirectedTreeNode, Sequence[TreeFrame]]:

# Removed node: the node to remove.
# Replaced node: the node removed and replaced with the new node.
# New node: the new node that combines the removed and replaced nodes.
Expand Down Expand Up @@ -292,7 +284,6 @@ def remove_edge(

# Check if a link has non-trivial inertial parameters
def has_zero_inertial(link: rod.Link) -> bool:

if not isinstance(link, rod.Link):
return True

Expand All @@ -319,20 +310,16 @@ def has_zero_inertial(link: rod.Link) -> bool:

@functools.cached_property
def links_dict(self) -> Dict[str, DirectedTreeNode]:

return self.nodes_dict

@functools.cached_property
def frames_dict(self) -> Dict[str, TreeFrame]:

return {frame.name(): frame for frame in self.frames}

@functools.cached_property
def joints_dict(self) -> Dict[str, TreeEdge]:

return {joint.name(): joint for joint in self.joints}

@functools.cached_property
def joints_connection_dict(self) -> Dict[Tuple[str, str], TreeEdge]:

return {(j.parent.name(), j.child.name()): j for j in self.joints}
7 changes: 0 additions & 7 deletions src/rod/kinematics/tree_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

@dataclasses.dataclass
class TreeTransforms:

kinematic_tree: KinematicTree = dataclasses.dataclass(init=False)

@staticmethod
Expand All @@ -20,7 +19,6 @@ def build(
is_top_level: bool = True,
prevent_switching_frame_convention: bool = False,
) -> "TreeTransforms":

model = copy.deepcopy(model)

model.resolve_frames(is_top_level=is_top_level, explicit_frames=True)
Expand All @@ -33,18 +31,15 @@ def build(
)

def transform(self, name: str) -> npt.NDArray:

if name == TreeFrame.WORLD:
return np.eye(4)

if name in {TreeFrame.MODEL, self.kinematic_tree.model.name}:

relative_to = self.kinematic_tree.model.pose.relative_to
assert relative_to in {None, ""}, (relative_to, name)
return self.kinematic_tree.model.pose.transform()

if name in self.kinematic_tree.joint_names():

edge = self.kinematic_tree.joints_dict[name]
assert edge.name() == name

Expand All @@ -63,7 +58,6 @@ def transform(self, name: str) -> npt.NDArray:
name in self.kinematic_tree.link_names()
or name in self.kinematic_tree.frame_names()
):

element = (
self.kinematic_tree.links_dict[name]
if name in self.kinematic_tree.link_names()
Expand All @@ -84,7 +78,6 @@ def transform(self, name: str) -> npt.NDArray:
raise ValueError(name)

def relative_transform(self, relative_to: str, name: str) -> npt.NDArray:

return np.linalg.inv(self.transform(name=relative_to)) @ self.transform(
name=name
)
11 changes: 0 additions & 11 deletions src/rod/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class LoggingLevel(enum.IntEnum):

NOTSET = logging.NOTSET
DEBUG = logging.DEBUG
INFO = logging.INFO
Expand All @@ -18,26 +17,22 @@ class LoggingLevel(enum.IntEnum):


def _logger() -> logging.Logger:

return logging.getLogger(name=LOGGER_NAME)


def set_logging_level(level: Union[int, LoggingLevel] = LoggingLevel.WARNING):

if isinstance(level, int):
level = LoggingLevel(level)

_logger().setLevel(level=level.value)


def get_logging_level() -> LoggingLevel:

level = _logger().getEffectiveLevel()
return LoggingLevel(level)


def configure(level: LoggingLevel = LoggingLevel.WARNING) -> None:

info(f"Configuring the '{LOGGER_NAME}' logger")

handler = logging.StreamHandler()
Expand All @@ -53,30 +48,24 @@ def configure(level: LoggingLevel = LoggingLevel.WARNING) -> None:


def debug(msg: str = "") -> None:

_logger().debug(msg=msg)


def info(msg: str = "") -> None:

_logger().info(msg=msg)


def warning(msg: str = "") -> None:

_logger().warning(msg=msg)


def error(msg: str = "") -> None:

_logger().error(msg=msg)


def critical(msg: str = "") -> None:

_logger().critical(msg=msg)


def exception(msg: str = "") -> None:

_logger().exception(msg=msg)
7 changes: 0 additions & 7 deletions src/rod/pretty_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

class DataclassPrettyPrinter(abc.ABC):
def to_string(self) -> str:

return DataclassPrettyPrinter.dataclass_to_str(obj=self, level=1)

@staticmethod
def list_to_string(obj: List[Any], level: int = 1) -> str:

if not isinstance(obj, list):
raise TypeError(obj, type(obj))

Expand All @@ -37,37 +35,32 @@ def list_to_string(obj: List[Any], level: int = 1) -> str:

@staticmethod
def dataclass_to_str(obj: Any, level: int = 1) -> str:

if not dataclasses.is_dataclass(obj):
raise TypeError(obj, type(obj))

serialization: List[Tuple[str, str]] = []

for field in dataclasses.fields(obj):

attr = getattr(obj, field.name)

if attr is None or attr == "":
continue

elif isinstance(attr, list):

list_str = DataclassPrettyPrinter.list_to_string(
obj=attr, level=level + 1
)
serialization += [(field.name, list_str)]
continue

elif dataclasses.is_dataclass(attr):

dataclass_str = DataclassPrettyPrinter.dataclass_to_str(
obj=attr, level=level + 1
)
serialization += [(field.name, dataclass_str)]
continue

else:

serialization += [(field.name, f"{attr!s}")]
continue

Expand Down
1 change: 0 additions & 1 deletion src/rod/sdf/collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

@dataclasses.dataclass
class Collision(Element):

geometry: Geometry
name: str = dataclasses.field(metadata=mashumaro.field_options(alias="@name"))

Expand Down
7 changes: 0 additions & 7 deletions src/rod/sdf/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

@dataclasses.dataclass
class Xyz(Element):

xyz: List[float] = dataclasses.field(
default=None,
metadata=mashumaro.field_options(
Expand All @@ -25,7 +24,6 @@ class Xyz(Element):

@classmethod
def __pre_deserialize__(cls, d: Dict[Any, Any]) -> Dict[Any, Any]:

if isinstance(d, str):
d = {"#text": d, "@expressed_in": ""}

Expand All @@ -34,7 +32,6 @@ def __pre_deserialize__(cls, d: Dict[Any, Any]) -> Dict[Any, Any]:

@dataclasses.dataclass
class Pose(Element):

pose: List[float] = dataclasses.field(
default=None,
metadata=mashumaro.field_options(
Expand All @@ -58,7 +55,6 @@ class Pose(Element):

@classmethod
def __pre_deserialize__(cls, d: Dict[Any, Any]) -> Dict[Any, Any]:

if isinstance(d, str):
d = {"#text": d, "@relative_to": ""}

Expand All @@ -73,7 +69,6 @@ def rpy(self) -> List[float]:
return self.pose[3:6]

def transform(self) -> npt.NDArray:

import numpy as np
from scipy.spatial.transform import Rotation as R

Expand All @@ -95,7 +90,6 @@ def transform(self) -> npt.NDArray:

@staticmethod
def from_transform(transform: npt.NDArray, relative_to: str = None) -> "Pose":

if transform.shape != (4, 4):
raise ValueError(transform.shape)

Expand All @@ -109,7 +103,6 @@ def from_transform(transform: npt.NDArray, relative_to: str = None) -> "Pose":

@dataclasses.dataclass
class Frame(Element):

name: str = dataclasses.field(metadata=mashumaro.field_options(alias="@name"))

attached_to: Optional[str] = dataclasses.field(
Expand Down
Loading