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

Support multi vehicle sitl gazebo without ros #13729

Merged
merged 7 commits into from Dec 26, 2019
Merged

Conversation

Jaeyoung-Lim
Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim commented Dec 11, 2019

Describe problem solved by this pull request
Previous implementation used ros launchfiles, to spawn multiple vehicles in SITL gazebo. This was great, but required manually expanding the launchfile to add more vehicles and required ros to be installed on the system in order to run roslaunch

Describe your solution
This PR adds a simple bash script that spawns multiple px4 SITL instances and spawns the model in gazebo. It can also spawn as many vehicles as the user wants.

Tools/gazebo_sitl_multiple_run.sh <number_of_vehicles>

Test data / coverage
The following shows screenshots of spawning 10 vehicles with the script
Screenshot from 2019-12-11 11-33-05
Screenshot from 2019-12-11 11-32-46

Also running two vehicles doing different missions

Screenshot from 2019-12-11 11-24-13

Additional context
I have noticed that gazebo processes don't exit cleanly and I need to manually kill gazebo when stoping the script. This should be included in future improvements

@Jaeyoung-Lim Jaeyoung-Lim requested a review from RomanBapst Dec 11, 2019
@hamishwillee
Copy link
Contributor

@hamishwillee hamishwillee commented Dec 11, 2019

Hi @Jaeyoung-Lim

This will need docs like http://dev.px4.io/master/en/simulation/multi_vehicle_jmavsim.html

Is the usage the same? Ideally it would be very similar.

@ShiauweiZhao
Copy link
Contributor

@ShiauweiZhao ShiauweiZhao commented Dec 12, 2019

I test the pr, and output

 ./Tools/gazebo_sitl_multiple_run.sh 
killing running instances
Starting gazebo
Gazebo multi-robot simulator, version 9.11.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 10.13.0.132
starting instance 0 in /home/xiaowei/src/Firmware/build/px4_sitl_default/instance_0

Spawning iris_0
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_multirotor_base_plugin.so: libgazebo_multirotor_base_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_gps_plugin.so: libgazebo_gps_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_magnetometer_plugin.so: libgazebo_magnetometer_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_barometer_plugin.so: libgazebo_barometer_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_mavlink_interface.so: libgazebo_mavlink_interface.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_imu_plugin.so: libgazebo_imu_plugin.so: cannot open shared object file: No such file or directory
starting instance 1 in /home/xiaowei/src/Firmware/build/px4_sitl_default/instance_1

Spawning iris_1
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_multirotor_base_plugin.so: libgazebo_multirotor_base_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_gps_plugin.so: libgazebo_gps_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_magnetometer_plugin.so: libgazebo_magnetometer_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_barometer_plugin.so: libgazebo_barometer_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_mavlink_interface.so: libgazebo_mavlink_interface.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_imu_plugin.so: libgazebo_imu_plugin.so: cannot open shared object file: No such file or directory
Starting gazebo client

maybe need to add a path?

@ShiauweiZhao
Copy link
Contributor

@ShiauweiZhao ShiauweiZhao commented Dec 12, 2019

I test the pr, and output

 ./Tools/gazebo_sitl_multiple_run.sh 
killing running instances
Starting gazebo
Gazebo multi-robot simulator, version 9.11.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 10.13.0.132
starting instance 0 in /home/xiaowei/src/Firmware/build/px4_sitl_default/instance_0

Spawning iris_0
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_multirotor_base_plugin.so: libgazebo_multirotor_base_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_gps_plugin.so: libgazebo_gps_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_magnetometer_plugin.so: libgazebo_magnetometer_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_barometer_plugin.so: libgazebo_barometer_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_mavlink_interface.so: libgazebo_mavlink_interface.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_imu_plugin.so: libgazebo_imu_plugin.so: cannot open shared object file: No such file or directory
starting instance 1 in /home/xiaowei/src/Firmware/build/px4_sitl_default/instance_1

Spawning iris_1
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_multirotor_base_plugin.so: libgazebo_multirotor_base_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_motor_model.so: libgazebo_motor_model.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_gps_plugin.so: libgazebo_gps_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_magnetometer_plugin.so: libgazebo_magnetometer_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_barometer_plugin.so: libgazebo_barometer_plugin.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_mavlink_interface.so: libgazebo_mavlink_interface.so: cannot open shared object file: No such file or directory
[Err] [Plugin.hh:187] Failed to load plugin libgazebo_imu_plugin.so: libgazebo_imu_plugin.so: cannot open shared object file: No such file or directory
Starting gazebo client

maybe need to add a path?

use source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default sovled

@Jaeyoung-Lim
Copy link
Member Author

@Jaeyoung-Lim Jaeyoung-Lim commented Dec 12, 2019

@zhaoxiaowei1013 Thanks for testing it out. I included the environment sourcing inside the script

@Jaeyoung-Lim
Copy link
Member Author

@Jaeyoung-Lim Jaeyoung-Lim commented Dec 13, 2019

@hamishwillee It is even simpler. You don't need to fire up multiple scripts. Will get the documentation updated

- make sure to kill all px4 instances and gazebo client when exiting
- add arguments to specify number of vehicles and vehicle model
- exit for now if vehicle model is not iris, since needs changes in
sitl_gazebo submodule

Signed-off-by: RomanBapst <bapstroman@gmail.com>
@@ -0,0 +1,81 @@
#!/bin/bash
# run multiple instances of the 'px4' binary, but w/o starting the simulator.
Copy link
Contributor

@JonasVautherin JonasVautherin Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that part of the comment accurate? Seems to me like it is starting gzserver, right?

Copy link
Member Author

@Jaeyoung-Lim Jaeyoung-Lim Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I will update the comment

Copy link
Contributor

@JonasVautherin JonasVautherin Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! I'll try to run it as soon as that's fixed, so that I can review the final state 😊

Copy link
Member Author

@Jaeyoung-Lim Jaeyoung-Lim Dec 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sleep 5

n=0
while [ $n -lt $num_vehicles ]; do
Copy link
Contributor

@JonasVautherin JonasVautherin Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a detail, and I'm not an expert in bash, but couldn't we do a for loop here? So that it fits on one line and removes the n=$(($n + 1)) at the end of the loop.

Suggested change
while [ $n -lt $num_vehicles ]; do
for n in {0..$((num_vehicles-1))}; do

Copy link
Member Author

@Jaeyoung-Lim Jaeyoung-Lim Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems better. but wouldn't there be value on being consistent with https://github.com/PX4/Firmware/blob/master/Tools/sitl_multiple_run.sh#L25 ?

Copy link
Contributor

@JonasVautherin JonasVautherin Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, your call 😉.

Copy link
Contributor

@JonasVautherin JonasVautherin left a comment

Working for me! Thanks!

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

Successfully merging this pull request may close these issues.

None yet

6 participants