Install Flightmare on ROS - Dieptranivsr/DroneIVSR GitHub Wiki

Install Flightmare on ROS

  1. Install ROS melodic on Ubuntu 18.04
  2. Install dependence libraries
$ sudo apt-get update
$ sudo apt-get install -y --no-install-Recommend \
   build-essential \
   cmake \
   libzmqpp-dev \
   libopencv-dev 
  1. Install Gazebo 9.0
  2. Install dependence ROS packages
$ sudo apt-get install libgoogle-glog-dev protobuf-compiler ros-$ROS_DISTRO-octomap-msgs ros-$ROS_DISTRO-octomap-ros ros-$ROS_DISTRO-joy python-vcstool
  1. Install compile tools
$ sudo apt-get install python-pip 
$ sudo pip install catkin-tools
  1. Make sure that protobuf compiler version is 3.0.0
$ protoc--version

OR build Protobuf from Source

6.1) Clone the protobuf repository and checkout the correct version

cd /<source_root>/
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v3.0.0

6.2) Apply below patch to file /<source_root>/protobuf/autogen.sh

--- a/autogen.sh
+++ b/autogen.sh
@@ -30,11 +30,16 @@ fi
# Check that gmock is present.  Usually it is already there since the
# directory is set up as an SVN external.
if test ! -e gmock; then
-  echo "Google Mock not present.  Fetching gmock-1.7.0 from the web..."
-  curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip
-  unzip -q gmock-1.7.0.zip
-  rm gmock-1.7.0.zip
-  mv gmock-1.7.0 gmock
+ echo "Google Mock not present.  Fetching gmock-1.7.0 from the web..."
+ curl $curlopts -L -O https://github.com/google/googlemock/archive/release-1.7.0.zip
+ unzip -q release-1.7.0.zip
+ rm release-1.7.0.zip
+ mv googlemock-release-1.7.0 gmock
+
+ curl $curlopts -L -O https://github.com/google/googletest/archive/release-1.7.0.zip
+ unzip -q release-1.7.0.zip
+ rm release-1.7.0.zip
+ mv googletest-release-1.7.0 gmock/gtest
fi

set -ex 

6.3) Generate and then run the configuration

./autogen.sh
./configure

6.4) Apply below patch to file /<source_root>/protobuf/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h

--- a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
+++ b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h
@@ -127,7 +127,23 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
                             __ATOMIC_RELAXED, __ATOMIC_RELAXED);
 return old_value;
}
+inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
+                                                    Atomic64 increment) {
+       return __atomic_add_fetch(ptr, increment, __ATOMIC_RELAXED);
+}
+
+inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
+       __atomic_store_n(ptr, value, __ATOMIC_RELAXED);
+}

+inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
+                                                    Atomic64 new_value) {
+       return __atomic_exchange_n(ptr, new_value, __ATOMIC_RELAXED);
+}
+
+inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
+       return __atomic_load_n(ptr, __ATOMIC_RELAXED);
+}
#endif // defined(__LP64__)

}  // namespace internal

6.5) Build and test

$ make
$ make check

6.6) Install Protobuf and verify the installation

$ sudo make install
$ export LD_LIBRARY_PATH=/usr/local/lib
$ protoc --version
  1. Create the workspace below
$ cd
$ mkdir -p catkin_ws/src
$ cd catkin_ws
$ catkin config --init --mkdirs --extend /opt/ros/$ROS_DISTRO --merge-devel --cmake-args -DCMAKE_BUILD_TYPE=Release
  1. Copy the Flightmare source code
$ cd ~ / catkin_ws / src
$ git clone https://github.com/uzh-rpg/flightmare.git
  1. Clone dependencies:
repositories:
  catkin_simple:
    type: git
    url: https://github.com/catkin/catkin_simple.git
    version: master
  eigen_catkin:
    type: git
    url: https://github.com/ethz-asl/eigen_catkin.git
    version: master
  mav_comm:
    type: git
    url: https://github.com/ethz-asl/mav_comm.git
    version: master
  rotors_simulator:
    type: git
    url: https://github.com/ethz-asl/rotors_simulator.git
    version: master
  rpg_quadrotor_common:
    type: git
    url: https://github.com/uzh-rpg/rpg_quadrotor_common.git
    version: master
  rpg_single_board_io:
    type: git
    url: https://github.com/uzh-rpg/rpg_single_board_io.git
    version: master
  rpg_quadrotor_control:
    type: git
    url: https://github.com/uzh-rpg/rpg_quadrotor_control.git
    version: master
  1. Build workspace
$ catkin_make
  1. Add sourcing of your catkin workspace and FLIGHTMARE_PATH environment variable to your .bashrc file
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
echo "export FLIGHTMARE_PATH=~/catkin_ws/src/flightmare" >> ~/.bashrc
source ~/.bashrc
  1. Download Flightmare Unity Binary

Download the Flightmare Unity Binary RPG_Flightmare.tar.xz for rendering from the Releases and extract it into the /path/to/flightmare/flightrender.

  1. You can run the launch file:
$ roslaunch flightros rotors_gazebo.launch