Sphinx Wind Plugin

Good day,

We are attempting to use the Sphinx wind plugin in a .world file to simulate current wind conditions in a particular geographic region (we obtain these conditions from an external API and then construct the .world file accordingly). However, when we add the XML snippet below to our world, the results are catastrophic for the drone. It seems to get blown way off course and can’t even make it to the points we have specified in the MoveTos. Even values as low as 0.5 for <magnitude_mean> give the drone trouble. Is it just the case that this value is not m/s as the comment suggests? Is there some other parameters that we are missing/have misconfigured?


    <plugin name="wind" filename="libsphinx_wind.so">
      <!-- Wind mean speed in m/s. -->
      <magnitude_mean>7.5</magnitude_mean>
      <!-- Wind mean direction in decimal degrees. -->
      <direction_mean>220</direction_mean>
      <!-- Wind mean elevation in decimal degrees. -->
      <elevation_mean>0.0</elevation_mean>
      <!-- Lowpass filter time characteristics in seconds.
              A value of 0 seconds deactivate the filter. -->
      <magnitude_time_for_rise>0.0</magnitude_time_for_rise>
      <direction_time_for_rise>0.0</direction_time_for_rise>
      <elevation_time_for_rise>0.0</elevation_time_for_rise>
      <!-- Wind expressions where "val" is the mean value. -->
      <!-- Example: The following defines an horizontal sinusoidal wind with
             an orientation that turns 360° every 60 seconds. Note that the mean
             direction and mean elevation are unused. -->
      <magnitude_expr>val</magnitude_expr>
      <direction_expr>val</direction_expr>
      <elevation_expr>val</elevation_expr>
    </plugin>

Here is a screenshot from the Sphinx dashboard. This was with the wind parameters outlined above.

Thanks for pointing that out. The drone is currently affected by wind conditions before being ready. This should not happen. We made a fix that will be in the next sphinx release. In the meantime, you can set the magnitude_mean value to 0 and change it at runtime with pysphinx or sphinx-cli when the drone is ready:

#!/usr/bin/env python3

import pysphinx
import time

def is_drone_ready(sphinx):
    try:
        fwman = sphinx.get_component('world', 'fwman', 'fwman')
    except:
        return False
    if fwman is None:
        return False
    ready = fwman.get_param('all_drones_ready')
    if ready is None:
        return False
    return ready == 'true'

sphinx = pysphinx.Sphinx()

# wait until drone is ready
timeout = 30  # seconds
retry = 0
while not is_drone_ready(sphinx):
    if retry == timeout:
        raise RuntimeError('Timeout reached')
    retry += 1
    print(f'Waiting until drone is ready {retry}/{timeout} ...')
    time.sleep(1)

wind = sphinx.get_component('world', 'wind', 'wind')
wind.set_param('magnitude_mean', '7.5')

Thanks for the quick reply @ocrave. I don’t seem to be able to use your script as python cannot find the pysphinx module. I am running Sphinx 1.8 in this environment. I tried to use the curl method outlined in the accompanying documentation (via sphinx --doc) but it complains about the parameters even though I took the example straight from the documentation. Am I missing something simple or is this an invalid way to set the wind conditions in 1.8?

$ echo '{"jsonrpc": "2.0", "method": "SetParameter", "params": {"machine":"world", "object":"wind/wind", "parameter":"magnitude_mean", "value":"5.0"}, "id": 1}' | curl -d @- http://localhost:8383 | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   292  100   141  100   151   137k   147k --:--:-- --:--:-- --:--:--  285k
{
    "error": {
        "code": -32602,
        "message": "INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised"
    },
    "id": 1,
    "jsonrpc": "2.0"
}

You can try this:

echo '{"jsonrpc": "2.0", "method": "SetParam", "params": {"machine":"world", "object":"wind/wind", "parameter":"magnitude_mean", "value":"5.0"}, "id": 1}' | curl -d @- http://127.0.0.1:8383 | python -m json.tool

Ahh SetParam instead of SetParameter. The API call to set the wind now works. However, 7.5 m/s is still like a hurricane. I have tried making the API call after the drone is instantiated, but before take off and also after the drone has taken off and started its route (as dictated by the Olympe script I launched). I created a GIF that shows as soon as I set the wind to 7.5, it starts going vastly off course. It is unable to recover once the wind is set and will continue to be pushed in the direction of the wind forever. I verified that the magnitude_mean is 0.0 in the .world file.
wind_issue

This topic was automatically closed after 30 days. New replies are no longer allowed.