From cc15d196862d439ebd8b041dc3c2e5c88f40ea3b Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Wed, 21 Sep 2022 23:41:42 +0300 Subject: [PATCH] Add Gazebo simulator to image --- builder/image-build.sh | 1 + builder/image-simulator.sh | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 builder/image-simulator.sh diff --git a/builder/image-build.sh b/builder/image-build.sh index 534157eb..529bbad5 100755 --- a/builder/image-build.sh +++ b/builder/image-build.sh @@ -120,6 +120,7 @@ ${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/launch. # ${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} copy ${SCRIPTS_DIR}'/assets/kinetic-ros-clover.rosinstall' '/home/pi/ros_catkin_ws/' # Add rename script ${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-ros.sh' ${REPO_URL} ${IMAGE_VERSION} false false ${NUMBER_THREADS} +${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-simulator.sh' ${BUILDER_DIR}/image-chroot.sh ${IMAGE_PATH} exec ${SCRIPTS_DIR}'/image-validate.sh' ${BUILDER_DIR}/image-resize.sh ${IMAGE_PATH} diff --git a/builder/image-simulator.sh b/builder/image-simulator.sh new file mode 100755 index 00000000..95acf53b --- /dev/null +++ b/builder/image-simulator.sh @@ -0,0 +1,42 @@ +#! /usr/bin/env bash + +# +# Script for build the image. Used builder script of the target repo +# For build: docker run --privileged -it --rm -v /dev:/dev -v $(pwd):/builder/repo smirart/builder +# +# Copyright (C) 2018 Copter Express Technologies +# +# Author: Artem Smirnov +# +# Distributed under MIT License (available at https://opensource.org/licenses/MIT). +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# + +set -ex # exit on error, echo commands + +echo "--- Downloading PX4" +cd /home/pi/catkin_ws/ +git clone --recursive --depth 1 --branch v1.13.0 https://github.com/PX4/PX4-Autopilot.git /home/pi/PX4-Autopilot +ln -s /home/pi/PX4-Autopilot /home/pi/catkin_ws/src/ +ln -s /home/pi/PX4-Autopilot/Tools/sitl_gazebo /home/pi/catkin_ws/src/ + +echo "--- Installing PX4 dependencies" +echo "progress=dot:giga" > /home/pi/.wgetrc # make wget don't spam to log +apt-get install --no-install-recommends -y gazebo11 +/home/pi/PX4-Autopilot/Tools/setup/ubuntu.sh --no-nuttx +rm /home/pi/.wgetrc +pip3 install --user toml + +echo "--- Patching mavlink_sitl_gazebo" +# See https://github.com/PX4/PX4-SITL_gazebo/pull/872 +cd /home/pi/PX4-Autopilot/Tools/sitl_gazebo +patch -p1 < /tmp/patches/sitl_gazebo.patch + +echo "--- Build mavlink" +cd /home/pi/catkin_ws +catkin_make mavlink_c_generate -DCATKIN_WHITELIST_PACKAGES="px4" # at first build PX4's mavlink to enforce mavlink_sitl_gazebo using it +ln -s "." build/mavlink/mavlink # fix https://github.com/PX4/PX4-Autopilot/pull/19964 + +echo "--- Building the workspace" +catkin_make -DCATKIN_WHITELIST_PACKAGES=""