Skip to content

Commit

Permalink
Add speed value setter in MotionStateArray
Browse files Browse the repository at this point in the history
  • Loading branch information
omersahintas committed Feb 22, 2023
1 parent 51784e6 commit 2c90ee7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions p3iv_types/src/p3iv_types/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ def append(self, other):
def speed(self):
return np.linalg.norm(self.velocity.mean, axis=1)

@speed.setter
def speed(self, speed_yaw):
"""Use speed and yaw angle (in radians) to set velocity values."""
speed, yaw_radians = speed_yaw
velocity = np.empty([len(speed), 2])
velocity[:, 0] = speed * np.cos(yaw_radians)
velocity[:, 1] = speed * np.sin(yaw_radians)
self.velocity.mean = velocity


class MotionControl(object):
"""
Expand Down

0 comments on commit 2c90ee7

Please sign in to comment.