Skip to content

Commit

Permalink
Add some Python samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
lovettchris committed May 17, 2017
1 parent 9998b74 commit 4d4c54e
Show file tree
Hide file tree
Showing 14 changed files with 269 additions and 8 deletions.
2 changes: 1 addition & 1 deletion AirLib/include/controllers/DroneCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace msr { namespace airlib {


enum class DrivetrainType {
MaxDegreeOfFreedome = 0,
MaxDegreeOfFreedom = 0,
ForwardOnly
};

Expand Down
8 changes: 4 additions & 4 deletions AirLib/include/rpc/RpcLibClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class RpcLibClient {
bool moveByAngle(float pitch, float roll, float z, float yaw, float duration);

bool moveByVelocity(float vx, float vy, float vz, float duration,
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedome, const YawMode& yaw_mode = YawMode());
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedom, const YawMode& yaw_mode = YawMode());
bool moveByVelocityZ(float vx, float vy, float z, float duration,
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedome, const YawMode& yaw_mode = YawMode());
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedom, const YawMode& yaw_mode = YawMode());
bool moveOnPath(const vector<Vector3r>& path, float velocity,
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedome, const YawMode& yaw_mode = YawMode(), float lookahead = -1, float adaptive_lookahead = 1);
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedom, const YawMode& yaw_mode = YawMode(), float lookahead = -1, float adaptive_lookahead = 1);
bool moveToPosition(float x, float y, float z, float velocity,
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedome, const YawMode& yaw_mode = YawMode(), float lookahead = -1, float adaptive_lookahead = 1);
DrivetrainType drivetrain = DrivetrainType::MaxDegreeOfFreedom, const YawMode& yaw_mode = YawMode(), float lookahead = -1, float adaptive_lookahead = 1);
bool moveToZ(float z, float velocity,
const YawMode& yaw_mode = YawMode(), float lookahead = -1, float adaptive_lookahead = 1);
bool moveByManual(float vx_max, float vy_max, float z_min, DrivetrainType drivetrain, const YawMode& yaw_mode, float duration);
Expand Down
2 changes: 1 addition & 1 deletion AirLib/src/controllers/DroneControllerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ bool DroneControllerBase::moveToZ(float z, float velocity, const YawMode& yaw_mo
{
Vector2r cur_xy = getPositionXY();
vector<Vector3r> path { Vector3r(cur_xy.x(), cur_xy.y(), z) };
return moveOnPath(path, velocity, DrivetrainType::MaxDegreeOfFreedome, yaw_mode, lookahead, adaptive_lookahead,
return moveOnPath(path, velocity, DrivetrainType::MaxDegreeOfFreedom, yaw_mode, lookahead, adaptive_lookahead,
cancelable_action);
}

Expand Down
26 changes: 26 additions & 0 deletions AirSim.sln
Original file line number Diff line number Diff line change
Expand Up @@ -70,78 +70,104 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SimMode", "SimMode", "{6175
Unreal\Plugins\AirSim\Source\SimMode\SimModeWorldMultiRotor.h = Unreal\Plugins\AirSim\Source\SimMode\SimModeWorldMultiRotor.h
EndProjectSection
EndProject
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "PythonClient", "PythonClient\PythonClient.pyproj", "{E2049E20-B6DD-474E-8BCA-1C8DC54725AA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Debug|Any CPU.ActiveCfg = Debug|Win32
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Debug|x64.ActiveCfg = Debug|x64
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Debug|x64.Build.0 = Debug|x64
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Debug|x86.ActiveCfg = Debug|Win32
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Debug|x86.Build.0 = Debug|Win32
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Release|Any CPU.ActiveCfg = Release|Win32
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Release|x64.ActiveCfg = Release|x64
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Release|x64.Build.0 = Release|x64
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Release|x86.ActiveCfg = Release|Win32
{9FE9234B-373A-4D5A-AD6B-FB0B593312DD}.Release|x86.Build.0 = Release|Win32
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Debug|Any CPU.ActiveCfg = Debug|Win32
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Debug|x64.ActiveCfg = Debug|x64
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Debug|x64.Build.0 = Debug|x64
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Debug|x86.ActiveCfg = Debug|Win32
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Debug|x86.Build.0 = Debug|Win32
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Release|Any CPU.ActiveCfg = Release|Win32
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Release|x64.ActiveCfg = Release|x64
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Release|x64.Build.0 = Release|x64
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Release|x86.ActiveCfg = Release|Win32
{4BFB7231-077A-4671-BD21-D3ADE3EA36E7}.Release|x86.Build.0 = Release|Win32
{98BB426F-6FB5-4754-81BC-BB481900E135}.Debug|Any CPU.ActiveCfg = Debug|Win32
{98BB426F-6FB5-4754-81BC-BB481900E135}.Debug|x64.ActiveCfg = Debug|x64
{98BB426F-6FB5-4754-81BC-BB481900E135}.Debug|x64.Build.0 = Debug|x64
{98BB426F-6FB5-4754-81BC-BB481900E135}.Debug|x86.ActiveCfg = Debug|Win32
{98BB426F-6FB5-4754-81BC-BB481900E135}.Debug|x86.Build.0 = Debug|Win32
{98BB426F-6FB5-4754-81BC-BB481900E135}.Release|Any CPU.ActiveCfg = Release|Win32
{98BB426F-6FB5-4754-81BC-BB481900E135}.Release|x64.ActiveCfg = Release|x64
{98BB426F-6FB5-4754-81BC-BB481900E135}.Release|x64.Build.0 = Release|x64
{98BB426F-6FB5-4754-81BC-BB481900E135}.Release|x86.ActiveCfg = Release|Win32
{98BB426F-6FB5-4754-81BC-BB481900E135}.Release|x86.Build.0 = Release|Win32
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Debug|Any CPU.ActiveCfg = Debug|Win32
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Debug|x64.ActiveCfg = Debug|x64
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Debug|x64.Build.0 = Debug|x64
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Debug|x86.ActiveCfg = Debug|Win32
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Debug|x86.Build.0 = Debug|Win32
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Release|Any CPU.ActiveCfg = Release|Win32
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Release|x64.ActiveCfg = Release|x64
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Release|x64.Build.0 = Release|x64
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Release|x86.ActiveCfg = Release|Win32
{8510C7A4-BF63-41D2-94F6-D8731D137A5A}.Release|x86.Build.0 = Release|Win32
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Debug|Any CPU.ActiveCfg = Debug|Win32
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Debug|x64.ActiveCfg = Debug|x64
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Debug|x64.Build.0 = Debug|x64
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Debug|x86.ActiveCfg = Debug|Win32
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Debug|x86.Build.0 = Debug|Win32
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Release|Any CPU.ActiveCfg = Release|Win32
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Release|x64.ActiveCfg = Release|x64
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Release|x64.Build.0 = Release|x64
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Release|x86.ActiveCfg = Release|Win32
{A050F015-87E2-498F-866A-2E5AF65AF7AC}.Release|x86.Build.0 = Release|Win32
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Debug|Any CPU.ActiveCfg = Debug|Win32
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Debug|x64.ActiveCfg = Debug|x64
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Debug|x64.Build.0 = Debug|x64
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Debug|x86.ActiveCfg = Debug|Win32
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Debug|x86.Build.0 = Debug|Win32
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Release|Any CPU.ActiveCfg = Release|Win32
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Release|x64.ActiveCfg = Release|x64
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Release|x64.Build.0 = Release|x64
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Release|x86.ActiveCfg = Release|Win32
{25EB67BE-468A-4AA5-910F-07EFD58C5516}.Release|x86.Build.0 = Release|Win32
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Debug|Any CPU.ActiveCfg = Debug|Win32
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Debug|x64.ActiveCfg = Debug|x64
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Debug|x64.Build.0 = Debug|x64
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Debug|x86.ActiveCfg = Debug|Win32
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Debug|x86.Build.0 = Debug|Win32
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Release|Any CPU.ActiveCfg = Release|Win32
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Release|x64.ActiveCfg = Release|x64
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Release|x64.Build.0 = Release|x64
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Release|x86.ActiveCfg = Release|Win32
{C679466F-9D35-4AFC-B9AE-F9FB5448FB99}.Release|x86.Build.0 = Release|Win32
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Debug|Any CPU.ActiveCfg = Debug|Win32
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Debug|x64.ActiveCfg = Debug|x64
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Debug|x64.Build.0 = Debug|x64
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Debug|x86.ActiveCfg = Debug|Win32
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Debug|x86.Build.0 = Debug|Win32
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Release|Any CPU.ActiveCfg = Release|Win32
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Release|x64.ActiveCfg = Release|x64
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Release|x64.Build.0 = Release|x64
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Release|x86.ActiveCfg = Release|Win32
{2A61ED54-2B66-4B9B-99FA-299DD0EF57CD}.Release|x86.Build.0 = Release|Win32
{E2049E20-B6DD-474E-8BCA-1C8DC54725AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2049E20-B6DD-474E-8BCA-1C8DC54725AA}.Debug|x64.ActiveCfg = Debug|Any CPU
{E2049E20-B6DD-474E-8BCA-1C8DC54725AA}.Debug|x86.ActiveCfg = Debug|Any CPU
{E2049E20-B6DD-474E-8BCA-1C8DC54725AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2049E20-B6DD-474E-8BCA-1C8DC54725AA}.Release|x64.ActiveCfg = Release|Any CPU
{E2049E20-B6DD-474E-8BCA-1C8DC54725AA}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion DroneShell/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ See RecordPose for information about log file format")
VectorMath::toEulerianAngle(quaternion, pitch, roll, yaw);

context->client.moveToPosition(local_point.x(), local_point.y(), local_point.z(), velocity,
DrivetrainType::MaxDegreeOfFreedome, YawMode(false, yaw), lookahead, adaptive_lookahead);
DrivetrainType::MaxDegreeOfFreedom, YawMode(false, yaw), lookahead, adaptive_lookahead);
}
}
});
Expand Down
84 changes: 84 additions & 0 deletions PythonClient/PythonClient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# to install this run 'pip install mprpc'
from mprpc import RPCClient
import numpy as np

