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

How could one plot rtb.models.DH.plot and spatialmath.base.trplot() in the same figure?

Open rojas70 opened this issue 4 years ago • 4 comments

For the inverse kinematics portion, in matlab it was easy to plot both the robot's current configuration as well as the desired pose configuration.

I have not found a way to fix the figure upon which both of these methods plot...

rojas70 avatar Feb 10 '21 14:02 rojas70

Pls send a minimal example that shows the problem.

petercorke avatar Feb 11 '21 08:02 petercorke

# Imports
from spatialmath import *
from spatialmath.base import *
from roboticstoolbox import *
import matplotlib.pyplot as plt

# Puma
puma = rtb.models.DH.Puma560()

# Start at qn and plot 
puma.plot(puma.qn)

# Desired pose and plot
T = SE3(0.6, 0.1, 0.5)*SE3().RPY([0, 0, 0], unit='deg')
trplot(T.A, dims=[-2,2], frame='EE', rviz=True)                 # plots not superposed here.

Plots not easily superposed here... can use plt.ion(), but I notice that when the coordinates are loaded, the robot shrinks.

Continue to display the robot solution:

# Desired angles... analytic/numerical solns
sol = puma.ikine_LM(T, q0=puma.qn)
puma.plot(sol.q);                                             

New figure opens up. We are not able to see a nice overlap of the solution with the desired pose as is.

rojas70 avatar Feb 22 '21 09:02 rojas70

I get this

The axes are a bit big, but otherwise OK.

Maybe do

puma.plot(puma.qn, block=False)

So that you don’t have to dismiss the Puma plot before doing the next plot.

At the moment, by default all RTB plots are blocking, but I’m not sure now that’s such a great idea. Let me know how it goes.

Peter

On 22 Feb 2021, at 7:39 pm, Dr. Juan Rojas [email protected] wrote:

Imports

import math import numpy as np

from spatialmath import * from spatialmath.base import *

import roboticstoolbox as rtb from roboticstoolbox import *

import matplotlib.pyplot as plt

Puma

puma = rtb.models.DH.Puma560()

Start at qn and plot

puma.plot(puma.qn)

Desired pose and plot

T = SE3(0.6, 0.1, 0.5)*SE3().RPY([0, 0, 0], unit='deg') trplot(T.A, dims=[-2,2], frame='EE', rviz=True) # plots not superposed here.

Desired angles... analytic/numerical solns

sol = puma.ikine_LM(T, q0=puma.qn) puma.plot(sol.q); # Would like to see the robot des pose to be superposed over the trplot frame version. — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/petercorke/robotics-toolbox-python/issues/173#issuecomment-783238791, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2BIURSHB76KHCUIQODAMLTAIQ4DANCNFSM4XNCZQ2A.

petercorke avatar Feb 23 '21 03:02 petercorke

Thank you.

The block=False, works nicely for the first part, however, the second puma.plot resets the figure and overwrites it... It would be nice to use the same figure/axes there. Perhaps have an option to set which fig/axes to use.

rojas70 avatar Feb 23 '21 05:02 rojas70