Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frames support #12

Merged
merged 2 commits into from
Oct 19, 2022
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
2 changes: 1 addition & 1 deletion src/rod/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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)