-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation, example script for setWind API
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import setup_path | ||
import airsim | ||
import time | ||
|
||
client = airsim.MultirotorClient() | ||
client.confirmConnection() | ||
client.enableApiControl(True) | ||
|
||
client.armDisarm(True) | ||
|
||
# Set wind to (20,0,0) in NED (forward direction) | ||
print("Setting wind to (20,0,0)") | ||
wind = airsim.Vector3r(20, 0, 0) | ||
client.simSetWind(wind) | ||
|
||
# Takeoff or hover | ||
landed = client.getMultirotorState().landed_state | ||
if landed == airsim.LandedState.Landed: | ||
print("taking off...") | ||
client.takeoffAsync().join() | ||
else: | ||
print("already flying...") | ||
client.hoverAsync().join() | ||
|
||
time.sleep(5) | ||
|
||
# Set wind to (0,25,0) in NED (towards right) | ||
print("Setting wind to (0,25,0)") | ||
wind = airsim.Vector3r(0, 25, 0) | ||
client.simSetWind(wind) | ||
|
||
time.sleep(5) | ||
|
||
# Set wind to 0 | ||
print("Resetting wind to (0,0,0)") | ||
wind = airsim.Vector3r(0, 0, 0) | ||
client.simSetWind(wind) |
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