Skip to content

Commit

Permalink
Linux setup.sh, build.sh, cmake rewrites, fix various warnings, updat…
Browse files Browse the repository at this point in the history
…e docs
  • Loading branch information
sytelus committed Jul 19, 2017
1 parent 0aa7f3b commit 0c87453
Show file tree
Hide file tree
Showing 30 changed files with 341 additions and 250 deletions.
1 change: 1 addition & 0 deletions AirLib/include/common/SimClock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SimClock : public ClockBase {
: scale_(scale), latency_(latency)
{
offset_ = latency * (scale_ - 1);
unused(latency_);
}

virtual TTimePoint nowNanos() const override
Expand Down
2 changes: 2 additions & 0 deletions AirLib/include/common/common_utils/StrictMode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
_Pragma("clang diagnostic ignored \"-Wstrict-overflow\"") \
_Pragma("clang diagnostic ignored \"-Wswitch-default\"") \
_Pragma("clang diagnostic ignored \"-Wundef\"") \
_Pragma("clang diagnostic ignored \"-Wunused-variable\"") \
_Pragma("clang diagnostic ignored \"-Wunused-parameter\"")

/* Addition options that can be enabled
Expand Down Expand Up @@ -72,6 +73,7 @@ _Pragma("clang diagnostic ignored \"-Wunused-variable\"") \
_Pragma("GCC diagnostic ignored \"-Wstrict-overflow\"") \
_Pragma("GCC diagnostic ignored \"-Wswitch-default\"") \
_Pragma("GCC diagnostic ignored \"-Wundef\"") \
_Pragma("GCC diagnostic ignored \"-Wunused-variable\"") \
_Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")

/* Addition options that can be enabled
Expand Down
1 change: 1 addition & 0 deletions AirLib/include/controllers/DroneControllerBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class DroneControllerBase : public VehicleControllerBase {
StatusLock(DroneControllerBase* drone)
: drone_(drone), lock_(drone->status_mutex_)
{
unused(drone_);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/controllers/MavLinkDroneController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ struct MavLinkDroneController::impl {
bool rc = false;
checkVehicle();
mavlinkcom::AsyncResult<bool> result = mav_vehicle_->loiter();
auto start_time = std::chrono::system_clock::now();
//auto start_time = std::chrono::system_clock::now();
while (!cancelable_action.isCancelled())
{
if (result.wait(100, &rc))
Expand Down
3 changes: 3 additions & 0 deletions AirLib/include/controllers/ros_flight/firmware/estimator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class Estimator {

void Estimator::init(Params* _params, bool use_matrix_exponential, bool use_quadratic_integration, bool use_accelerometer)
{
unused(board);
unused(_adaptive_gyro_bias);

params = _params;

mat_exp = use_matrix_exponential;
Expand Down
2 changes: 2 additions & 0 deletions AirLib/include/controllers/ros_flight/firmware/mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class Mode {
/************************************************** Implementation ***************************************************************/
void Mode::init(Board* _board, CommLink* _comm_link, CommonState* _common_state, Sensors* _sensors, RC* _rc, Params* _params)
{
unused(_error_state);

board = _board;
comm_link = _comm_link;
params = _params;
Expand Down
4 changes: 4 additions & 0 deletions AirLib/include/controllers/ros_flight/firmware/sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class Sensors {

void Sensors::init(CommonState* _common_state, Board* _board, Estimator* _estimator, Params* _params, CommLink* _comm_link)
{
unused(accel_status);
unused(gyro_status);
unused(temp_status);

common_state = _common_state;
estimator = _estimator;
params = _params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AngleStabilizer {
pid_angle_yaw_(clock,
PidController<float>::Config(params->p_yaw_angle, 0, 0))
{
unused(params_);
}

void reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class RateStabilizer {
pid_rate_yaw_(clock,
PidController<float>::Config(params->p_yaw_rate, 0, 0))
{
unused(params_);
}

void reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Stabilizer {
angle_estimator_(angle_estimator),
rate_stabilizer_(params, clock), angle_stabilizer_(params, clock)
{
unused(clock_);
}

void reset()
Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/vehicles/configs/RosFlightQuadX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RosFlightQuadX : public MultiRotorParams {
//set up mass
params.mass = 2.856f;
real_T motor_assembly_weight = 0.0800f; //weight for MT2212 motor for F450 frame
real_T box_mass = params.mass - params.rotor_count * motor_assembly_weight;
//real_T box_mass = params.mass - params.rotor_count * motor_assembly_weight;

//set up dimensions of core body box
params.body_box.x() = 0.35f; params.body_box.y() = 0.20f; params.body_box.z() = 0.22f;
Expand Down
4 changes: 2 additions & 2 deletions AirLib/src/controllers/DroneControllerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ bool DroneControllerBase::setSafety(SafetyEval::SafetyViolationType enable_reaso

bool DroneControllerBase::moveByManual(float vx_max, float vy_max, float z_min, float duration, DrivetrainType drivetrain, const YawMode& yaw_mode, CancelableBase& cancelable_action)
{
const float kMaxMessageAge = 0.1f /* 0.1 sec */, kMaxVelocity = 2, trim_duration = 1, kMinCountForTrim = 10, kMaxTrim = 100, kMaxRCValue = 10000;
const float kMaxMessageAge = 0.1f /* 0.1 sec */, kTrimduration = 1, kMinCountForTrim = 10, kMaxTrim = 100, kMaxRCValue = 10000;

if (duration <= 0)
return true;
Expand All @@ -422,7 +422,7 @@ bool DroneControllerBase::moveByManual(float vx_max, float vy_max, float z_min,
Quaternionr starting_quaternion = getOrientation();

//get trims
Waiter waiter_trim(getCommandPeriod(), trim_duration);
Waiter waiter_trim(getCommandPeriod(), kTrimduration);
RCData rc_data_trims;
uint count = 0;
do {
Expand Down
1 change: 1 addition & 0 deletions AirLibUnitTests/AirLibUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using namespace msr::airlib;
int main()
{
Settings& settings = Settings::loadJSonFile("settings.json");
unused(settings);

TestVehicles test1;
test1.Run();
Expand Down
4 changes: 2 additions & 2 deletions MavLinkCom/MavLinkTest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static const int pixhawkVendorId = 9900; ///< Vendor ID for Pixhawk board (V2
static const int pixhawkFMUV4ProductId = 18; ///< Product ID for Pixhawk V2 board
static const int pixhawkFMUV2ProductId = 17; ///< Product ID for Pixhawk V2 board
static const int pixhawkFMUV2OldBootloaderProductId = 22; ///< Product ID for Bootloader on older Pixhawk V2 boards
static const int pixhawkFMUV1ProductId = 16; ///< Product ID for PX4 FMU V1 board
//static const int pixhawkFMUV1ProductId = 16; ///< Product ID for PX4 FMU V1 board

#define MAV_AUTOPILOT_ENUM_END (static_cast<uint8_t>(MAV_AUTOPILOT::MAV_AUTOPILOT_ASLUAV)+1)
#define MAV_TYPE_ENUM_END (static_cast<uint8_t>(MAV_TYPE::MAV_TYPE_ADSB)+1)
Expand Down Expand Up @@ -771,7 +771,7 @@ bool ParseCommandLine(int argc, const char* argv[])
{
const char* logDirOption = "logdir";
const char* logformatOption = "logformat";
const char* outLogFileOption = "outlogfile";
//const char* outLogFileOption = "outlogfile";
const char* wifiOption = "wifi";
const char* initOption = "init";
const char* filterOption = "filter";
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ There are two ways to get AirSim working on your machine. Click on below links a
2. [Use the precompiled binaries](docs/use_precompiled.md)

## Linux
Kerry Snyder has created [Docker container for AirSim](https://github.com/kersny/airsim_nvidia_docker)! If you are using Linux, give it a try.
[Build AirSim on Ubuntu 16.04](docs/linux_build.md)

Several people have reported that they have been running in Linux as well as OSX successfully. Please check [conversations on Linux](https://github.com/microsoft/airsim/issues?utf8=%E2%9C%93&q=linux).
You can find our experimental [Linux build instruction here](docs/linux_build.md). Our official binary release for Ubuntu 16.04 is now just around the corner.

# How to Use It

Expand Down
10 changes: 10 additions & 0 deletions Unreal/Environments/Blocks/clean.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#! /bin/bash

# get path of current script: https://stackoverflow.com/a/39340259/207661
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR"

set -e

# clean temporary unreal folders
rm -rf Binaries
rm -rf Intermediate
rm -rf Saved
rm -rf Plugins/AirSim/Binaries
rm -rf Plugins/AirSim/Intermediate
rm -rf Plugins/AirSim/Saved

popd
48 changes: 20 additions & 28 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,36 @@

# get path of current script: https://stackoverflow.com/a/39340259/207661
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
pushd "$SCRIPT_DIR"

set -e
set +x

# update any git submodules, currently rpclib
git submodule update --init --recursive

# check for clang compiler, if not installed then instruct user to install it
#!/bin/bash
if [[ !(-f "/usr/bin/clang") || !(-f "/usr/bin/clang++") ]]; then
echo "ERROR: clang++ 3.9 is necessary to compile AirSim and run it in Unreal"
echo " please run : sudo apt-get install clang++-3.9"
echo " followed by: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.9 60 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-3.9 "

echo " We need to use clang because the Unreal Engine is built with clang as well and"
echo " there are some symbol inconsistencies in the C++ library with regard to C++11"
echo " (see GCC Dual ABI: # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html)"

# check for libc++
if [[ !(-d "./llvm-build/output/lib") ]]; then
echo "ERROR: clang++ 3.9 and libc++ is necessary to compile AirSim and run it in Unreal 4.15"
echo "please run setup.sh first."
exit 1
fi

# set up paths of clang compiler
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export CC=/usr/bin/clang-3.9
export CXX=/usr/bin/clang++-3.9

# if eigen env var not found then install eigen in current directory
if [[ ! -d "$EIGEN_ROOT" ]]; then
echo "EIGEN_ROOT variable is not set."
#install EIGEN library
if [[ -z "${EIGEN_ROOT}" ]]; then
echo "EIGEN_ROOT variable is not set"
if [[ ! -d eigen ]]; then
echo "downloading eigen..."
wget http://bitbucket.org/eigen/eigen/get/3.3.2.zip
unzip 3.3.2.zip -d eigen
pushd eigen
mv eigen* eigen3
echo "3.3.2" > version
popd &>/dev/null
rm 3.3.2.zip
echo "eigen is not installed. Please run setup.sh first."
exit 1
fi
export EIGEN_ROOT="$(pwd)/eigen"
echo "export EIGEN_ROOT=\"$(pwd)/eigen\"" >> ~/.bashrc
fi


# variable for build output
build_dir=build_debug
echo "putting build in build_debug folder, to clean, just delete the directory..."
Expand Down Expand Up @@ -79,11 +67,15 @@ mkdir -p AirLib/deps/MavLinkCom/lib
cp $build_dir/output/lib/libAirLib.a AirLib/lib
cp $build_dir/output/lib/libMavLinkCom.a AirLib/deps/MavLinkCom/lib
cp $build_dir/output/lib/libAirSim-rpclib.a AirLib/deps/rpclib/lib/librpc.a

# Update AirLib/lib, AirLib/deps, Plugins folders with new binaries
rsync -a --delete $build_dir/output/lib/ AirLib/lib/x64/Debug
rsync -a --delete external/rpclib/include AirLib/deps/rpclib
rsync -a --delete MavLinkCom/include AirLib/deps/MavLinkCom
rsync -a --delete AirLib Unreal/Plugins/AirSim/Source

# Update Blocks project
Unreal/Environments/Blocks/clean.sh
rsync -a --delete Unreal/Plugins Unreal/Environments/Blocks

echo ""
Expand All @@ -94,8 +86,8 @@ echo "If you are using Blocks environment, its already updated."
echo "If you are using your own environment, update blugin with this:"
echo "rsync -t -r Unreal/Plugins path/to/MyUnrealProject"
echo ""
echo "Make sure EIGEN_ROOT variable is set! (.bashrc should have it now)"
echo "export EIGEN_ROOT=\"$EIGEN_ROOT\""
echo "For help see https://github.com/Microsoft/AirSim/blob/master/docs/linux_build.md"
echo "=================================================================="


popd
13 changes: 12 additions & 1 deletion clean.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
#! /bin/bash

# get path of current script: https://stackoverflow.com/a/39340259/207661
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR"

set -e

rm -rf build_debug
rm -rf build_release
rm -rf build_release
rm -rf cmake/output

popd
26 changes: 6 additions & 20 deletions cmake/AirLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
cmake_minimum_required(VERSION 3.2.2)
cmake_minimum_required(VERSION 3.5.0)
project(AirLib)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../cmake-modules/CommonSetup.cmake")
CommonSetup()

## System dependencies are found with CMake's conventions
find_package(Eigen3 3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
IncludeEigen()

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${AIRSIM_ROOT}/AirLib/
${AIRSIM_ROOT}/AirLib/include
${AIRSIM_ROOT}/MavLinkCom/include
${RPC_LIB_INCLUDES}
)

add_library(AirLib STATIC
${AIRSIM_ROOT}/AirLib/src/controllers/DroneControllerBase.cpp
${AIRSIM_ROOT}/AirLib/src/controllers/FileSystem.cpp
${AIRSIM_ROOT}/AirLib/src/safety/ObstacleMap.cpp
${AIRSIM_ROOT}/AirLib/src/safety/SafetyEval.cpp
${AIRSIM_ROOT}/AirLib/src/rpc/RpcLibClient.cpp
${AIRSIM_ROOT}/AirLib/src/rpc/RpcLibServer.cpp
)
file(GLOB_RECURSE ${PROJECT_NAME}_sources ${AIRSIM_ROOT}/${PROJECT_NAME}/src/*.cpp)
add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_sources})

## Add these to your app that links this library:
CommonTargetLink()
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})
target_link_libraries(${PROJECT_NAME} MavLinkCom)

#string(SUBSTRING ${CMAKE_STATIC_LINKER_FLAGS} 9 -1 "BUILD_PLATFORM")
#find_package(Threads REQUIRED)
Expand Down
28 changes: 5 additions & 23 deletions cmake/AirLibUnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
cmake_minimum_required(VERSION 3.2.2)
cmake_minimum_required(VERSION 3.5.0)
project(AirLibUnitTests)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/../cmake-modules/CommonSetup.cmake")
CommonSetup()

## System dependencies are found with CMake's conventions
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake-modules")
find_package(Eigen3 3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

IF(UNIX)
ELSE()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CONSOLE ")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
ENDIF()
IncludeEigen()

###########
## Build ##
###########
SetupConsoleBuild()

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${AIRSIM_ROOT}/AirLibUnitTests
${AIRSIM_ROOT}/AirLib/include
${AIRSIM_ROOT}/MavLinkCom/include
)

AddExecutableSource()

## Declare the executable
add_executable(AirLibUnitTests
${AIRSIM_ROOT}/AirLibUnitTests/AirLibUnitTests.cpp
)

target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
CommonTargetLink()
target_link_libraries(${PROJECT_NAME} AirLib)
target_link_libraries(${PROJECT_NAME} MavLinkCom)
target_link_libraries(${PROJECT_NAME} ${RPC_LIB})
10 changes: 2 additions & 8 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
cmake_minimum_required(VERSION 3.2.2)
cmake_minimum_required(VERSION 3.5.0)
project(AirSim)
set(RPCLIB_NAME_SUFFIX rpclib)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules")
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/cmake-modules/CommonSetup.cmake")
CommonSetup()

add_subdirectory("${AIRSIM_ROOT}/external/rpclib" "${CMAKE_CURRENT_BINARY_DIR}/rpclib")

add_subdirectory("rpclib_wrapper")
add_subdirectory("AirLib")
add_subdirectory("MavLinkCom")
add_subdirectory("AirLibUnitTests")
Expand Down
Loading

0 comments on commit 0c87453

Please sign in to comment.