Gepetto / gepetto-viewer

Graphical Interface for Pinocchio and HPP.
BSD 2-Clause "Simplified" License
44 stars 30 forks source link

[Ubuntu 18.04] gui items disappear behind transparent robot #97

Closed stanislas-brossette closed 5 years ago

stanislas-brossette commented 5 years ago

Hello, I'm using gepette-gui to visualize robot trajectories and physical quantities like CoM/CoP/DCM... The issue I'm facing is that when displaying a transparent robot and a sphere representing the CoP, that sphere disappears behind the transparent robot, while the floor is clearly visible behind the robot. Below is the core code that I use for displaying the scene. Am I missing something or is that a bug/shortcoming?

from pinocchio.robot_wrapper import RobotWrapper

robot = RobotWrapper()
colorized_urdf = get_colorized_urdf(urdf_path, (1,1,1,0.7))
robot.initFromURDF(colorized_urdf, [root_path], pinocchio.JointModelFreeFlyer())
robot.initDisplay()
robot.viewer.gui.addFloor('hpp-gui/floor')
robot.loadDisplayModel('my_robot')
robot.display(utils.array_to_matrix(model_positions[:, 0]))
robot.viewer.gui.addSphere('current_CoP', 0.02, [1, 0, 0, 1])
robot.viewer.gui.addLine('current_CoP_line', [0.0, .0, 0.0], [0.0, 0.0, 0.3], [1, 0, 0, 1])
robot.viewer.gui.addToGroup('current_CoP', 'world')
robot.viewer.gui.addToGroup('current_CoP_line', 'world')

wait_for_start()

for i in range(len(times) - 1):
        robot.display(utils.array_to_matrix(model_positions[:, i]))
        dt = (times[i + 1] - times[i]) / speed
        if dt > 0.:
            time.sleep(dt)
        robot.viewer.gui.applyConfiguration('current_CoP', (cop[:, i].tolist() + [0.0, 0.0, 0.0, 1.0]))
        robot.viewer.gui.applyConfiguration('current_CoP_line', (cop[:, i].tolist() + [0.0, 0.0, 0.0, 1.0]))

    robot.display(utils.array_to_matrix(model_positions[:, -1]))
jmirabel commented 5 years ago

Hi,

you hit two points:

Can you try to add a robot.viewer.gui.setFloatProperty("nodename", "Transparency", desiredAlpha) ?

stanislas-brossette commented 5 years ago

The setFloatProperty method fixed the problem, thank you :)

jmirabel commented 5 years ago

In next version, "Transparency" will be replaced by "Alpha" to fix the incoherent behavior.