Skip to content

Commit

Permalink
added option to turn on off ground lock
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Jul 28, 2017
1 parent edcde6f commit d4b379c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
12 changes: 8 additions & 4 deletions AirLib/include/physics/FastPhysicsEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace msr { namespace airlib {

class FastPhysicsEngine : public PhysicsEngineBase {
public:
FastPhysicsEngine()
FastPhysicsEngine(bool enable_ground_lock = true)
: enable_ground_lock_(enable_ground_lock)
{
FastPhysicsEngine::reset();
}
Expand Down Expand Up @@ -79,7 +80,8 @@ class FastPhysicsEngine : public PhysicsEngineBase {
CollisonResponseInfo& collison_response_info = body.getCollisionResponseInfo();
//if collision was already responsed then do not respond to it until we get updated information
if (collison_info.has_collided && collison_response_info.collision_time_stamp != collison_info.time_stamp) {
bool is_collison_response = getNextKinematicsOnCollison(dt, collison_info, body, current, next, next_wrench);
bool is_collison_response = getNextKinematicsOnCollison(dt, collison_info, body,
current, next, next_wrench, enable_ground_lock_);
updateCollisonResponseInfo(collison_info, next, is_collison_response, collison_response_info);
}

Expand All @@ -101,7 +103,7 @@ class FastPhysicsEngine : public PhysicsEngineBase {

//return value indicates if collison response was generated
static bool getNextKinematicsOnCollison(TTimeDelta dt, const CollisionInfo& collison_info, const PhysicsBody& body,
const Kinematics::State& current, Kinematics::State& next, Wrench& next_wrench)
const Kinematics::State& current, Kinematics::State& next, Wrench& next_wrench, bool enable_ground_lock)
{
/************************* Collison response ************************/
const real_T dt_real = static_cast<real_T>(dt);
Expand Down Expand Up @@ -179,7 +181,7 @@ class FastPhysicsEngine : public PhysicsEngineBase {
next.accelerations.angular = Vector3r::Zero();

next.pose = current.pose;
if (ground_lock) {
if (enable_ground_lock && ground_lock) {
float pitch, roll, yaw;
VectorMath::toEulerianAngle(next.pose.orientation, pitch, roll, yaw);
pitch = roll = 0;
Expand Down Expand Up @@ -380,6 +382,8 @@ class FastPhysicsEngine : public PhysicsEngineBase {

std::stringstream debug_string_;
int grounded_;
bool enable_ground_lock_;

};

}} //namespace
Expand Down
16 changes: 14 additions & 2 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeWorldBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,20 @@ void ASimModeWorldBase::createWorld()
{
if (physics_engine_name == "" || usage_scenario == kUsageScenarioComputerVision)
physics_engine_.release(); //no physics engine
else if (physics_engine_name == "FastPhysicsEngine")
physics_engine_.reset(new msr::airlib::FastPhysicsEngine());
else if (physics_engine_name == "FastPhysicsEngine") {
msr::airlib::Settings fast_phys_settings;
if (msr::airlib::Settings::singleton().getChild("FastPhysicsEngine", fast_phys_settings)) {
physics_engine_.reset(
new msr::airlib::FastPhysicsEngine(fast_phys_settings.getBool("EnableGroundLock", true))
);
}
else {
physics_engine_.reset(
new msr::airlib::FastPhysicsEngine()
);
}

}
else {
physics_engine_.release();
UAirBlueprintLib::LogMessageString("Unrecognized physics engine name: ", physics_engine_name, LogDebugLevel::Failure);
Expand Down

0 comments on commit d4b379c

Please sign in to comment.