AVBP Mission plugin » History » Revision 12
Revision 11 (Rafael Bailon-Ruiz, 2021-03-11 15:06) → Revision 12/13 (Rafael Bailon-Ruiz, 2021-03-11 15:23)
h1. AVBP Mission plugin
The _AVBP mission plugin_ is an aircraft plugin, built upon the standard Mission Manager, to supervise adaptive mapping missions.
It is defined in the <code class="python">cams_avbp.plugins.mission</code> module.
h2. Scenario definition
<code class="python">AVBPMission</code> must de declared in the plugins section. The <code class="python">Missions</code> plugin is required and must be included first in the list. Example:
<pre><code class="yaml">
aircrafts:
200:
replay: false
type: 'pprz'
plugins:
# Other plugins ...
- Missions:
backup_file: '/PATH/TO/backup_200.bin'
Goto: *goto_defaults
Segment: *segment_defaults
- AVBPMission
</code></pre>
h2. User remote control
You can make remote procedure calls using the http API, that you can issue with a web browser or from the command line with <code class="shell">curl</code>. For instance:
<pre><code class="shell">
curl -v "http://127.0.0.1:8000/runtime/call_method/?uav_id=200&plugin=AVBPMission&method=stop"
</code></pre>
calls the _stop_ method of the uav _200_ defined in the _AVBPMission_ plugin.
h2. Event handlers
h3. Aircraft status handlers
Status messages originated in paparazzi related to the aircraft state and mission execution status.
<pre><code class="python">
def flight_param_callback(self, msg):
"""
Receive pprz FLIGHT_PARAM messages
http://docs.paparazziuav.org/latest/paparazzi_messages.html#FLIGHT_PARAM
"""
pass
def engine_status_callback(self, engineStatus):
"""
Receive pprz ENGINE_STATUS messages
http://docs.paparazziuav.org/latest/paparazzi_messages.html#ENGINE_STATUS
"""
pass
def mission_status_callback(self, missionStatus):
"""
Receive pprz MISSION_STATUS messages
http://docs.paparazziuav.org/latest/paparazzi_messages.html#MISSION_STATUS
"""
pass
def nav_status_callback(self, navStatus):
"""
Receive pprz NAV_STATUS messages
http://docs.paparazziuav.org/latest/paparazzi_messages.html#NAV_STATUS
"""
pass
def ap_status_callback(self, apStatus):
"""
Receive pprz AP_STATUS messages
http://docs.paparazziuav.org/latest/paparazzi_messages.html#AP_STATUS
"""
pass
</code></pre>
h3. Sensor sample handlers
Handler for the internal CAMS event "add_sample". It is called each time a sensor sample is disseminated from another plugin of the same UAV.
<pre><code class="python">
def add_sample(self, sample: ty.Union[AbstractSensorSample, SensorSample]):
"""Catch sensor samples coming from other plugins"""
pass
</code></pre>
h3. Interaction methods
These functions are not called periodically by CAMS, but manually by the operators to trigger certain actions. More can be defined provided by <code class="python">__pluginmethods__</code> is update accordingly.
<pre><code class="python">
def stop(self):
"""Disable the AVBPProbe plugin"""
pass
def pause(self, *args, **kwargs):
"""Specific stop signal just for the AVBPMission plugin"""
pass
def play(self, *args, **kwargs):
"""Specific start signal just for the AVBPMission plugin
You can activate this method manually with:
curl -v "http://127.0.0.1:8000/runtime/call_method/?uav_id=200&plugin=AVBPMission&method=play
or browsing to http://127.0.0.1:8000/rpc (Call UAV plugin method)
"""
pass
</code></pre>
h2. Available commands
The <code class="python">self</code> argument of every plugin method (declared in <code class="python">__pluginmethods__</code>) is the AircraftPprz from nephelae_paparazzi the plugin is attached to.
h3. Create a mission
<pre><code class="python">
_logger.debug("Create a 'Goto' test mission")
goto_mission_params = {"wp_east": 500.0, "wp_north": 300.0, "wp_alt": 500.0}
mission = self.create_mission('Goto', insertMode=InsertMode.ReplaceAll,
**goto_mission_params)
_logger.debug("mission %s created", mission)
_logger.debug("Create a 'Segment' test mission")
segment_mission_params = {"segment_east_1": 500.0, "segment_north_1": 300.0,
"segment_east_2": 300.0, "segment_north_2": 500.0,
"segment_alt": 500.0}
mission = self.create_mission('Segment', insertMode=InsertMode.Append,
**segment_mission_params)
_logger.debug("mission %s created", mission)
</code></pre>
These missions can either be validated with the gui (operator) OR