class AirSimImageType:
Scene = 1
Depth = 2
Segmentation = 4

class DrivetrainType:
MaxDegreeOfFreedom = 0
ForwardOnly = 1

class YawMode:
is_rate = True
yaw_or_rate = 0.0
def __init__(self, is_rate, yaw_or_rate):
self.is_rate = is_rate
self.yaw_or_rate = yaw_or_rate

class AirSimClient:
def __init__(self, ip):
if (ip == ""):
ip = "127.0.0.1"
self.client = RPCClient(ip, 41451)

# basic flight control
def arm(self):
return self.client.call('armDisarm', True)

def disarm(self):
return self.client.call('armDisarm', False)

def takeoff(self):
return self.client.call('takeoff', 10)

def land(self):
return self.client.call('land')

def goHome(self):
return self.client.call('goHome')

def hover(self):
return self.client.call('hover')


# query position of drone
def getPosition(self):
return self.client.call('getPosition')
def getVelocity(self):
return self.client.call('getVelocity')
def getOrientation(self):
return self.client.call('getOrientation')
def getGpsLocation(self):
return self.client.call('getGpsLocation')
def getHomePoint(self):
return self.client.call('getHomePoint')

# special offboard control
def isOffboardMode(self):
return self.client.call('isOffboardMode')
def moveByVelocity(self, vx, vy, vz, duration, drivetrain, yaw_mode):
return self.client.call('moveByVelocity', vx, vy, vz, duration, drivetrain, (yaw_mode.is_rate, yaw_mode.yaw_or_rate))
def moveByVelocityZ(self, vx, vy, z, duration, drivetrain, yaw_mode):
return self.client.call('moveByVelocityZ', vx, vy, z, duration, drivetrain, (yaw_mode.is_rate, yaw_mode.yaw_or_rate))
def moveOnPath(self, path, velocity, drivetrain, yaw_mode, lookahead, adaptive_lookahead):
return self.client.call('moveOnPath', path, velocity, drivetrain, (yaw_mode.is_rate, yaw_mode.yaw_or_rate), lookahead, adaptive_lookahead)
def moveToZ(self, z, velocity, yaw_mode, lookahead, adaptive_lookahead):
return self.client.call('moveToZ', z, velocity, (yaw_mode.is_rate, yaw_mode.yaw_or_rate), lookahead, adaptive_lookahead)
def rotateToYaw(self, yaw, margin):
return self.client.call('rotateToYaw', yaw, margin)
def rotateByYawRate(self, yaw_rate, duration):
return self.client.call('rotateByYawRate', yaw_rate, duration)

