Skip to content

Commit b134a07

Browse files
authored
Merge pull request #425 from LonelyPaprika/feature/add_q_attribute_vel_damper
added the attribute q to joint velocity damper method
2 parents a7f23f3 + 4142b43 commit b134a07

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

roboticstoolbox/robot/Robot.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,7 @@ def collided(self, q, shape: Shape, skip: bool = False) -> bool:
13551355

13561356
def joint_velocity_damper(
13571357
self,
1358+
q=None,
13581359
ps: float = 0.05,
13591360
pi: float = 0.1,
13601361
n: Union[int, None] = None,
@@ -1392,16 +1393,19 @@ def joint_velocity_damper(
13921393

13931394
if n is None:
13941395
n = self.n
1396+
1397+
if q is None:
1398+
q = np.copy(self.q)
13951399

13961400
Ain = np.zeros((n, n))
13971401
Bin = np.zeros(n)
13981402

13991403
for i in range(n):
14001404
if self.q[i] - self.qlim[0, i] <= pi:
1401-
Bin[i] = -gain * (((self.qlim[0, i] - self.q[i]) + ps) / (pi - ps))
1405+
Bin[i] = -gain * (((self.qlim[0, i] - q[i]) + ps) / (pi - ps))
14021406
Ain[i, i] = -1
14031407
if self.qlim[1, i] - self.q[i] <= pi:
1404-
Bin[i] = gain * ((self.qlim[1, i] - self.q[i]) - ps) / (pi - ps)
1408+
Bin[i] = gain * ((self.qlim[1, i] - q[i]) - ps) / (pi - ps)
14051409
Ain[i, i] = 1
14061410

14071411
return Ain, Bin

0 commit comments

Comments
 (0)