8000 add method for random joint config · oridong/robotics-toolbox-python@e8c594e · GitHub
[go: up one dir, main page]

Skip to content

Commit e8c594e

Browse files
committed
add method for random joint config
1 parent 9616da0 commit e8c594e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

roboticstoolbox/robot/Robot.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,25 @@ def n(self):
210210
"""
211211
return self._n
212212

213+
@property
214+
def qrandom(self):
215+
"""
216+
Return a random joint configuration
217+
218+
:return: Random joint configuration :rtype: ndarray(n)
219+
220+
The value for each joint is uniform randomly distributed between the
221+
limits set for the robot.
222+
223+
.. note:: The joint limit for all joints must be set.
224+
225+
:seealso: :func:`Robot.qlim`, :func:`Link.qlim`
226+
"""
227+
qlim = self.qlim
228+
if np.any(np.isnan(qlim)):
229+
raise ValueError('some joint limits not defined')
230+
return np.random.uniform(low=qlim[0, :], high=qlim[1, :], size=(self.n,))
231+
213232
def addconfiguration(self, name, q, unit='rad'):
214233
"""
215234
Add a named joint configuration (Robot superclass)

0 commit comments

Comments
 (0)
0