# camera control
# image_type uses one of the AirSimImageType members
def setImageTypeForCamera(self, camera_id, image_type):
return self.client.call('setImageTypeForCamera', camera_id, image_type)
def getImageTypeForCamera(self, camera_id):
return self.client.call('getImageTypeForCamera', camera_id)
def getImageForCamera(self, camera_id, image_type):
return np.fromstring(self.client.call('getImageForCamera', camera_id, image_type), np.int8)


Binary file added PythonClient/PythonClient.pyc
Binary file not shown.
53 changes: 53 additions & 0 deletions PythonClient/PythonClient.pyproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>e2049e20-b6dd-474e-8bca-1c8dc54725aa</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>camera.py</StartupFile>
<SearchPath>
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<Name>PythonClient</Name>
<RootNamespace>PythonClient</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<ItemGroup>
<Compile Include="box.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="camera.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="path.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="PythonClient.py" />
<Compile Include="test.py">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<PtvsTargetsFile>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets</PtvsTargetsFile>
</PropertyGroup>
<Import Condition="Exists($(PtvsTargetsFile))" Project="$(PtvsTargetsFile)" />
<Import Condition="!Exists($(PtvsTargetsFile))" Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<!-- Uncomment the CoreCompile target to enable the Build command in
Visual Studio and specify your pre- and post-build commands in
the BeforeBuild and AfterBuild targets below. -->
<!--<Target Name="CoreCompile" />-->
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
</Project>
17 changes: 17 additions & 0 deletions PythonClient/box.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from PythonClient import *
import sys
import time

