Created
January 16, 2019 15:27
-
-
Save jasonhbartlett/59e7ad7328dbb639c1db21754bfe2290 to your computer and use it in GitHub Desktop.
hello_drone3.py flies the drone in a simple WWWWW flight pattern.
This file contains hidden or 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
import setup_path | |
import airsim | |
import numpy as np | |
import os | |
import tempfile | |
import pprint | |
import time | |
# connect to the AirSim simulator | |
client = airsim.MultirotorClient() | |
client.confirmConnection() | |
print("Disabling Api Control") | |
client.enableApiControl(False) | |
if (client.isApiControlEnabled() == False): | |
client.enableApiControl(True) | |
print("Enabled Api Control") | |
client.armDisarm(True) | |
client.takeoffAsync().join() | |
for i in range(100): | |
time.sleep(3) | |
pos = client.simGetGroundTruthKinematics().position | |
print("{:.3f},{:.3f},{:.3f}".format(pos.x_val, pos.y_val, pos.z_val)) | |
client.enableApiControl(True) | |
client.moveToPositionAsync(-5, pos.y_val + 1, -3, 1).join() | |
pos = client.simGetGroundTruthKinematics().position | |
print("{:.3f},{:.3f},{:.3f}".format(pos.x_val, pos.y_val, pos.z_val)) | |
time.sleep(3) | |
pos = client.simGetGroundTruthKinematics().position | |
print("{:.3f},{:.3f},{:.3f}".format(pos.x_val, pos.y_val, pos.z_val)) | |
client.enableApiControl(True) | |
client.moveToPositionAsync(5, pos.y_val + 1, -3, 1).join() | |
pos = client.simGetGroundTruthKinematics().position | |
print("{:.3f},{:.3f},{:.3f}".format(pos.x_val, pos.y_val, pos.z_val)) | |
client.landAsync().join() | |
client.armDisarm(False) | |
client.enableApiControl(False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment