项目作者: PX4

项目描述 :
Set of plugins, models and worlds to use with OSRF Gazebo Simulator in SITL and HITL.
高级语言: C++
项目地址: git://github.com/PX4/PX4-SITL_gazebo.git
创建时间: 2016-01-02T19:02:58Z
项目社区:https://github.com/PX4/PX4-SITL_gazebo

开源协议:

下载


PX4 Gazebo Plugin Suite for MAVLink SITL and HITL

Build Status MacOS Build Tests

This is a flight simulator for rovers, boats, multirotors, VTOL, fixed wing. It uses the motor model and other pieces from the RotorS simulator, but in contrast to RotorS has no dependency on ROS. Original project: https://github.com/ethz-asl/rotors_simulator.

If you use this simulator in academic work, please cite RotorS as per the README in the above link.

Installation

This simulator is designed to be used with the PX4 Autopilot. Please follow the official developer toolchain installation instructions:
http://docs.px4.io/main/en/sim_gazebo_classic/

Contributing and Testing

Please refer to the installations instructions above for normal usage and to get the development environment installed. This section covers specifics for developers interested to contribute to the simulator.

sitl_gazebo plugin dependencies

Some plugins on this packages require some specific dependencies:

  • Protobuf is required to generate custom protobuf messages to be published and subscribed between topics of different plugins;
  • Jinja 2 is used to generate some SDF models from templates;
  • Gstreamer is required for a plugin that streams video from a simulated camera.

Build sitl_gazebo

Clone the repository to your computer.

IMPORTANT: If you do not clone to ~/src/sitl_gazebo, all remaining paths in these instructions will need to be adjusted.

  1. mkdir -p ~/src
  2. cd src
  3. git clone --recursive https://github.com/PX4/sitl_gazebo.git

Create a build folder in the top level of your repository:

  1. mkdir build

Navigate into the build directory and invoke CMake from it:

  1. cd ~/src/sitl_gazebo
  2. cd build
  3. cmake ..

Now build the gazebo plugins by typing:

  1. make -j$(nproc) -l$(nproc)

Next add the location of this build directory to your gazebo plugin path, e.g. add the following line to your .bashrc (Linux) or .bash_profile (Mac) file:

  1. # Set the plugin path so Gazebo finds our model and sim
  2. export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:$HOME/src/sitl_gazebo/build
  3. # Set the model path so Gazebo finds the airframes
  4. export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:$HOME/src/sitl_gazebo/models
  5. # Disable online model lookup since this is quite experimental and unstable
  6. export GAZEBO_MODEL_DATABASE_URI=""

You also need to add the the root location of this repository, e.g. add the following line to your .bashrc (Linux) or .bash_profile (Mac) file:

  1. # Set path to sitl_gazebo repository
  2. export SITL_GAZEBO_PATH=$HOME/src/sitl_gazebo

Install

If you wish the libraries and models to be usable anywhere on your system without
specifying th paths, install as shown below.

Note: If you are using Ubuntu, it is best to see the packaging section.

  1. sudo make install

Testing

Gazebo will now launch when typing ‘gazebo’ on the shell:

  1. . /usr/share/gazebo/setup.sh
  2. . /usr/share/mavlink_sitl_gazebo/setup.sh
  3. gazebo worlds/iris.world

Please refer to the documentation of the particular flight stack how to run it against this framework, e.g. PX4

Unit Tests

For building and running test an installation of ‘googletest’ is needed.

On Ubuntu it can be installed with:

  1. sudo apt-get install libgtest-dev
  2. cd /usr/src/googletest
  3. sudo cmake . && cd googletest
  4. sudo make -j$(nproc) -l$(nproc)
  5. sudo cp *.a /usr/lib

On macOS it needs to be installed from source:

  1. git clone https://github.com/google/googletest
  2. pushd googletest
  3. mkdir build
  4. pushd build
  5. cmake ..
  6. make -j$(nproc) -l$(nproc)
  7. make install

When writing test it’s important to be careful which API functions of Gazebo are called. As no Gazebo server is running during the tests some functions can produce undefined behaviour (e.g. segfaults).

CUDA Hardware Accelerated H264 encoding (optional)

  1. Download CUDA 10.0 from https://developer.nvidia.com/cuda-toolkit-archive.
  2. Download Video Codec SDK 9.0 from https://developer.nvidia.com/video-codec-sdk-archive.
  3. Install both archives:
  1. wget https://raw.githubusercontent.com/jackersson/env-setup/master/gst-nvidia-docker/install_video_codec_sdk.sh
  2. chmod +x install_video_codec_sdk.sh
  3. sudo ./install_video_codec_sdk.sh
  4. sudo dpkg -i cuda-repo-ubuntu*.deb
  5. sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
  6. sudo apt-get update
  7. sudo apt-get install cuda
  1. Reboot your system and run the command nvidia-smi to verify the successul installation of CUDA.
  2. Install GStreamer 1.18.3:
  1. git clone https://github.com/GStreamer/gst-build -b 1.18.3
  2. cd gst-build
  3. meson -Dbuildtype=release -Dstrip=true -Dgst-plugins-bad:introspection=enabled -Dgst-plugins-bad:nvcodec=enabled builddir
  4. ninja -C builddir
  5. sudo meson install -C builddir
  1. Add <useCuda>true</useCuda> to any gazebo_gst_camera_plugin in a SDF file. For example ./models/fpv_cam/fpv_cam.sdf.

catkin tools

With catkin, the unit tests are enabled by default.

  1. # After setting up the catkin workspace
  2. catkin build -j4 -l4 -DBUILD_ROS_PLUGINS=ON
  3. cd build/mavlink_sitl_gazebo/
  4. catkin run_tests

Plain CMake

For building the tests with plain CMake, the flag ENABLE_UNIT_TESTS needs to be provided.

  1. mkdir build && cd build
  2. cmake -DENABLE_UNIT_TESTS=On ..

Then build and run the tests:

  1. make -j$(nproc) -l$(nproc)
  2. make test

Packaging

Debian packages

To create a debian package for Ubuntu and install it to your system.

  1. cd Build
  2. cmake ..
  3. make
  4. rm *.deb
  5. cpack -G DEB
  6. sudo dpkg -i *.deb