-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3626 from jonyMarino/pr/external_physics_engine
External physics engine
- Loading branch information
Showing
10 changed files
with
130 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#ifndef airsim_core_ExternalPhysicsEngine_hpp | ||
#define airsim_core_ExternalPhysicsEngine_hpp | ||
|
||
#include "common/Common.hpp" | ||
#include "physics/PhysicsEngineBase.hpp" | ||
#include <iostream> | ||
#include <sstream> | ||
#include <fstream> | ||
#include <memory> | ||
#include "common/CommonStructs.hpp" | ||
#include "common/SteppableClock.hpp" | ||
#include <cinttypes> | ||
|
||
namespace msr | ||
{ | ||
namespace airlib | ||
{ | ||
|
||
class ExternalPhysicsEngine : public PhysicsEngineBase { | ||
public: | ||
ExternalPhysicsEngine() | ||
{ | ||
} | ||
|
||
//*** Start: UpdatableState implementation ***// | ||
virtual void resetImplementation() override | ||
{ | ||
|
||
} | ||
|
||
virtual void update() override | ||
{ | ||
PhysicsEngineBase::update(); | ||
|
||
for (PhysicsBody* body_ptr : *this) { | ||
body_ptr->updateKinematics(); | ||
body_ptr->update(); | ||
} | ||
|
||
} | ||
virtual void reportState(StateReporter& reporter) override | ||
{ | ||
for (PhysicsBody* body_ptr : *this) { | ||
reporter.writeValue("ExternalPhysicsEngine",true); | ||
reporter.writeValue("Is Grounded", body_ptr->isGrounded()); | ||
} | ||
//call base | ||
UpdatableObject::reportState(reporter); | ||
} | ||
//*** End: UpdatableState implementation ***// | ||
|
||
}; | ||
|
||
} //namespace | ||
} //namespace | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import setup_path | ||
import airsim | ||
import time | ||
|
||
# This example shows how to use the External Physics Engine | ||
# It allows you to control the drone through setVehiclePose and obtain collision information. | ||
# It is especially useful for injecting your own flight dynamics model to the AirSim drone. | ||
|
||
# Use Blocks environment to see the drone colliding and seeing the collision information | ||
# in the command prompt. | ||
|
||
# Add this line to your settings.json before running AirSim: | ||
# "PhysicsEngineName":"ExternalPhysicsEngine" | ||
|
||
|
||
client = airsim.VehicleClient() | ||
client.confirmConnection() | ||
pose = client.simGetVehiclePose() | ||
|
||
pose.orientation = airsim.to_quaternion(0.1, 0.1, 0.1) | ||
client.simSetVehiclePose( pose, False ) | ||
|
||
for i in range(900): | ||
print(i) | ||
pose = client.simGetVehiclePose() | ||
pose.position = pose.position + airsim.Vector3r(0.03, 0, 0) | ||
pose.orientation = pose.orientation + airsim.to_quaternion(0.1, 0.1, 0.1) | ||
client.simSetVehiclePose( pose, False ) | ||
time.sleep(0.003) | ||
collision = client.simGetCollisionInfo() | ||
if collision.has_collided: | ||
print(collision) | ||
|
||
client.reset() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters