softbankrobotics-research / qibullet

Bullet simulation for SoftBank Robotics robots
Apache License 2.0
141 stars 38 forks source link

qiBullet spawns Pepper for 1 second then stops working #59

Closed hisham246 closed 3 years ago

hisham246 commented 3 years ago

I ran the following code to spawn Pepper simulation:

`from qibullet import SimulationManager

if name == "main": simulation_manager = SimulationManager()

client_id = simulation_manager.launchSimulation(gui=True)

pepper_robot = True

if pepper_robot:

  pepper = simulation_manager.spawnPepper(
      client_id,
      translation=[0, 0, 0],
      quaternion=[0, 0, 0, 1],
      spawn_ground_plane=True)
else:
  nao = simulation_manager.spawnNao(
      client_id,
      spawn_ground_plane=True)`

but it starts only for a moment then shuts down very fast, and I receive the following in the terminal:

pybullet build time: Dec 23 2020 01:46:51 startThreads creating 1 threads. starting thread 0 started thread 0 argc=2 argv[0] = --unused argv[1] = --start_demo_name=Physics Server ExampleBrowserThreadFunc started X11 functions dynamically loaded using dlopen/dlsym OK! X11 functions dynamically loaded using dlopen/dlsym OK! Creating context Created GL 3.3 context Direct GLX rendering context obtained Making context current GL_VENDOR=NVIDIA Corporation GL_RENDERER=GeForce MX150/PCIe/SSE2 GL_VERSION=3.3.0 NVIDIA 455.38 GL_SHADING_LANGUAGE_VERSION=3.30 NVIDIA via Cg compiler pthread_getconcurrency()=0 Version = 3.3.0 NVIDIA 455.38 Vendor = NVIDIA Corporation Renderer = GeForce MX150/PCIe/SSE2 b3Printf: Selected demo: Physics Server startThreads creating 1 threads. starting thread 0 started thread 0 MotionThreadFunc thread started ven = NVIDIA Corporation ven = NVIDIA Corporation numActiveThreads = 0 stopping threads Thread with taskId 0 exiting Thread TERMINATED destroy semaphore semaphore destroyed destroy main semaphore main semaphore destroyed finished numActiveThreads = 0 btShutDownExampleBrowser stopping threads Thread with taskId 0 exiting Thread TERMINATED destroy semaphore semaphore destroyed destroy main semaphore main semaphore destroyed

How can I fix this?

Operating System: Ubuntu 18.04 GPU: NVIDIA Geforce MX150 (4 GB)

mbusy commented 3 years ago

Hi, you need a blocking call at the end of your script. With your current script, you launch the simulation, spawn a robot, and reach the end of your script (kill the simulation). You could for instance add

# Python 3
input("Press enter to stop the simulation")

# Python2
raw_input("Press enter to stop the simulation")

# Always good practice to clean up before killing the simulation
simulation_manager.stopSimulation(client_id)