Skip to content

Commit

Permalink
(pykdl_ros) add Zero/Identity classmethods
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Sep 8, 2023
1 parent 01b030c commit 7a7d4fc
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions pykdl_ros/pykdl_ros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ def __ne__(self, other):
def __hash__(self):
return hash((self.frame, self.header.frame_id))

@classmethod
def Identity(cls, stamp: Time, frame_id: str) -> FrameStamped:
"""
Construct a FrameStamped object with identity frame.
:param stamp: TimeStamp
:param frame_id: Frame ID
:return: Filled object
"""
frame = kdl.Frame.Identity()
return cls(frame, stamp, frame_id)

@classmethod
def from_xyz_rpy(
cls, x: float, y: float, z: float, roll: float, pitch: float, yaw: float, stamp: Time, frame_id: str
Expand Down Expand Up @@ -101,6 +113,18 @@ def __ne__(self, other):
def __hash__(self):
return hash((self.twist, self.header.frame_id))

@classmethod
def Zero(cls, stamp: Time, frame_id: str) -> TwistStamped:
"""
Construct a TwistStamped object with zero velocity and angular velocity.
:param stamp: TimeStamp
:param frame_id: Frame ID
:return: Filled object
"""
twist = kdl.Twist.Zero()
return cls(twist, stamp, frame_id)

@classmethod
def from_xyz_rpy(cls, vx: float, vy: float, vz: float, wx: float, wy: float, wz: float, stamp: Time, frame_id: str):
"""
Expand Down Expand Up @@ -157,6 +181,18 @@ def __ne__(self, other):
def __hash__(self):
return hash((self.vector, self.header.frame_id))

@classmethod
def Zero(cls, stamp: Time, frame_id: str) -> VectorStamped:
"""
Construct a VectorStamped object with zero vector.
:param stamp: TimeStamp
:param frame_id: Frame ID
:return: Filled object
"""
vector = kdl.Vector.Zero()
return cls(vector, stamp, frame_id)

@classmethod
def from_xyz(cls, x: float, y: float, z: float, stamp: Time, frame_id: str) -> VectorStamped:
"""
Expand Down Expand Up @@ -219,6 +255,18 @@ def __ne__(self, other):
def __hash__(self):
return hash((self.wrench, self.header.frame_id))

@classmethod
def Zero(cls, stamp: Time, frame_id: str) -> WrenchStamped:
"""
Construct a WrenchStamped object with zero force and torque.
:param stamp: TimeStamp
:param frame_id: Frame ID
:return: Filled object
"""
wrench = kdl.Wrench.Zero()
return cls(wrench, stamp, frame_id)

@classmethod
def from_fxfyfz_txtytz(
cls, fx: float, fy: float, fz: float, tx: float, ty: float, tz: float, stamp: Time, frame_id: str
Expand Down

0 comments on commit 7a7d4fc

Please sign in to comment.