client = AirSimClient('127.0.0.1')


print("Flying a small square box using moveByVelocityZ")
client.moveByVelocityZ(1,0,-5,5, DrivetrainType.MaxDegreeOfFreedom, YawMode(False, 0))
time.sleep(2)
client.moveByVelocityZ(0,1,-5,5, DrivetrainType.MaxDegreeOfFreedom, YawMode(False, 90))
time.sleep(2)
client.moveByVelocityZ(-1,0,-5,5, DrivetrainType.MaxDegreeOfFreedom, YawMode(False, 180))
time.sleep(2)
client.moveByVelocityZ(0,-1,-5,5, DrivetrainType.MaxDegreeOfFreedom, YawMode(False, 270))
time.sleep(2)

22 changes: 22 additions & 0 deletions PythonClient/camera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# use open cv to show new images from AirSim

from PythonClient import *
import cv2
import time

client = AirSimClient('127.0.0.1')

# you must first press "1" in the AirSim view to turn on the depth capture

# get depth image
client.setImageTypeForCamera(0, AirSimImageType.Depth)
time.sleep(1) # give it time to render

while True:
rawImage = client.getImageForCamera(0, AirSimImageType.Depth)
png = cv2.imdecode(rawImage, cv2.IMREAD_UNCHANGED)
cv2.imshow("Traffic", png)

key = cv2.waitKey(1) & 0xFF;
if (key == 27 or key == ord('q') or key == ord('x')):
break;
9 changes: 9 additions & 0 deletions PythonClient/path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from PythonClient import *
import sys
import time

client = AirSimClient('127.0.0.1')

# see https://github.com/Microsoft/AirSim/wiki/moveOnPath-demo

client.moveOnPath([(0,-253,-5),(125,-253,-5),(125,0,-5),(0,0,-5)], 12, DrivetrainType.ForwardOnly, YawMode(False,0), 15, 1)
31 changes: 31 additions & 0 deletions PythonClient/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from PythonClient import *
import sys
import time

client = AirSimClient('127.0.0.1')

print("Waiting for home GPS location to be set...")
home = client.getHomePoint()
while (home[0] == 0 and home[1] == 0 and home[2] == 0):
time.sleep(1)
home = client.getHomePoint()

print("Home lat=%g, lon=%g, alt=%g" % home)

if (not client.arm()):
print("failed to arm the drone")
sys.exit(1);

if (not client.takeoff()):
print("failed to takeoff")
sys.exit(1);

print("Should now be flying...")
time.sleep(5)

if (not client.land()):
print("failed to land")
sys.exit(1);



4 changes: 3 additions & 1 deletion docs/px4.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,6 @@ gcc-arm-none-eabi-5_4-2017q2/bin
````

If you add this folder to your PATH using the usual `export PATH=...` trick then the PX4 build will be able to find
and run this compiler. After that, you can run `make px4fmu-v2_default` in BashOnWindows.
and run this compiler. After that, you can run `make px4fmu-v2_default` in BashOnWindows and the firmware will appear
here: `build_px4fmu-v2_default/src/firmware/nuttx/px4fmu-v2_default.px4`. You can then flash this new firmware on your
Pixhawk using QGroundControl.
17 changes: 17 additions & 0 deletions docs/python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Using Python with AirSim

You can call AirSim from Python to control the drone and get images back.

First install the following Python package:

````
pip install mprpc
````

Now you can run the samples in the Python folder. For example `path.py` runs my [moveOnPath demo](https://github.com/Microsoft/AirSim/wiki/moveOnPath-demo)
and `camera.py` captures the depth camera and presents it in an opencv window.

## Windows

On windows you may need to install the Microsoft Visual C++ 9.0 from [http://aka.ms/vcpython27](http://aka.ms/vcpython27).

0 comments on commit 4d4c54e

Please sign in to comment.