Project

General

Profile

AVBP Mission plugin » History » Version 12

Rafael Bailon-Ruiz, 2021-03-11 15:23

1 1 Rafael Bailon-Ruiz
h1. AVBP Mission plugin
2 2 Rafael Bailon-Ruiz
3
The _AVBP mission plugin_ is an aircraft plugin, built upon the standard Mission Manager, to supervise adaptive mapping missions.
4
It is defined in the  <code class="python">cams_avbp.plugins.mission</code> module.
5 3 Rafael Bailon-Ruiz
6 6 Rafael Bailon-Ruiz
h2. Scenario definition
7 5 Rafael Bailon-Ruiz
8 7 Rafael Bailon-Ruiz
<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:
9 5 Rafael Bailon-Ruiz
10
<pre><code class="yaml">
11
aircrafts:
12
    200:
13
        replay: false
14
        type: 'pprz'
15
        plugins:
16
            # Other plugins ...
17
            - Missions:
18
                backup_file: '/PATH/TO/backup_200.bin'
19
                Goto: *goto_defaults
20
                Segment: *segment_defaults
21
            - AVBPMission
22
</code></pre>
23
24 3 Rafael Bailon-Ruiz
h2. User remote control
25
26 4 Rafael Bailon-Ruiz
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:
27 3 Rafael Bailon-Ruiz
28
<pre><code class="shell">
29
curl -v "http://127.0.0.1:8000/runtime/call_method/?uav_id=200&plugin=AVBPMission&method=stop"
30
</code></pre>
31
32 8 Rafael Bailon-Ruiz
calls the _stop_ method of the uav _200_ defined in the _AVBPMission_ plugin.
33
34
h2. Event handlers
35
36
h3. Aircraft status handlers
37 9 Rafael Bailon-Ruiz
38 8 Rafael Bailon-Ruiz
Status messages originated in paparazzi related to the aircraft state and mission execution status.
39
40
<pre><code class="python">
41
def flight_param_callback(self, msg):
42
    """
43
    Receive pprz FLIGHT_PARAM messages
44
45
    http://docs.paparazziuav.org/latest/paparazzi_messages.html#FLIGHT_PARAM
46
    """
47
    pass
48
49
def engine_status_callback(self, engineStatus):
50
    """
51
    Receive pprz ENGINE_STATUS messages
52
53
    http://docs.paparazziuav.org/latest/paparazzi_messages.html#ENGINE_STATUS
54
    """
55
    pass
56
57
def mission_status_callback(self, missionStatus):
58
    """
59
    Receive pprz MISSION_STATUS messages
60
61
    http://docs.paparazziuav.org/latest/paparazzi_messages.html#MISSION_STATUS
62
    """
63
    pass
64
65
def nav_status_callback(self, navStatus):
66
    """
67
    Receive pprz NAV_STATUS messages
68
69
    http://docs.paparazziuav.org/latest/paparazzi_messages.html#NAV_STATUS
70
    """
71
    pass
72
73
def ap_status_callback(self, apStatus):
74
    """
75
    Receive pprz AP_STATUS messages
76
77
    http://docs.paparazziuav.org/latest/paparazzi_messages.html#AP_STATUS
78
    """
79
    pass
80
</code></pre>
81
82
h3. Sensor sample handlers
83 9 Rafael Bailon-Ruiz
84 8 Rafael Bailon-Ruiz
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.
85
86
<pre><code class="python">
87
def add_sample(self, sample: ty.Union[AbstractSensorSample, SensorSample]):
88
    """Catch sensor samples coming from other plugins"""
89
    pass
90
</code></pre>
91
92
h3. Interaction methods
93
94
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.
95
96
<pre><code class="python">
97
def pause(self, *args, **kwargs):
98
    """Specific stop signal just for the AVBPMission plugin"""
99
    pass
100
101
def play(self, *args, **kwargs):
102
    """Specific start signal just for the AVBPMission plugin
103
104
    You can activate this method manually with:
105
    curl -v "http://127.0.0.1:8000/runtime/call_method/?uav_id=200&plugin=AVBPMission&method=play
106
107
    or browsing to http://127.0.0.1:8000/rpc (Call UAV plugin method)
108
    """
109
    pass
110
</code></pre>
111 10 Rafael Bailon-Ruiz
112
h2. Available commands
113
114
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.
115
116
h3. Create a mission
117 11 Rafael Bailon-Ruiz
118 10 Rafael Bailon-Ruiz
<pre><code class="python">
119
_logger.debug("Create a 'Goto' test mission")
120
goto_mission_params = {"wp_east": 500.0, "wp_north": 300.0, "wp_alt": 500.0}
121
mission = self.create_mission('Goto', insertMode=InsertMode.ReplaceAll,
122
                                      **goto_mission_params)
123
_logger.debug("mission %s created", mission)
124
125
_logger.debug("Create a 'Segment' test mission")
126
segment_mission_params = {"segment_east_1": 500.0, "segment_north_1": 300.0,
127
                                  "segment_east_2": 300.0, "segment_north_2": 500.0,
128
                                  "segment_alt": 500.0}
129
mission = self.create_mission('Segment', insertMode=InsertMode.Append,
130
                                      **segment_mission_params)
131
_logger.debug("mission %s created", mission)
132
</code></pre>
133
134
These missions can either be validated with the gui (operator) OR