robotics-toolbox-python icon indicating copy to clipboard operation
robotics-toolbox-python copied to clipboard

robottoolkit corrupts matplotlib namespace, can't use plot normally

Open walchko opened this issue 3 years ago • 0 comments

roboticstoolbox-python: 0.11.0 matplotlib: 3.5.1 numpy: 1.22.3

Trying to use roboticstoolkit and matplotlib seem impossible. Somehow your toolbox is corrupting matplotlibs plot command ... can you fix this? Seems unnecessary to pollute the namespace such that I can no longer call plt.plot anymore.

plt.plot([1,2,3])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [45], in <cell line: 1>()
----> 1 plt.plot([1,2,3])

File ~/robottoolkit/lib/python3.9/site-packages/matplotlib/pyplot.py:2757, in plot(scalex, scaley, data, *args, **kwargs)
   2755 @_copy_docstring_and_deprecators(Axes.plot)
   2756 def plot(*args, scalex=True, scaley=True, data=None, **kwargs):
-> 2757     return gca().plot(
   2758         *args, scalex=scalex, scaley=scaley,
   2759         **({"data": data} if data is not None else {}), **kwargs)

TypeError: plot() missing 1 required positional argument: 'ys'

oh, before I tried to use matplotlib, I did:

robot = rtb.models.DH.Puma560()

T = SE3(0.5, 0.2, 0.1) * SE3.OA([0, 1, 0], [0, 0, -1])
print(T)

sol = robot.ikine_LM(T)  # solve IK
q_pickup = sol.q
qt = rtb.jtraj(robot.qr, q_pickup, 50)

robot.plot(q=qt.q, backend='pyplot', dt=0.050)

walchko avatar Apr 16 '22 17:04 walchko