Skip to content

Commit

Permalink
Merge pull request #425 from LonelyPaprika/feature/add_q_attribute_ve…
Browse files Browse the repository at this point in the history
…l_damper

added the attribute q to joint velocity damper method
  • Loading branch information
jhavl committed Aug 7, 2024
2 parents a7f23f3 + 4142b43 commit b134a07
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions roboticstoolbox/robot/Robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ def collided(self, q, shape: Shape, skip: bool = False) -> bool:

def joint_velocity_damper(
self,
q=None,
ps: float = 0.05,
pi: float = 0.1,
n: Union[int, None] = None,
Expand Down Expand Up @@ -1392,16 +1393,19 @@ def joint_velocity_damper(

if n is None:
n = self.n

if q is None:
q = np.copy(self.q)

Ain = np.zeros((n, n))
Bin = np.zeros(n)

for i in range(n):
if self.q[i] - self.qlim[0, i] <= pi:
Bin[i] = -gain * (((self.qlim[0, i] - self.q[i]) + ps) / (pi - ps))
Bin[i] = -gain * (((self.qlim[0, i] - q[i]) + ps) / (pi - ps))
Ain[i, i] = -1
if self.qlim[1, i] - self.q[i] <= pi:
Bin[i] = gain * ((self.qlim[1, i] - self.q[i]) - ps) / (pi - ps)
Bin[i] = gain * ((self.qlim[1, i] - q[i]) - ps) / (pi - ps)
Ain[i, i] = 1

return Ain, Bin
Expand Down

0 comments on commit b134a07

Please sign in to comment.