robot_dart
robot_dart copied to clipboard
Saving images corrupted on MacOS Windowed mode
Hi @costashatz , here is an issue linked to the JOSS review https://github.com/openjournals/joss-reviews/issues/6771.
I figured out that the png export generates corrupted image (almost empty if I open the binary file). However, it works well in windowless mode... I adapted the hello_world.py example to provide a minimal test:
Does not work
# @HELLO_WORLD_INCLUDE_PYTHON@
import RobotDART as rd
# @HELLO_WORLD_INCLUDE_PYTHON_END@
# @HELLO_WORLD_ROBOT_CREATION_PYTHON@
robot = rd.Robot("pexod.urdf");
# @HELLO_WORLD_ROBOT_CREATION_PYTHON_END@
# @HELLO_WORLD_ROBOT_PLACING_PYTHON@
robot.set_base_pose([0., 0., 0., 0., 0., 0.2])
# @HELLO_WORLD_ROBOT_PLACING_PYTHON_END@
# @HELLO_WORLD_ROBOT_SIMU_PYTHON@
simu = rd.RobotDARTSimu(0.001); # dt=0.001, 1KHz simulation
simu.add_floor();
simu.add_robot(robot);
# @HELLO_WORLD_ROBOT_SIMU_PYTHON_END@
# @HELLO_WORLD_ROBOT_GRAPHIC_PYTHON@
configuration = rd.gui.GraphicsConfiguration()
configuration.shadowed = False # Prevent segfault shadow
graphics = rd.gui.Graphics(configuration)
simu.set_graphics(graphics)
graphics.look_at([0.5, 3., 0.75], [0.5, 0., 0.2])
# @HELLO_WORLD_ROBOT_GRAPHIC_PYTHON_END@
# @HELLO_WORLD_ROBOT_RUN_PYTHON@
simu.run(10.)
img = graphics.image()
rd.gui.save_png_image('Test.png', img)
# @HELLO_WORLD_ROBOT_RUN_PYTHON_END@
Works well
# @HELLO_WORLD_INCLUDE_PYTHON@
import RobotDART as rd
# @HELLO_WORLD_INCLUDE_PYTHON_END@
# @HELLO_WORLD_ROBOT_CREATION_PYTHON@
robot = rd.Robot("pexod.urdf");
# @HELLO_WORLD_ROBOT_CREATION_PYTHON_END@
# @HELLO_WORLD_ROBOT_PLACING_PYTHON@
robot.set_base_pose([0., 0., 0., 0., 0., 0.2])
# @HELLO_WORLD_ROBOT_PLACING_PYTHON_END@
# @HELLO_WORLD_ROBOT_SIMU_PYTHON@
simu = rd.RobotDARTSimu(0.001); # dt=0.001, 1KHz simulation
simu.add_floor();
simu.add_robot(robot);
# @HELLO_WORLD_ROBOT_SIMU_PYTHON_END@
# @HELLO_WORLD_ROBOT_GRAPHIC_PYTHON@
graphics = rd.gui.WindowlessGraphics()
simu.set_graphics(graphics)
graphics.look_at([0.5, 3., 0.75], [0.5, 0., 0.2])
# @HELLO_WORLD_ROBOT_GRAPHIC_PYTHON_END@
# @HELLO_WORLD_ROBOT_RUN_PYTHON@
simu.run(10.)
img = graphics.image()
rd.gui.save_png_image('Test.png', img)
# @HELLO_WORLD_ROBOT_RUN_PYTHON_END@