Skip to content

Commit

Permalink
Move Wiki pages to docs (#2803)
Browse files Browse the repository at this point in the history
* [docs] Move drone survey wiki page

* [docs] Move Orbit Wiki page

* [docs] Move Point Clouds Wiki page
  • Loading branch information
rajat2004 authored Jul 21, 2020
1 parent f5691f9 commit 745edc2
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 10 deletions.
50 changes: 50 additions & 0 deletions docs/drone_survey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Implementing a Drone Survey script

Moved here from [https://github.com/microsoft/AirSim/wiki/Implementing-a-Drone-Survey-script](https://github.com/microsoft/AirSim/wiki/Implementing-a-Drone-Survey-script)

Ever wanted to capture a bunch of top-down pictures of a certain location? Well, the Python API makes this really simple. See the [code available here](https://github.com/microsoft/AirSim/blob/master/PythonClient/multirotor/survey.py).

![survey](images/survey.png)

Let's assume we want the following variables:

| Variable | Description |
| ------------- | ------------- |
| boxsize | The overall size of the square box to survey |
| stripewidth | How far apart to drive the swim lanes, this can depend on the type of camera lens, for example. |
| altitude | The height to fly the survey. |
| speed | The speed of the survey can depend on how fast your camera can snap shots. |

So with these we can compute a square path box using this code:

```python
path = []
distance = 0
while x < self.boxsize:
distance += self.boxsize
path.append(Vector3r(x, self.boxsize, z))
x += self.stripewidth
distance += self.stripewidth
path.append(Vector3r(x, self.boxsize, z))
distance += self.boxsize
path.append(Vector3r(x, -self.boxsize, z))
x += self.stripewidth
distance += self.stripewidth
path.append(Vector3r(x, -self.boxsize, z))
distance += self.boxsize
```
Assuming we start in the corner of the box, increment x by the stripe width, then fly the full y-dimension of `-boxsize` to `+boxsize`, so in this case, `boxsize` is half the size of the actual box we will be covering.

Once we have this list of Vector3r objects, we can fly this path very simply with the following call:
```python
result = self.client.moveOnPath(path, self.velocity, trip_time, DrivetrainType.ForwardOnly,
YawMode(False,0), lookahead, 1)
```

We can compute an appropriate `trip_time` timeout by dividing the distance of the path and the speed we are flying.

The `lookahead` needed here for smooth path interpolation can be computed from the velocity using `self.velocity + (self.velocity/2)`. The more lookahead, the smoother the turns. This is why you see in the screenshot that the ends of each swimland are smooth turns rather than a square box pattern. This can result in a smoother video from your camera also.

That's it, pretty simple, eh?

Now of course you can add a lot more intelligence to this, make it avoid known obstacles on your map, make it climb up and down a hillside so you can survey a slope, etc. Lots of fun to be had.
Binary file added docs/images/depth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/orbit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/point_cloud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/survey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions docs/orbit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# An Orbit Trajectory

Moved here from [https://github.com/microsoft/AirSim/wiki/An-Orbit-Trajectory](https://github.com/microsoft/AirSim/wiki/An-Orbit-Trajectory)

Have you ever wanted to fly a nice smooth circular orbit? This can be handy for capturing 3D objects from all sides especially if you get multiple orbits at different altitudes.

So the `PythonClient/multirotor` folder contains a script named [Orbit](https://github.com/microsoft/AirSim/blob/master/PythonClient/multirotor/orbit.py) that will do precisely that.

See [demo video](https://youtu.be/RFG5CTQi3Us)

The demo video was created by running this command line:

```shell
python orbit.py --radius 10 --altitude 5 --speed 1 --center "0,1" --iterations 1
```

This flies a 10 meter radius orbit around the center location at (startpos + radius * [0,1]), in other words, the center is located `radius` meters away in the direction of the provided center vector. It also keeps the front-facing camera on the drone always pointing at the center of the circle. If you watch the flight using LogViewer you will see a nice circular pattern get traced out on the GPS map:

![image](images/orbit.png)

The core of the algorithm is not that complicated. At each point on the circle, we look ahead by a small delta in degrees, called the `lookahead_angle`, where that angle is computed based on our desired velocity. We then find that lookahead point on the circle using sin/cosine and make that our "target point". Calculating the velocity then is easy, just subtract our current position from that point and feed that into the AirSim method `moveByVelocityZ`.
17 changes: 17 additions & 0 deletions docs/point_clouds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Point Clouds

Moved here from [https://github.com/microsoft/AirSim/wiki/Point-Clouds](https://github.com/microsoft/AirSim/wiki/Point-Clouds)

A Python script [point_cloud.py](https://github.com/Microsoft/AirSim/blob/master/PythonClient/multirotor/point_cloud.py) shows how to convert the depth image returned from AirSim into a point cloud.

The following depth image was captured using the Modular Neighborhood environment:

![depth](images/depth.png)

And with the appropriate projection matrix, the OpenCV `reprojectImageTo3D` function can turn this into a point cloud. The following is the result, which is also available here: [https://skfb.ly/68r7y](https://skfb.ly/68r7y).

![depth](images/point_cloud.png)

[SketchFab](https://sketchfab.com) can upload the resulting file `cloud.asc` and render it for you.

PS: you may notice the scene is reflected on the Y axis, so I may have a sign wrong in the projection matrix. An exercise for the reader :-)
21 changes: 11 additions & 10 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ markdown_extensions:

remote_branch: gh-pages

theme:
theme:
name: 'readthedocs'
logo:
icon: ' '
Expand All @@ -22,14 +22,14 @@ extra:
palette:
social:
- type: facebook
link: https://www.facebook.com/groups/1225832467530667/
link: https://www.facebook.com/groups/1225832467530667/
- type: github-alt
link: https://github.com/Microsoft/AirSim

copyright: Copyright &copy; 2018 Microsoft Research

nav:
- "Home":
- "Home":
- "Home": 'README.md'
- "Changelog": 'CHANGELOG.md'
- "Get AirSim":
Expand All @@ -48,7 +48,7 @@ nav:
- "C++ APIs": 'apis_cpp.md'
- "Development Workflow": 'dev_workflow.md'
- "Settings": 'settings.md'
- "Camera Views": 'camera_views.md'
- "Camera Views": 'camera_views.md'
- "Car Mode": 'using_car.md'
- "Remote Control": 'remote_control.md'
- "XBox Controller": 'xbox_controller.md'
Expand All @@ -57,8 +57,8 @@ nav:
- "Sensors": 'sensors.md'
- "LIDAR": 'lidar.md'
- "Infrared Camera": "InfraredCamera.md"
- "ROS: AirSim ROS Wrapper": "airsim_ros_pkgs.md"
- "ROS: AirSim Tutorial Packages": "airsim_tutorial_pkgs.md"
- "ROS: AirSim ROS Wrapper": "airsim_ros_pkgs.md"
- "ROS: AirSim Tutorial Packages": "airsim_tutorial_pkgs.md"
- "Domain Randomization": "retexturing.md"
- "Mesh Vertex Buffers": "meshes.md"
- "Playing Logs": 'playback.md'
Expand Down Expand Up @@ -93,8 +93,9 @@ nav:
- "Autonomous Driving on Azure": 'https://aka.ms/AutonomousDrivingCookbook'
- "Building Hexacopter": 'https://github.com/Microsoft/AirSim/wiki/hexacopter'
- "Moving on Path Demo": 'https://github.com/Microsoft/AirSim/wiki/moveOnPath-demo'
- "Building Point Clouds": 'https://github.com/Microsoft/AirSim/wiki/Point-Clouds'
- "Surveying Using Drone": 'https://github.com/Microsoft/AirSim/wiki/Implementing-a-Drone-Survey-script'
- "Building Point Clouds": 'point_clouds.md'
- "Surveying Using Drone": 'drone_survey.md'
- "Orbit Trajectory": "orbit.md"
- "Misc":
- "AirSim on Real Drones": 'custom_drone.md'
- "Installing cmake on Linux": 'cmake_linux.md'
Expand All @@ -105,8 +106,8 @@ nav:
- "Who is Using AirSim": 'who_is_using.md'
- "Working with UE Plugin Contents": 'working_with_plugin_contents.md'
- "Formula Student Technion Self-drive": 'https://github.com/Microsoft/AirSim/wiki/technion'
- "Support":
- "Support":
- "FAQ": 'faq.md'
- "Support": 'SUPPORT.md'
- "Create Issue": 'create_issue.md'
- "Contribute": 'CONTRIBUTING.md'
- "Contribute": 'CONTRIBUTING.md'

0 comments on commit 745edc2

Please sign in to comment.