Tuning of drone internals at runtime - interfaces

An important feature of sphinx is the control of the behaviour of simulated drone’s hardware/physical components. What we call here “components” is typically the drone sensors, the propulsion group(s), or the aerodynamic model. For example, if you need to test your application with a drone that has no GPS signal, you just need to deactivate the GPS component for the desired duration.

Two interfaces are available to control the components:

  • Web interface: the most convenient in case of manual tests
  • Command line: more appropriate to automatize sequences

The current page describes in details these interfaces. If you want more practical information about how to fill in the tuning parameters, please refer to the page Tuning of drone internals at runtime - Howtos.

Web interface

The web interface is accessible through the port 9002. So if your web browser and Sphinx are running on the same machine, just enter the following address:

http://localhost:9002

Once the page is loaded, drag and drop the inspector widget as shown in the video below. A window listing the components that can be controlled should appear. At start, all entries are hidden since the tree is folded. You just need to unfold the part that you want to change.

Two types of controls are available:

  • action: just push on the button to execute the related action
  • parameter: click on the field to edit the text and enter a new value or click on the button to edit the parameter in a new window

Command line

The communication relies on JSON-RPC (version 2.0), which runs on top of:

  • either HTTP protocol,
  • or Named Unix Domain Socket

By default, the Parameter Server is going to listen on port 8383 (decimal) through an HTTP server.

If the default settings are not suited, it is up to you to choose the link that is going to be used. Just edit the .world file as follows:

<world>
...
<plugin name="fwman" filename="libsphinx_fwman.so">
  <param_server>
    <!-- type of connection: 'http' or 'unix' -->
    <type>unix</type>
    <!-- path to the socket for 'unix', or HTTP port number (in decimal) -->
    <info>/tmp/myserverparam.sock</info>
  </param_server>
...
</plugin>
...
</world>

Available methods

GetAllParameters

Method name: GetAllParameters Parameters: None Action: returns an JSON object containing all available parameters for the complete running scene.

The returned object is built as follows:

{
    <machine> : { objectid/type : [param1, param2, ...] }
}

SetParam

Method name: SetParam

Parameters:

  • machine: name of the drone or module as it appears in the drone section of your .drone file
  • object: combination of “objectid/type” of the component we want to refer to. Example: mpu6050/imu
  • parameter: name of the parameter we want to set.
  • value: new value of the parameter

Action: changes the value of one given parameter.

TriggerAction

Method name: TriggerAction

Parameters:

  • machine: name of the drone or module as it appears in the drone section of your .drone file
  • object: combination of “objectid/type” of the component we want to refer to. Example: mpu6050/imu
  • action: name of the action we want to trigger.

Action: sends a request to trigger an action.

Testing with command line

In case you use the default configuration (HTTP on port 8383), control the drone components with command lines thanks to cURL. Make sure that the field “machine” is set with the name given in the drone section of your .drone file.

$ echo '{"jsonrpc": "2.0", "method": "GetAllParameters", "params": {}, "id": 1}' \
   | curl -d @- http://localhost:8383 | python -m json.tool
$ echo '{"jsonrpc": "2.0", "method": "SetParam", \
  "params": {"machine":"bebop2", "object":"gps/gps", "parameter":"updatePeriod", "value":"5.0"}, "id": 1}'\
  | curl -d @- http://localhost:8383 | python -m json.tool
$ echo '{"jsonrpc": "2.0", "method": "TriggerAction",\
  "params": {"machine":"disco", "object":"fixedwings_shake/handling", "action":"start"}, "id": 1}' \
  | curl -d @- http://localhost:8383 | python -m json.tool

If the fwman plugin in your .world file is configured to use a Unix Socket connection type, replace curl -d @- http://localhost:8383 by nc -U <path/to/unix/socket>.