Animate URDF Robot with trajectory of end effector #153
-
I ma trying to animate robot from urdf with trajectory of end effector in the same time. How to do it in one animation callback? How to show the history of motion of end effector of robot and keeping trajectory while robot is moving in the same time? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
If your question is about how to animate multiple "artists" in general and not about robots and lines specifically, here is an example that I am currently working with: class AnimationCallback: # animation callback as callable object (defines __call__ method)
def __init__(self, fig, pipeline, show_object, show_robot):
self.fig = fig
self.show_object = show_object
self.show_robot = show_robot
...
if self.show_object:
self.object_frame = pv.Frame(np.eye(4), s=0.1)
self.object_frame.add_artist(self.fig)
if self.show_robot:
self.robot = pipeline.make_robot_artist()
self.robot.add_artist(self.fig)
def __call__(self, t, markers, dataset, pipeline):
markers.set_data(dataset.get_markers(t))
artists = [markers]
if self.show_object:
object_pose = ... # compute object_pose
self.object_frame.set_data(object_pose)
artists.append(self.object_frame)
if self.show_robot:
angle = ... # compute new angle, in my case the pipeline object does this
self.robot.tm.set_joint("joint_name", angle) # update robot configuration
self.robot.set_data()
artists.append(self.robot)
return artists # return a tuple or a list of artists
...
markers = ... # an artist that represents several sphere meshes
pipeline = ... # contains some algorithm that computes robot joint angles
dataset = ... # data based on which the pipeline object operates
n_steps = ... # number of steps
from pytransform3d import visualizer as pv
fig = pv.figure()
animation_callback = AnimationCallback(fig, pipeline, True, True)
fig.animate(
animation_callback, n_steps, loop=True,
fargs=(markers, dataset, pipeline)) You can also find further information here: https://rock-learning.github.io/pytransform3d/_apidoc/pytransform3d.visualizer.Figure.html#pytransform3d.visualizer.Figure.animate |
Beta Was this translation helpful? Give feedback.
If your question is about how to animate multiple "artists" in general and not about robots and lines specifically, here is an example that I am currently working with: