Skip to content

Commit

Permalink
Merge of Colosseum by Codex Laboratories LLC
Browse files Browse the repository at this point in the history
  • Loading branch information
WouterJansen committed Apr 22, 2024
2 parents 626e6d7 + fb703f1 commit d48c94d
Show file tree
Hide file tree
Showing 42 changed files with 536 additions and 320 deletions.
2 changes: 2 additions & 0 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ namespace airlib
bool isRecording();

void simSetWind(const Vector3r& wind) const;
void simSetExtForce(const Vector3r& ext_force) const;

vector<string> listVehicles();

std::string getSettingsString() const;
Expand Down
1 change: 1 addition & 0 deletions AirLib/include/api/WorldSimApiBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace airlib
virtual bool isRecording() const = 0;

virtual void setWind(const Vector3r& wind) const = 0;
virtual void setExtForce(const Vector3r& ext_force) const = 0;
virtual vector<string> listVehicles() const = 0;

virtual std::string getSettingsString() const = 0;
Expand Down
16 changes: 11 additions & 5 deletions AirLib/include/common/AirSimSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,13 @@ namespace airlib
CameraDirectorSetting camera_director;
std::map<std::string, std::unique_ptr<BeaconSetting>> beacons;
std::map<std::string, std::unique_ptr<PassiveEchoBeaconSetting>> passive_echo_beacons;
float speed_unit_factor = 1.0f;
float speed_unit_factor = 1.0f;
std::string speed_unit_label = "m\\s";
std::map<std::string, std::shared_ptr<SensorSetting>> sensor_defaults;
Vector3r wind = Vector3r::Zero();
std::string settings_text_ = "";
Vector3r ext_force = Vector3r::Zero();
std::string material_list_file = "";
std::string settings_text_ = "";

public: //methods
static AirSimSettings& singleton()
Expand Down Expand Up @@ -543,7 +544,7 @@ namespace airlib
Settings& settings_json = Settings::singleton();
//write some settings_json in new file otherwise the string "null" is written if all settings_json are empty
settings_json.setString("SeeDocsAt", "https://cosysgit.uantwerpen.be/sensorsimulation/airsim/-/blob/master/docs/settings.md");
settings_json.setDouble("SettingsVersion", 1.2);
settings_json.setDouble("SettingsVersion", 2.0);

std::string settings_filename = Settings::getUserDirectoryFullPath("settings.json");
//TODO: there is a crash in Linux due to settings_json.saveJSonString(). Remove this workaround after we only support Unreal 4.17
Expand Down Expand Up @@ -802,7 +803,6 @@ namespace airlib
capture_settings[i] = CaptureSetting();
}
capture_settings.at(Utils::toNumeric(ImageType::Scene)).target_gamma = CaptureSetting::kSceneTargetGamma;
capture_settings.at(Utils::toNumeric(ImageType::Segmentation)).target_gamma = 1;
}

static void loadCaptureSettings(const Settings& settings_json, CaptureSettingsMap& capture_settings)
Expand Down Expand Up @@ -1407,6 +1407,13 @@ namespace airlib
wind = createVectorSetting(child_json, wind);
}
}
{
// External Force Settings
Settings child_json;
if (settings_json.getChild("ExternalForce", child_json)) {
ext_force = createVectorSetting(child_json, ext_force);
}
}
}

static void loadDefaultCameraSetting(const Settings& settings_json, CameraSetting& camera_defaults)
Expand All @@ -1416,7 +1423,6 @@ namespace airlib
camera_defaults = createCameraSetting(child_json, camera_defaults);
}
}

static void loadCameraDirectorSetting(const Settings& settings_json,
CameraDirectorSetting& camera_director, const std::string& simmode_name)
{
Expand Down
27 changes: 20 additions & 7 deletions AirLib/include/physics/FastPhysicsEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace airlib
class FastPhysicsEngine : public PhysicsEngineBase
{
public:
FastPhysicsEngine(bool enable_ground_lock = true, Vector3r wind = Vector3r::Zero())
: enable_ground_lock_(enable_ground_lock), wind_(wind)
FastPhysicsEngine(bool enable_ground_lock = true, Vector3r wind = Vector3r::Zero(), Vector3r ext_force = Vector3r::Zero())
: enable_ground_lock_(enable_ground_lock), wind_(wind), ext_force_(ext_force)
{
setName("FastPhysicsEngine");
}
Expand Down Expand Up @@ -69,6 +69,11 @@ namespace airlib
{
wind_ = wind;
}
// Set External Force
void setExtForce(const Vector3r& ext_force) override
{
ext_force_ = ext_force;
}

private:
void initPhysicsBody(PhysicsBody* body_ptr)
Expand All @@ -88,7 +93,7 @@ namespace airlib

//first compute the response as if there was no collision
//this is necessary to take in to account forces and torques generated by body
getNextKinematicsNoCollision(dt, body, current, next, next_wrench, wind_);
getNextKinematicsNoCollision(dt, body, current, next, next_wrench, wind_, ext_force_);

//if there is collision, see if we need collision response
const CollisionInfo collision_info = body.getCollisionInfo();
Expand Down Expand Up @@ -261,8 +266,11 @@ namespace airlib
}
}

static Wrench getDragWrench(const PhysicsBody& body, const Quaternionr& orientation,
const Vector3r& linear_vel, const Vector3r& angular_vel_body, const Vector3r& wind_world)
static Wrench getDragWrench(const PhysicsBody& body,
const Quaternionr& orientation,
const Vector3r& linear_vel,
const Vector3r& angular_vel_body,
const Vector3r& wind_world)
{
//add linear drag due to velocity we had since last dt seconds + wind
//drag vector magnitude is proportional to v^2, direction opposite of velocity
Expand Down Expand Up @@ -323,7 +331,7 @@ namespace airlib
}

