Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving images corrupted on MacOS Windowed mode #209

Closed
c-joly opened this issue Jul 2, 2024 · 1 comment
Closed

Saving images corrupted on MacOS Windowed mode #209

c-joly opened this issue Jul 2, 2024 · 1 comment
Assignees

Comments

@c-joly
Copy link

c-joly commented Jul 2, 2024

Hi @costashatz , here is an issue linked to the JOSS review openjournals/joss-reviews#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@
@costashatz costashatz self-assigned this Jul 12, 2024
@costashatz
Copy link
Member

This should be fixed by 9412aa2. I basically added a few lines describing possible issues so that Mac users are aware that the GUI is not working as expected. For this specific issue, I still believe that this is a problem of HiDPI but haven't been able to pin it down. I added an issue to have a look on HiDPI in total (see #223). @c-joly let me know if I forgot something or if you are not happy with what I wrote in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants