Weather and Environment Controls

AirGen offers comprehensive control over environmental conditions, including weather effects, wind, and time of day. These parameters allow users to customize visual effects as well as the physical impact on aerial vehicles in simulation.

Note

By default, all weather effects are disabled. To enable weather effects, you must first call simEnableWeather(True).

Weather Parameters

Weather parameters are accessible through simSetWeatherParameter(), which enables users to set various weather effects. These effects impact only visuals and do not alter drone dynamics. Available weather parameters are:

  • Rain

  • Snow

  • Fog

  • Dust

To set a weather parameter, specify the effect using airgen.WeatherParameter and provide a scalar value between 0 and 1, where 1.0 is the maximum effect.

Example: Setting Weather Effects

import airgen
client.simSetWeatherParameter(airgen.WeatherParameter.Rain, 1.0)  # Maximum rain
client.simSetWeatherParameter(airgen.WeatherParameter.Fog, 1.0)   # Maximum fog

Wind API

The simSetWind() function modifies wind parameters in the simulation and directly impacts both visuals and the drone's dynamics. The wind is defined using a Vector3r vector, where each component specifies wind speed in meters per second along the North-East-Down (NED) coordinate frame.

Example: Setting Wind Conditions

import airgen, time
# Apply a wind of 5 m/s along the North axis (X direction) for 10 seconds
client.simSetWind(airgen.Vector3r(5, 0, 0))
time.sleep(10)
# Reset wind to zero
client.simSetWind(airgen.Vector3r(0, 0, 0))

Note

Aerial Vehicles Only: The wind effect currently influences only aerial vehicles; ground robots are unaffected by simSetWind() settings.

Time of Day

To dynamically adjust the time of day within the simulation, use simSetTimeofDay(). This function adjusts sun and moon positions, ambient lighting, and overall sky conditions. Specify the desired date and time in the "YYYY-MM-DD HH:MM:SS" format.

Example: Setting Simulation Date and Time

# Set a specific date and time (e.g., midday)
client.simSetTimeofDay(True, "2024-07-22 12:00:00")
# Set nighttime
client.simSetTimeofDay(True, "2024-07-22 00:00:00")