static void getNextKinematicsNoCollision(TTimeDelta dt, PhysicsBody& body, const Kinematics::State& current,
Kinematics::State& next, Wrench& next_wrench, const Vector3r& wind)
Kinematics::State& next, Wrench& next_wrench, const Vector3r& wind, const Vector3r& ext_force)
{
const real_T dt_real = static_cast<real_T>(dt);

Expand Down Expand Up @@ -356,7 +364,11 @@ namespace airlib
avg_angular = current.twist.angular + current.accelerations.angular * (0.5f * dt_real);
const Wrench drag_wrench = getDragWrench(body, current.pose.orientation, avg_linear, avg_angular, wind);

next_wrench = body_wrench + drag_wrench;
// ext_force is defined in world space
Wrench ext_force_wrench = Wrench::zero();
ext_force_wrench.force = ext_force;

next_wrench = body_wrench + drag_wrench + ext_force_wrench;

//Utils::log(Utils::stringf("B-WRN %s: ", VectorMath::toString(body_wrench.force).c_str()));
//Utils::log(Utils::stringf("D-WRN %s: ", VectorMath::toString(drag_wrench.force).c_str()));
Expand Down Expand Up @@ -459,6 +471,7 @@ namespace airlib
bool enable_ground_lock_;
TTimePoint last_message_time;
Vector3r wind_;
Vector3r ext_force_;
};
}
} //namespace
Expand Down
1 change: 1 addition & 0 deletions AirLib/include/physics/PhysicsEngineBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace airlib
}

virtual void setWind(const Vector3r& wind) { unused(wind); };
virtual void setExtForce(const Vector3r& ext_force) { unused(ext_force); };
};
}
} //namespace
Expand Down
6 changes: 5 additions & 1 deletion AirLib/src/api/RpcLibClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,11 @@ __pragma(warning(disable : 4239))
RpcLibAdaptorsBase::Vector3r conv_wind(wind);
pimpl_->client.call("simSetWind", conv_wind);
}

void RpcLibClientBase::simSetExtForce(const Vector3r& ext_force) const
{
RpcLibAdaptorsBase::Vector3r conv_ext_force(ext_force);
pimpl_->client.call("simSetExtForce", conv_ext_force);
}
vector<string> RpcLibClientBase::listVehicles()
{
return pimpl_->client.call("listVehicles").as<vector<string>>();
Expand Down
5 changes: 4 additions & 1 deletion AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ namespace airlib
const auto& response = getWorldSimApi()->getDetections(type, CameraDetails(camera_name, vehicle_name));
return RpcLibAdaptorsBase::DetectionInfo::from(response);
});

pimpl_->server.bind("reset", [&]() -> void {
//Exit if already resetting.
static bool resetInProgress;
Expand Down Expand Up @@ -545,6 +544,10 @@ namespace airlib
getWorldSimApi()->setWind(wind.to());
});

pimpl_->server.bind("simSetExtForce", [&](const RpcLibAdaptorsBase::Vector3r& ext_force) -> void {
getWorldSimApi()->setExtForce(ext_force.to());
});

pimpl_->server.bind("listVehicles", [&]() -> vector<string> {
return getWorldSimApi()->listVehicles();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ __pragma(warning(disable : 4239))
MultirotorRpcLibClient* MultirotorRpcLibClient::moveToGPSAsync(float latitude, float longitude, float altitude, float velocity, float timeout_sec,
DrivetrainType drivetrain, const YawMode& yaw_mode, float lookahead, float adaptive_lookahead, const std::string& vehicle_name)
{
pimpl_->last_future = static_cast<rpc::client*>(getClient())->async_call("movetoGPS", latitude, longitude, altitude, velocity, timeout_sec, drivetrain, MultirotorRpcLibAdaptors::YawMode(yaw_mode), lookahead, adaptive_lookahead, vehicle_name);
pimpl_->last_future = static_cast<rpc::client*>(getClient())->async_call("moveToGPS", latitude, longitude, altitude, velocity, timeout_sec, drivetrain, MultirotorRpcLibAdaptors::YawMode(yaw_mode), lookahead, adaptive_lookahead, vehicle_name);
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion HelloDrone/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main()
const std::vector<ImageResponse>& response = client.simGetImages(request);
std::cout << "# of images received: " << response.size() << std::endl;

if (!response.size()) {
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
36 changes: 35 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
============================= Original License ================================
The MIT License (MIT)

MSR Aerial Informatics and Robotics Platform
MSR Aerial Informatics and Robotics Simulator (AirSim)

Copyright (c) Microsoft Corporation
Copyright (c) Microsoft Corporation. 2022

All rights reserved.

Expand All @@ -12,3 +13,36 @@ MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
===============================================================================
===================== New License by Codex Laboratories ======================
The MIT License (MIT)

MSR Aerial Informatics and Robotics Platform
MSR Aerial Informatics and Robotics Simulator (AirSim)

Copyright (c) Codex Laboratories LLC. 2022

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

===============================================================================
======================== New License by Cosys-Lab ============================
The MIT License (MIT)

MSR Aerial Informatics and Robotics Platform
MSR Aerial Informatics and Robotics Simulator (AirSim)

Copyright (c) University of Antwerp, Belgium 2024

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
Loading

0 comments on commit d48c94d

Please sign in to comment.