ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

how can you check that gazebo gui is fully started?

asked 2023-04-28 06:03:39 -0500

vane gravatar image

How can I check (programmatically) if the gazebo GUI is fully loaded and the scene is visible? I use ROS2 Foxy and Gazebo Classic at the moment

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-04-28 16:40:22 -0500

hunterlineage1 gravatar image

To programmatically check if the Gazebo GUI is fully loaded and the scene is visible, you can use the gzclient tool to check if the Gazebo client process is running. Here's an example Python code that you can use:

import subprocess
import time

def is_gazebo_ready():
    ps_output = subprocess.check_output(['ps', 'aux'])
    ps_output_str = ps_output.decode('utf-8')
    if 'gzclient' in ps_output_str:
        return True
    else:
        return False

if __name__ == '__main__':
    while not is_gazebo_ready():
        time.sleep(1)
    print('Gazebo is ready')

This code uses the subprocess module to execute the ps command and get the list of running processes. It then checks if the gzclient process is running by searching for it in the process list. If the gzclient process is found, it means that the Gazebo GUI is fully loaded and the scene is visible. Otherwise, the code waits for one second and checks again.

You can customize the sleep duration (currently set to 1 second) to fit your specific use case.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-04-28 06:03:39 -0500

Seen: 256 times

Last updated: Apr 28 '23