Skip to content

Commit

Permalink
Add documentation, example script for setWind API
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Jul 21, 2020
1 parent 578fff0 commit c3154e8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
37 changes: 37 additions & 0 deletions PythonClient/multirotor/set_wind.py
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 (25,0,0) in NED (forward direction)
print("Setting wind to (25,0,0)")
wind = airsim.Vector3r(25, 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,30,0) in NED (towards right)
print("Setting wind to (0,30,0)")
wind = airsim.Vector3r(0, 30, 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)
14 changes: 14 additions & 0 deletions docs/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ Please note that `Roadwetness`, `RoadSnow` and `RoadLeaf` effects requires addin

Please see [example code](https://github.com/Microsoft/AirSim/blob/master/PythonClient/computer_vision/weather.py) for more details.

### Wind API

Wind can be changed during simulation using `simSetWind()`. Wind is specified in World frame, NED direction and m/s values

E.g. To set 20m/s wind in North (forward) direction -

```python
# Set wind to (20,0,0) in NED (forward direction)
wind = airsim.Vector3r(20, 0, 0)
client.simSetWind(wind)
```

Also see example script in [set_wind.py](https://github.com/Microsoft/AirSim/blob/master/PythonClient/multirotor/set_wind.py)

### Lidar APIs
AirSim offers API to retrieve point cloud data from Lidar sensors on vehicles. You can set the number of channels, points per second, horizontal and vertical FOV, etc parameters in [settings.json](settings.md).

Expand Down
5 changes: 5 additions & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Below are complete list of settings available along with their default values. I
"PhysicsEngineName": "",
"SpeedUnitFactor": 1.0,
"SpeedUnitLabel": "m/s",
"Wind": { "X": 0, "Y": 0, "Z": 0 },
"Recording": {
"RecordOnMove": false,
"RecordInterval": 0.05,
Expand Down Expand Up @@ -214,6 +215,10 @@ The `InitMethod` determines how object IDs are initialized at startup to generat

If `MeshNamingMethod` is "" or "OwnerName" then we use mesh's owner name to generate random hash as object IDs. If its "StaticMeshName" then we use static mesh's name to generate random hash as object IDs. Note that it is not possible to tell individual instances of the same static mesh apart this way, but the names are often more intuitive.

## Wind Settings

This setting specifies the wind speed in World frame, in NED direction. Values are in m/s. By default, speed is 0, i.e. no wind.

## Camera Settings
The `CameraDefaults` element at root level specifies defaults used for all cameras. These defaults can be overridden for individual camera in `Cameras` element inside `Vehicles` as described later.

Expand Down

0 comments on commit c3154e8

Please sign in to comment.