Closed wxmerkt closed 11 months ago
In GitLab by @nmansard on Apr 18, 2019, 10:53
In GitLab by @cmastalli on Apr 18, 2019, 11:03
displayTrajectory
can only display one robot. It displays the entire motion for a single robot. If you want to display more than one robot you need to do something like this:
def displayTrajectory(robots, Xs, dt=0.1):
""" Display a robot trajectory xs using Gepetto-viewer gui.
:param robots: set of Robot wrappers
:param xs: set of state trajectory
:param dt: step duration
:param rate: visualization rate
:param cameraTF: camera transform
"""
if not hasattr(robot, 'viewer'):
for r in robots:
r.initDisplay(loadModel=True)
import numpy as np
def a2m(a):
return np.matrix(a).T
import time
length_traj = len(Xs[0]) # assert this for each case
for i in range(length_traj):
for r, robot in enumerate(robots):
x = Xs[r][i]
robot.display(a2m(x[:robot.nq]))
time.sleep(dt)
This kind of code is needed if you want to do something like this: https://youtu.be/C0h-NLdMVuc
In GitLab by @cmastalli on Apr 18, 2019, 11:08
I forgot to include an option to add a floor.
Do you think we need to request this stuff in GV? I was thinking that Crocoddyl should have its own GUI wrapper that displays the robot (and sets up background and floor) and remove RobotWrapper dependency.
In GitLab by @cmastalli on Apr 18, 2019, 10:18
There is a list of things that we should improve:
displayTrajectory
might be use a stack of robots. This will render multiple robots and trajectories.