Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into add-ros2-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
alonfaraj committed Mar 29, 2022
2 parents 8ad4654 + 78d8cf7 commit cf97e20
Show file tree
Hide file tree
Showing 35 changed files with 516 additions and 253 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ jobs:
run: |
python3 -m pip install --upgrade pip
python3 -m pip install mkdocs pymdown-extensions # Mkdocs requirements
python3 -m pip install jinja2==3.0.3
- name: Build API reference docs
run: |
python3 -m venv .env # Virtual env to avoid dep. issues
source .env/bin/activate
pip install Sphinx sphinx_rtd_theme numpy msgpack-rpc-python
pushd PythonClient >/dev/null
./build_api_docs.sh
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on: [push, pull_request, workflow_dispatch]

jobs:
build:
runs-on: macos-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-10.15, macos-11]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on: [push, pull_request, workflow_dispatch]

jobs:
build:
runs-on: windows-latest
runs-on: windows-2019

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2

- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.4.1
uses: ilammy/msvc-dev-cmd@v1

- name: Build AirLib
shell: cmd
Expand Down
40 changes: 40 additions & 0 deletions AirLib/include/common/AirSimSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ namespace airlib
float HorzDistortionStrength = 0.002f;
};

struct PixelFormatOverrideSetting
{
int pixel_format = 0;
};

struct UnrealEngineSetting
{
std::map<int, PixelFormatOverrideSetting> pixel_format_override_settings;
};

