Gazebo | Ignition | Community
Ask Your Question

How to open several gazebos in a linux operating system?

asked 2017-04-17 06:12:36 -0500

shin gravatar image

updated 2017-04-17 15:11:52 -0500

Carlos Agüero gravatar image

I can use the gazebo command to start Gazebo in my Linux. However, when I open a new terminal and type in gazebo (for the second time), then nothing happens. How can I run several Gazebo instances at the same time in my Linux?

edit retag flag offensive close merge delete


I have create several `gzserver` with different `localhosts`, then I create corresponding `gzclient`. It is strange that all clients do same operation as if they had received same instructions, but I connect them to `gzserver` with different `localhosts`. What determines the server? How can I use different server to control different client ?

shin gravatar imageshin ( 2017-04-17 21:54:39 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2017-04-17 10:18:43 -0500

chapulina gravatar image

updated 2017-04-17 22:22:49 -0500

To run various Gazebo instances, you must make sure each of them is using a different port. You can set this with the GAZEBO_MASTER_URI environment variable.

It's also convenient to run Gazebo in verbose mode so you can read error messages.

For example, on one terminal, start gzserver on the default port (11345):

gzserver --verbose

You'll see the port printed in green:

[Msg] Connected to gazebo master @

Then on a new terminal, open gzclient:

gzclient --verbose

You'll see the same port printed in green:

[Msg] Connected to gazebo master @

If you try to start another gzserver on a new terminal, without changing the URI, you'll get an error:

[Err] [] EXCEPTION: Unable to start server[bind: Address already in use]. There is probably another Gazebo process running.

The correct way is to open a new terminal and start another instance with a new URI:

export GAZEBO_MASTER_URI=http://localhost:11346; gzserver --verbose

This time the URI is different:

[Msg] Connected to gazebo master @

And then on a new terminal, the respective gzclient:

export GAZEBO_MASTER_URI=http://localhost:11346; gzclient --verbose

And you should also see the same URI:

[Msg] Connected to gazebo master @

edit flag offensive delete link more


By your instructions, I can really open multiple gazebo, however, when I use some control instructions, the models of all windows move in the same way. Can I just control only one window at one time and keep the states of other windows unchanged?

shin gravatar imageshin ( 2017-04-17 11:32:02 -0500 )edit

How are you sending instructions? You should be able to specify the URI to send them to and only that simulation will be affected. For example, if you use the gz command line tool, you should specify GAZEBO_MASTER_URI for the shell where you're running it.

chapulina gravatar imagechapulina ( 2017-04-17 12:23:20 -0500 )edit

I am playing a project, I guess the instructions have been packed. Can I specify URI when I open gzserver? If I do so, it will tell me no correct URl, and use old value, how can I solve it ?

shin gravatar imageshin ( 2017-04-17 18:41:21 -0500 )edit

I added more detailed instructions. Note that the URI must be set for each gzclient/gzserver you start.

chapulina gravatar imagechapulina ( 2017-04-17 22:23:31 -0500 )edit

This approach does work in some projects, but interesting things happen in project `haptix`, if I open two gazebo in this way, when I use keyboard to control the arms, two arms in different clients will act in same way. However, if I use the C API of this project to control, I can only control the one who was opened earier, even if I use the hx_connection to set host and port, it seems useless, I guess this may be related to the principle of gzserver, could you give me some ideas?

shin gravatar imageshin ( 2017-04-18 02:00:12 -0500 )edit

@chapulina as described above, I am able to run multiple gazebo instant and get data from it by putting export GAZEBO_MASTER_URI=http://localhost:11345 I am using C++ standalone plugin. So how to do it programmatically? What should I add in my program to do this automatically?

amit1989 gravatar imageamit1989 ( 2018-10-17 09:44:01 -0500 )edit

@amit1989, this sounds good for a new question

chapulina gravatar imagechapulina ( 2018-10-17 11:37:46 -0500 )edit

answered 2017-04-18 10:40:07 -0500

Carlos Agüero gravatar image

updated 2017-04-18 10:42:34 -0500

@chapulina already described the instructions for running multiple instances of Gazebo. Here are some additional notes that can help when working with the HAPTIX environment:

You should be able to isolate a Gazebo instance and your HAPTIX controllers with the help of the IGN_PARTITION environment variable. If you set this environment variable in the terminal where you launch Gazebo and in the terminal that you use to control the arm, other Gazebo instances shouldn't be affected by your controller. E.g.:

On terminal 1:

IGN_PARTITION=arm1 gazebo <your_world>

On terminal 2:

IGN_PARTITION=arm1 ./<my_controller>

Replace <your_world> with the appropriate Gazebo .world file and <my_controller> with the program that you're using for controlling the simulated arm.

edit flag offensive delete link more


This approach works perfectly! Thank you very much!

shin gravatar imageshin ( 2017-04-19 03:03:29 -0500 )edit

By your instructions, I can control different robot arm as I want. However, I can only control one arm in each time point because the environment variable IGN_PARTITION is unique in each time point. If I want to control two or more arms in the same time, how to do that? I try to use the function hx_connection, but I can not find its implementation, so it is difficult for me to use it. Could you please give me some more ideas? Thank you very much!

shin gravatar imageshin ( 2017-04-26 03:15:29 -0500 )edit

Question Tools



Asked: 2017-04-17 06:12:36 -0500

Seen: 6,482 times

Last updated: Apr 18 '17