Infinite battery in Simulation

I’d like for my simulated drone to have infinite battery. Is that possible?

My use case requires the simulated drone to always be flying, but the simulated drone lands after running out of battery. I imagined there would be an option to set battery to always remain at 100% in the anafi.drone file, but there isn’t.

Am I missing something or is this not possible?

You can set the discharge_speed_factor parameter to 0 via the dashboard or using this command line:

echo '{"jsonrpc": "2.0", "method": "SetParam", "params": {"machine":"anafi4k", "object":"lipobattery/lipobattery", "parameter":"discharge_speed_factor", "value":"0"}, "id": 1}' | curl -d @- http://localhost:8383 | python -m json.tool
1 Like

This works, but tripped me up for a long, long time because I thought the web dashboard receives the POST messages.
So I modified your command to the port my dashboard was running at (9002)
It took me a loooong time to understand that there is a separate server running at 8383 and that it receives these POST messages.

Where is this configuration specified? What is that server called?

The main Gazebo plugin is a World plugin called fwman. Its configuration should be in every .world files. This is what it looks like in empty.world:

<plugin name="fwman" filename="libsphinx_fwman.so">
  <spawn_point name="default">
    <pose>0 0 0.2 0 0 0</pose>
  </spawn_point>
</plugin>

By default, it runs a JSON-RPC server that can be queried on the port 8383. The server type and port number can be modified but we recommend to keep default values:

<plugin name="fwman" filename="libsphinx_fwman.so">
  ...
  <param_server>
    <type>http</type> <!-- or unix for unix socket -->
    <info>8383</info> <!-- or /path/to/sock for unix socket -->
  </param_server>
</plugin>

Check the documentation to see how to communicate with this server via command-line: https://developer.parrot.com/docs/sphinx/pluginctrl_ifaces.html?highlight=json#command-line

The Web dashboard runs on port 9002 and communicates with fwman via websockets. Its port can be modified with the --http-port option of sphinx.

At the end, both the JSON-RPC server and the Web dashboard communicate with Gazebo plugins.

1 Like

Got it. Thanks a lot!

Just for curiosity reasons, is there any reason Sphinx starts a separate server for JSON-RPC? I imagine it could have been possible to run it on the web dashboard port too right?

Or are the technologies/server frameworks completely different?

Yes, Sphinx does not use the same library to listen to http requests for the dashboard. In that case, the server is only used to serve static files and does not support Unix domain sockets.

1 Like