Is there a function to end the render window?

79 views
Skip to first unread message

Jay Sun

unread,
Sep 23, 2023, 10:19:11 PM9/23/23
to ProjectChrono
Hello everyone!

           I'm using pychrono now, I have met some problems.
           vis = veh. ChWheeledVehicleVisualSystemIrrlicht () is established a visual environment. while rendering, the while vis.Run() : loop is used. The condition for ending the loop is that when vis.Run() is False, making vis.Run() False can only be done by manually clicking the cross in the upper right corner of the rendering window (i.e., the close button). Is there a function that turns off the current rendering in the current program, or turns off the current button when a condition is triggered? (Example: time = my_hmmwv.GetSystem().getchtime (). if time > 1, end the render window.)
             Looking forward to your reply. Thanks very much!!!!

Regard,
Jay


1.png

Radu Serban

unread,
Sep 24, 2023, 3:43:35 AM9/24/23
to ProjectChrono

Simply use a ‘break’ statement.  See for example https://github.com/projectchrono/chrono/blob/main/src/demos/python/vehicle/demo_VEH_SteeringController.py

On a separate note, you can also interrupt the runtime visualization by pressing the escape key.

--Radu


--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/7a490c46-e882-4e6b-9614-aafceba3b8bdn%40googlegroups.com.

Jay Sun

unread,
Sep 24, 2023, 9:11:26 AM9/24/23
to ProjectChrono
Thank you very much for your reply. I am using the building reinforcement learning framework, the outer loop is for i_episode in range(sum_episode), the inner loop is the while loop for every action of the agent (i.e. while(vis.Run()), Using the break loop in the while inner loop does not kill the render window, but clicking the keyboard "esc" or clicking the cross in the upper right corner can kill the render window. I wonder if there is a function that simulates keyboard typing "esc" to kill Windows, or if there is a function that makes vis.Run() False. I record the screen (https://youtu.be/ZsANrfVMRqw), can focus on the task bar. The following image is the code for my main function.
1.png

Radu Serban

unread,
Sep 24, 2023, 10:10:35 AM9/24/23
to ProjectChrono

I see. In that case, you should be able to use:

env.vis.GetDevice().closeDevice()

(this is Irrlicht-specific).

 

Having said that, I just added a public function ChVisualSystem::Quit() which does this for all available runtime visualization systems.  With this, you’ll simply do:

env.vis.Quit()

If you are building PyChrono from sources, pull the latest code and rebuild. If you are using a conda package, it’ll take a while before new packages are regenerated and uploaded to anaconda.org.

 

--Radu

 

From: projec...@googlegroups.com <projec...@googlegroups.com> On Behalf Of Jay Sun
Sent: Sunday, September 24, 2023 3:11 PM
To: ProjectChrono <projec...@googlegroups.com>
Subject: Re: [chrono] Is there a function to end the render window?

 

Thank you very much for your reply. I am using the building reinforcement learning framework, the outer loop is for i_episode in range(sum_episode), the inner loop is the while loop for every action of the agent (i.e. while(vis.Run()), Using the break loop in the while inner loop does not kill the render window, but clicking the keyboard "esc" or clicking the cross in the upper right corner can kill the render window. I wonder if there is a function that simulates keyboard typing "esc" to kill Windows, or if there is a function that makes vis.Run() False. I record the screen (https://youtu.be/ZsANrfVMRqw), can focus on the task bar. The following image is the code for my main function.

2023924日星期日 UTC+8 15:43:35<Radu Serban> 写道:

Simply use a ‘break’ statement.  See for example https://github.com/projectchrono/chrono/blob/main/src/demos/python/vehicle/demo_VEH_SteeringController.py

On a separate note, you can also interrupt the runtime visualization by pressing the escape key.

--Radu

 

From: projec...@googlegroups.com <projec...@googlegroups.com> On Behalf Of Jay Sun
Sent: Sunday, September 24, 2023 4:19 AM
To: ProjectChrono <projec...@googlegroups.com>
Subject: [chrono] Is there a function to end the render window?

 

Hello everyone!

 

           I'm using pychrono now, I have met some problems.

           vis = veh. ChWheeledVehicleVisualSystemIrrlicht () is established a visual environment. while rendering, the while vis.Run() : loop is used. The condition for ending the loop is that when vis.Run() is False, making vis.Run() False can only be done by manually clicking the cross in the upper right corner of the rendering window (i.e., the close button). Is there a function that turns off the current rendering in the current program, or turns off the current button when a condition is triggered? (Example: time = my_hmmwv.GetSystem().getchtime (). if time > 1, end the render window.)

             Looking forward to your reply. Thanks very much!!!!

 

Regard,

Jay

 


--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/7a490c46-e882-4e6b-9614-aafceba3b8bdn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.

Jay Sun

unread,
Sep 24, 2023, 10:32:40 AM9/24/23
to ProjectChrono
Has been a success! Thank you very much!!!!
Reply all
Reply to author
Forward
0 new messages