struct CameraSetting
{
//nan means keep the default values set in components
Expand All @@ -193,6 +203,8 @@ namespace airlib
std::map<int, CaptureSetting> capture_settings;
std::map<int, NoiseSetting> noise_settings;

UnrealEngineSetting ue_setting;

CameraSetting()
{
initializeCaptureSettings(capture_settings);
Expand Down Expand Up @@ -1020,6 +1032,32 @@ namespace airlib
return gimbal;
}

static void loadUnrealEngineSetting(const msr::airlib::Settings& settings_json, UnrealEngineSetting& ue_setting)
{
Settings ue_settings_json;
if (settings_json.getChild("UnrealEngine", ue_settings_json)) {
Settings pixel_format_override_settings_json;
ue_setting.pixel_format_override_settings.clear();

for (int i = 0; i < Utils::toNumeric(ImageType::Count); i++) {
PixelFormatOverrideSetting pixel_format_setting;
pixel_format_setting.pixel_format = 0; // EXPixelformat::PF_Unknown
ue_setting.pixel_format_override_settings[i] = pixel_format_setting;
}

if (ue_settings_json.getChild("PixelFormatOverride", pixel_format_override_settings_json)) {
for (size_t child_index = 0; child_index < pixel_format_override_settings_json.size(); ++child_index) {
Settings pixel_format_child_json;
if (pixel_format_override_settings_json.getChild(child_index, pixel_format_child_json)) {
int image_type = pixel_format_child_json.getInt("ImageType", 0);
PixelFormatOverrideSetting& pixel_format_setting = ue_setting.pixel_format_override_settings.at(image_type);
pixel_format_setting.pixel_format = pixel_format_child_json.getInt("PixelFormat", 0); // default to EXPixelformat::PF_Unknown
}
}
}
}
}

static CameraSetting createCameraSetting(const Settings& settings_json)
{
CameraSetting setting;
Expand All @@ -1033,6 +1071,8 @@ namespace airlib
if (settings_json.getChild("Gimbal", json_gimbal))
setting.gimbal = createGimbalSetting(json_gimbal);

loadUnrealEngineSetting(settings_json, setting.ue_setting);

return setting;
}

Expand Down
10 changes: 5 additions & 5 deletions Examples/StandAloneSensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace airlib
output_stream << output.angular_velocity.x() << "\t" << output.angular_velocity.y() << "\t" << output.angular_velocity.z() << "\t";
output_stream << output.linear_acceleration.x() << "\t" << output.linear_acceleration.y() << "\t" << output.linear_acceleration.z() << "\n";

std::this_thread::sleep_for(std::chrono::duration<double>(period - (Utils::getTimeSinceEpochSecs() - last)));
std::this_thread::sleep_for(std::chrono::duration<double>(static_cast<double>(period) - (Utils::getTimeSinceEpochSecs() - last)));

last = Utils::getTimeSinceEpochSecs();
environment.update();
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace airlib
output_stream << Utils::getTimeSinceEpochSecs() << "\t";
output_stream << output.pressure << "\t" << output.altitude << std::endl;

std::this_thread::sleep_for(std::chrono::duration<double>(period - (Utils::getTimeSinceEpochSecs() - last)));
std::this_thread::sleep_for(std::chrono::duration<double>(static_cast<double>(period) - (Utils::getTimeSinceEpochSecs() - last)));

last = Utils::getTimeSinceEpochSecs();
environment.update();
Expand Down Expand Up @@ -99,7 +99,7 @@ namespace airlib
output_stream << Utils::getTimeSinceEpochSecs() << "\t";
output_stream << output.pressure << "\t" << output.altitude << "\t" << environment.getState().geo_point.altitude << std::endl;

std::this_thread::sleep_for(std::chrono::duration<double>(period - (Utils::getTimeSinceEpochSecs() - last)));
std::this_thread::sleep_for(std::chrono::duration<double>(static_cast<double>(period) - (Utils::getTimeSinceEpochSecs() - last)));

last = Utils::getTimeSinceEpochSecs();
environment.update();
Expand Down Expand Up @@ -147,7 +147,7 @@ namespace airlib
output_stream << output.magnetic_field_body.x() << "\t" << output.magnetic_field_body.y() << "\t" << output.magnetic_field_body.z();
output_stream << std::endl;

std::this_thread::sleep_for(std::chrono::duration<double>(period - (Utils::getTimeSinceEpochSecs() - last)));
std::this_thread::sleep_for(std::chrono::duration<double>(static_cast<double>(period) - (Utils::getTimeSinceEpochSecs() - last)));
last = Utils::getTimeSinceEpochSecs();
environment.update();
mag.update();
Expand Down Expand Up @@ -196,7 +196,7 @@ namespace airlib
output_stream << "\t" << kinematics.pose.orientation.w() << "\t" << kinematics.pose.orientation.x() << "\t" << kinematics.pose.orientation.y() << "\t" << kinematics.pose.orientation.z();
output_stream << std::endl;

std::this_thread::sleep_for(std::chrono::duration<double>(period - (Utils::getTimeSinceEpochSecs() - last)));
std::this_thread::sleep_for(std::chrono::duration<double>(static_cast<double>(period) - (Utils::getTimeSinceEpochSecs() - last)));
last = Utils::getTimeSinceEpochSecs();
environment.update();
mag.update();
Expand Down
38 changes: 17 additions & 21 deletions Examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
#include "GaussianMarkovTest.hpp"
#include "DepthNav/DepthNavCost.hpp"
#include "DepthNav/DepthNavThreshold.hpp"
#include "DepthNav/DepthNavOptAStar.hpp"
#include <iostream>
#include <string>
#include <sys/stat.h>
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#include <cmath>

int runStandAloneSensors(int argc, const char* argv[])
{
Expand Down Expand Up @@ -40,8 +38,8 @@ int runStandAloneSensors(int argc, const char* argv[])
//marymoore park
//GeoPoint testLocation(47.662804385, -122.1167039875, 9.93f);

GeoPoint testLocation(47.7631699747, -122.0685655406, 9.93f); // woodinville
float yawOffset = 0; // static_cast<float>(91.27622 * M_PI / 180.0); // I was aligned with the road...
const GeoPoint testLocation(47.7631699747, -122.0685655406, 9.93f); // woodinville
constexpr float yawOffset = 0; // static_cast<float>(91.27622 * M_PI / 180.0); // I was aligned with the road...

std::ofstream out_file(argv[1]);
StandALoneSensors::generateImuStaticData(out_file, period, total_duration);
Expand All @@ -62,25 +60,26 @@ int runStandAlonePhysics(int argc, const char* argv[])
return 0;
}

void runDataCollectorSGM(int num_samples, std::string storage_path)
void runDataCollectorSGM(const int num_samples, const std::string storage_path)
{
DataCollectorSGM gen(storage_path);
gen.generate(num_samples);
}

void runDataCollectorSGM(int argc, const char* argv[])
void runDataCollectorSGM(const int argc, const char* argv[])
{
runDataCollectorSGM(argc < 2 ? 5000 : std::stoi(argv[1]), argc < 3 ? common_utils::FileSystem::combine(common_utils::FileSystem::getAppDataFolder(), "data_sgm") : std::string(argv[2]));
}
void runSteroImageGenerator(int num_samples, std::string storage_path)

void runStereoImageGenerator(const int num_samples, const std::string storage_path)
{
StereoImageGenerator gen(storage_path);
gen.generate(num_samples);
}

void runSteroImageGenerator(int argc, const char* argv[])
void runStereoImageGenerator(const int argc, const char* argv[])
{
runSteroImageGenerator(argc < 2 ? 50000 : std::stoi(argv[1]), argc < 3 ? common_utils::FileSystem::combine(common_utils::FileSystem::getAppDataFolder(), "stereo_gen") : std::string(argv[2]));
runStereoImageGenerator(argc < 2 ? 50000 : std::stoi(argv[1]), argc < 3 ? common_utils::FileSystem::combine(common_utils::FileSystem::getAppDataFolder(), "stereo_gen") : std::string(argv[2]));
}

void runGaussianMarkovTest()
Expand All @@ -96,7 +95,7 @@ void runDepthNavGT()
typedef ImageCaptureBase::ImageRequest ImageRequest;
typedef ImageCaptureBase::ImageType ImageType;

std::vector<ImageRequest> request = {
const std::vector<ImageRequest> request{
ImageRequest("front_left", ImageType::DepthPlanar, true) /*,
ImageRequest("front_left", ImageType::Scene),
ImageRequest("front_left", ImageType::DisparityNormalized, true) */
Expand Down Expand Up @@ -126,7 +125,7 @@ void runDepthNavSGM()
typedef ImageCaptureBase::ImageRequest ImageRequest;
typedef ImageCaptureBase::ImageType ImageType;

std::vector<ImageRequest> request = {
const std::vector<ImageRequest> request{
ImageRequest("front_left", ImageType::Scene, false, false),
ImageRequest("front_right", ImageType::Scene, false, false), /*
ImageRequest("front_left", ImageType::DepthPlanar, true),
Expand All @@ -150,23 +149,20 @@ void runDepthNavSGM()
depthNav.initialize(client, request);

SGMOptions params;
CStateStereo* p_state;
CStateStereo p_state;

if (params.maxImageDimensionWidth != (int)depthNav.params_.depth_width)
if (params.maxImageDimensionWidth != static_cast<int>(depthNav.params_.depth_width))
printf("WARNING: Width Mismatch between SGM and DepthNav. Overwriting parameters.\n");
params.maxImageDimensionWidth = depthNav.params_.depth_width;
params.maxImageDimensionWidth = static_cast<int>(depthNav.params_.depth_width);

params.Print();
p_state = new CStateStereo();
p_state->Initialize(params, depthNav.params_.depth_height, depthNav.params_.depth_width);

depthNav.gotoGoalSGM(goalPose, client, request, p_state);
p_state.Initialize(params, static_cast<int>(depthNav.params_.depth_height), static_cast<int>(depthNav.params_.depth_width));

//Cleanup
delete p_state;
depthNav.gotoGoalSGM(goalPose, client, request, &p_state);
}

int main(int argc, const char* argv[])
int main(const int argc, const char* argv[])
{
//runDepthNavGT();
//runDepthNavSGM();
Expand Down
9 changes: 4 additions & 5 deletions HelloCar/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ STRICT_MODE_ON
#include "vehicles/car/api/CarRpcLibClient.hpp"
#include "common/common_utils/FileSystem.hpp"
#include <iostream>
#include <chrono>

int main()
{
Expand All @@ -34,11 +33,11 @@ int main()

std::cout << "Press Enter to get FPV image" << std::endl;
std::cin.get();
vector<ImageRequest> request = { ImageRequest("0", ImageType::Scene), ImageRequest("1", ImageType::DepthPlanar, true) };
const vector<ImageResponse>& response = client.simGetImages(request);
const std::vector<ImageRequest> request{ ImageRequest("0", ImageType::Scene), ImageRequest("1", ImageType::DepthPlanar, true) };
const std::vector<ImageResponse>& response = client.simGetImages(request);
std::cout << "# of images received: " << response.size() << std::endl;

if (response.size() > 0) {
if (!response.size()) {
std::cout << "Enter path with ending separator to save images (leave empty for no save)" << std::endl;
std::string path;
std::getline(std::cin, path);
Expand Down Expand Up @@ -90,7 +89,7 @@ int main()
client.setCarControls(CarApiBase::CarControls());
}
catch (rpc::rpc_error& e) {
std::string msg = e.get_error().as<std::string>();
const auto msg = e.get_error().as<std::string>();
std::cout << "Exception raised by the API, something went wrong." << std::endl
<< msg << std::endl;
std::cin.get();
Expand Down
14 changes: 7 additions & 7 deletions HelloDrone/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ int main()

std::cout << "Press Enter to get FPV image" << std::endl;
std::cin.get();
vector<ImageRequest> request = { ImageRequest("0", ImageType::Scene), ImageRequest("1", ImageType::DepthPlanar, true) };
const vector<ImageResponse>& response = client.simGetImages(request);
const std::vector<ImageRequest> request{ ImageRequest("0", ImageType::Scene), ImageRequest("1", ImageType::DepthPlanar, true) };
const std::vector<ImageResponse>& response = client.simGetImages(request);
std::cout << "# of images received: " << response.size() << std::endl;

if (response.size() > 0) {
if (!response.size()) {
std::cout << "Enter path with ending separator to save images (leave empty for no save)" << std::endl;
std::string path;
std::getline(std::cin, path);
Expand Down Expand Up @@ -109,9 +109,9 @@ int main()

auto position = client.getMultirotorState().getPosition();
float z = position.z(); // current position (NED coordinate system).
const float speed = 3.0f;
const float size = 10.0f;
const float duration = size / speed;
constexpr float speed = 3.0f;
constexpr float size = 10.0f;
constexpr float duration = size / speed;
DrivetrainType drivetrain = DrivetrainType::ForwardOnly;
YawMode yaw_mode(true, 0);

Expand Down Expand Up @@ -139,7 +139,7 @@ int main()
client.armDisarm(false);
}
catch (rpc::rpc_error& e) {
std::string msg = e.get_error().as<std::string>();
const auto msg = e.get_error().as<std::string>();
std::cout << "Exception raised by the API, something went wrong." << std::endl
<< msg << std::endl;
}
Expand Down
Loading

0 comments on commit cf97e20

Please sign in to comment.