LCOV - code coverage report
Current view: top level - SITL - SIM_Parachute.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 9 13 69.2 %
Date: 2026-09-09 11:02:08 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*
       2             :    This program is free software: you can redistribute it and/or modify
       3             :    it under the terms of the GNU General Public License as published by
       4             :    the Free Software Foundation, either version 3 of the License, or
       5             :    (at your option) any later version.
       6             : 
       7             :    This program is distributed in the hope that it will be useful,
       8             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
       9             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      10             :    GNU General Public License for more details.
      11             : 
      12             :    You should have received a copy of the GNU General Public License
      13             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      14             :  */
      15             : /*
      16             :   simple parachute simulator class
      17             : */
      18             : 
      19             : #include "SIM_Parachute.h"
      20             : #include "AP_HAL/AP_HAL.h"
      21             : #include <AP_Math/AP_Math.h>
      22             : #include <GCS_MAVLink/GCS.h>
      23             : 
      24             : using namespace SITL;
      25             : 
      26             : // table of user settable parameters
      27             : const AP_Param::GroupInfo Parachute::var_info[] = {
      28             : 
      29             :     // @Param: ENABLE
      30             :     // @DisplayName: Parachute Sim enable/disable
      31             :     // @Description: Allows you to enable (1) or disable (0) the Parachute simulation
      32             :     // @Values: 0:Disabled,1:Enabled
      33             :     // @User: Advanced
      34             :     AP_GROUPINFO("ENABLE", 0, Parachute, parachute_enable, 0),
      35             : 
      36             :     // @Param: PIN
      37             :     // @DisplayName: Parachute pin
      38             :     // @Description: The pin number that the Parachute pyrotechnics are connected to. (start at 1)
      39             :     // @Range: 0 15
      40             :     // @User: Advanced
      41             :     AP_GROUPINFO("PIN", 1, Parachute, parachute_pin, -1),
      42             : 
      43             :     AP_GROUPEND
      44             : };
      45             : 
      46             : /*
      47             :   update parachute state
      48             :  */
      49     1215553 : void Parachute::update(const struct sitl_input &input)
      50             : {
      51     1215553 :     const int16_t pwm = parachute_pin >= 1 ? input.servos[parachute_pin-1] : -1;
      52     1215553 :     const uint64_t now = AP_HAL::micros64();
      53             :     // const float dt = (now - last_update_us) * 1.0e-6f;
      54     1215553 :     if (pwm >= 1250) {
      55       41173 :         if (!deployed_ms) {
      56          15 :             deployed_ms = AP_HAL::millis();
      57          15 :             GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "BANG!  Parachute deployed");
      58             :         }
      59             :     }
      60     1215553 :     last_update_us = now;
      61     1215553 : }
      62             : 
      63           0 : bool Parachute::should_report() const
      64             : {
      65           0 :     if (AP_HAL::micros64() - last_report_us < report_interval) {
      66           0 :         return false;
      67             :     }
      68             : 
      69           0 :     return false;
      70             : }

Generated by: LCOV version 1.14