From ad2a6cbc338fa355ae3f35336742de4e15a21403 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Fri, 10 Jun 2022 17:08:44 +0300 Subject: [PATCH] Patch sitl_gazebo to make Gazebo not crash on deleting the model See https://github.com/PX4/PX4-SITL_gazebo/pull/872 --- assets/patches/sitl_gazebo.patch | 60 ++++++++++++++++++-------------- scripts/install_software.sh | 5 +++ 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/assets/patches/sitl_gazebo.patch b/assets/patches/sitl_gazebo.patch index a00a353..4d9c2c7 100644 --- a/assets/patches/sitl_gazebo.patch +++ b/assets/patches/sitl_gazebo.patch @@ -1,28 +1,36 @@ -diff --git a/cmake/FindMAVLink.cmake b/cmake/FindMAVLink.cmake -index 8de3079..3fdae02 100644 ---- a/cmake/FindMAVLink.cmake -+++ b/cmake/FindMAVLink.cmake -@@ -19,6 +19,7 @@ set(_MAVLINK_EXTRA_SEARCH_HINTS - ${CMAKE_SOURCE_DIR}/mavlink/ - ../../mavlink/ - ../mavlink/ -+ $ENV{HOME}/PX4-Autopilot/mavlink/include - ${CATKIN_DEVEL_PREFIX}/ - ) +diff --git a/src/gazebo_gps_plugin.cpp b/src/gazebo_gps_plugin.cpp +index 1195f5e..6540596 100644 +--- a/src/gazebo_gps_plugin.cpp ++++ b/src/gazebo_gps_plugin.cpp +@@ -41,7 +41,6 @@ GpsPlugin::~GpsPlugin() + if (updateSensorConnection_) + updateSensorConnection_->~Connection(); + parentSensor_.reset(); +- world_->Reset(); + } + void GpsPlugin::Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf) +diff --git a/src/gazebo_groundtruth_plugin.cpp b/src/gazebo_groundtruth_plugin.cpp +index 441ebd9..dd66e12 100644 +--- a/src/gazebo_groundtruth_plugin.cpp ++++ b/src/gazebo_groundtruth_plugin.cpp +@@ -51,7 +51,6 @@ GroundtruthPlugin::~GroundtruthPlugin() + { + if (updateConnection_) + updateConnection_->~Connection(); +- world_->Reset(); + } -diff --git a/package.xml b/package.xml -index ae0fb34..12f17b8 100644 ---- a/package.xml -+++ b/package.xml -@@ -50,8 +50,8 @@ - roscpp - sensor_msgs - std_msgs -- python-rospkg -- python-jinja2 -+ python3-rospkg -+ python3-jinja2 - eigen - gazebo_ros - geometry_msgs + void GroundtruthPlugin::Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) +diff --git a/src/gazebo_lidar_plugin.cpp b/src/gazebo_lidar_plugin.cpp +index 38374e6..1b2fbf8 100644 +--- a/src/gazebo_lidar_plugin.cpp ++++ b/src/gazebo_lidar_plugin.cpp +@@ -47,7 +47,6 @@ LidarPlugin::~LidarPlugin() + newLaserScansConnection_->~Connection(); + newLaserScansConnection_.reset(); + parentSensor_.reset(); +- world_->Reset(); + } + + ///////////////////////////////////////////////// diff --git a/scripts/install_software.sh b/scripts/install_software.sh index bef6379..62740e9 100644 --- a/scripts/install_software.sh +++ b/scripts/install_software.sh @@ -65,6 +65,11 @@ echo "--- Installing PX4 dependencies" pip3 install --user toml sudo -E sh -c 'apt-get install -y ant openjdk-11-jdk' # Additional packages for jMAVSim +echo "--- Patching mavlink_sitl_gazebo" +# See https://github.com/PX4/PX4-SITL_gazebo/pull/872 +cd ~/PX4-Autopilot/Tools/sitl_gazebo +patch -p1 < /tmp/patches/mavlink_sitl_gazebo.patch + echo "--- Addding Gazebo initialization to bashrc" echo "source /usr/share/gazebo/setup.sh" >> ~/.bashrc echo "export SVGA_VGPU10=0" >> ~/.bashrc