Skip to content

Commit

Permalink
Merge pull request #12 from ami-iit/feature/frames
Browse files Browse the repository at this point in the history
Add frames support
  • Loading branch information
diegoferigo authored Oct 19, 2022
2 parents 87bab1c + 1dd8739 commit acb3187
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rod/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import logging
from .collision import Collision
from .common import Pose, Xyz
from .common import Frame, Pose, Xyz
from .geometry import (
Box,
Capsule,
Expand Down
12 changes: 12 additions & 0 deletions src/rod/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,15 @@ def xyz(self) -> List[float]:
@property
def rpy(self) -> List[float]:
return self.pose[3:6]


@dataclasses.dataclass
class Frame(Element):

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

attached_to: Optional[str] = dataclasses.field(
default=None, metadata=mashumaro.field_options(alias="@attached_to")
)

pose: Optional[Pose] = dataclasses.field(default=None)
4 changes: 3 additions & 1 deletion src/rod/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import mashumaro

from .common import Pose
from .common import Frame, Pose
from .element import Element
from .joint import Joint
from .link import Link
Expand Down Expand Up @@ -54,6 +54,8 @@ class Model(Element):

model: Optional[Union["Model", List["Model"]]] = dataclasses.field(default=None)

frame: Optional[Union[Frame, List[Frame]]] = dataclasses.field(default=None)

link: Optional[Union[Link, List[Link]]] = dataclasses.field(default=None)

joint: Optional[Union[Joint, List[Joint]]] = dataclasses.field(default=None)
3 changes: 3 additions & 0 deletions src/rod/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import mashumaro.mixins.dict

from .common import Frame
from .element import Element
from .model import Model
from .physics import Physics
Expand Down Expand Up @@ -35,3 +36,5 @@ class World(Element):
scene: Scene = dataclasses.field(default_factory=Scene)

model: Optional[Union[Model, List[Model]]] = dataclasses.field(default=None)

frame: Optional[Union[Frame, List[Frame]]] = dataclasses.field(default=None)

0 comments on commit acb3187

Please sign in to comment.