Areas#
Areas are 3D volumes that do not physically exist in the world but can be used to modify the simulation conditions or to query whether the drone is inside a particular area of the world.
Areas of the same type can be grouped together by assigning them the same tag. For example, multiple indoor areas can be assigned the same “indoor” tag to easily determine if the drone is inside or outside an indoor environment.
Some worlds already contain predefined areas. The list of available areas can be
displayed with the -list-areas
command:
$ parrot-ue4-carla -level=town_10 -list-areas
== Available Areas ===========================================
- Name: indoor
Tags:
- indoor
Pose: 54.299999 20.799999 12.200000 0.000000 -0.000000 0.000000
Geometry:
Box:
Size: 17.500000 40.500000 22.500000
- Name: PoveArea
Pose: 9.200000 -32.200001 11.200000 0.000000 -0.000000 0.000000
Geometry:
Box:
Size: 248.437531 270.502625 52.180180
==============================================================
Areas are hidden by default. To visualize them, set the show_areas
parameter
on the fwman
world component to true
:
$ sphinx-cli param -m world fwman show_areas true
Add custom areas#
Custom areas can be loaded from the configuration file passed to the application
using the command line option -config-file
as show in the following example:
$ parrot-ue4-carla -level=town_10 -list-areas -config-file=./config.yaml
== Available Areas ===========================================
- Name: indoor
Tags:
- indoor
Pose: 54.299999 20.799999 12.200000 0.000000 -0.000000 0.000000
Geometry:
Box:
Size: 17.500000 40.500000 22.500000
- Name: PoveArea
Pose: 9.200000 -32.200001 11.200000 0.000000 -0.000000 0.000000
Geometry:
Box:
Size: 248.437531 270.502625 52.180180
- Name: TestArea
Tags:
- TestTag1
- TestTag2
Pose: 1.000000 2.000000 0.000000 0.000000 -0.000000 0.000000
Geometry:
Box:
Size: 1.000000 2.000000 3.000000
==============================================================
Where the config.yaml
file contains the following area configuration:
Areas:
- Name: 'TestArea'
Pose: 1 2 0 0 0 0
Tags:
- 'TestTag1'
- 'TestTag2'
Geometry:
Box:
Size: 1 2 3
Custom areas only support the “Box” geometry. The “Size” element represents the three side lengths of the box expressed in meters and the “Pose” element is expressed in Gazebo coordinate system (see HERE for more details).
Use area functions to alter expressions#
ExprTk expressions can be modified to take into account whether the drone is located inside or outside an area. See area functions for more details.
For example, the following command will nullify the wind speed when the drone is located inside an “indoor” area, and set the wind speed to 5 m/s otherwise.
$ sphinx-cli param -m anafi wind/wind magnitude_expr "5 * outside_area('indoor')"
Another use case is for the GPS component to, for example, reduce the number of available satellites for indoor environments:
$ sphinx-cli param -m anafi gps/gps num_sv_expr "2 + 10 * outside_area('indoor')"
Query the list of areas#
The pysphinx Python library can be used to query the list of all areas in the world, or the list of areas within the drone’s current coordinates:
import pysphinx
sphinx = pysphinx.Sphinx()
areas = sphinx.get_surrounding_areas(machine_name="anafi_ai")
print(areas)