LCOV - code coverage report
Current view: top level - SITL - SIM_Rover.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 3 3 100.0 %
Date: 2026-09-09 11:02:08 Functions: 2 2 100.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             :   rover simulator class
      17             : */
      18             : 
      19             : #pragma once
      20             : 
      21             : #include "SIM_Aircraft.h"
      22             : 
      23             : namespace SITL {
      24             : 
      25             : /*
      26             :   a rover simulator
      27             :  */
      28             : class SimRover : public Aircraft {
      29             : public:
      30             :     SimRover(const char *frame_str);
      31             : 
      32             :     /* update model by one time step */
      33             :     void update(const struct sitl_input &input) override;
      34             : 
      35             :     /* static object creator */
      36         245 :     static Aircraft *create(const char *frame_str) {
      37         245 :         return NEW_NOTHROW SimRover(frame_str);
      38             :     }
      39             : 
      40             : private:
      41             :     static constexpr float MAX_YAW_RATE = 360.0;  // MAX 360 deg/s yaw rate speed to not nuke the ekf gsf
      42             :     float max_speed = 20.0f;            // vehicle's maximum forward speed in m/s
      43             :     float max_accel = 10.0f;            // vehicle's maximum forward acceleration in m/s/s
      44             :     float max_wheel_turn = 35.0f;       // ackermann steering vehicle's maximum steering angle
      45             :     float turning_circle = 1.8f;        // ackermann steering vehicle's minimum turn diameter in meters
      46             :     float skid_turn_rate = 140.0f;      // skid-steering vehicle's maximum turn rate in deg/sec
      47             :     bool skid_steering;                 // true if this vehicle is a skid-steering vehicle
      48             : 
      49             :     // vectored thrust related members
      50             :     bool vectored_thrust;                   // true if vehicle uses vectored thrust (i.e. steering controls direction of thrust)
      51             :     float vectored_angle_max = 90.0f;       // maximum angle (in degrees) to which thrust can be turned
      52             :     float vectored_turn_rate_max = 90.0f;   // maximum turn rate (in deg/sec) with full throttle angled at 90deg
      53             : 
      54             :     // omni3 Mecanum related members
      55             :     bool omni3;                             // true if vehicle is omni-directional with 3 Mecanum wheels
      56             :     float omni3_max_speed = 2.3625f;        // omni vehicle's maximum forward speed in m/s
      57             :     float omni3_max_accel = 1.0f;           // omni vehicle's maximum forward acceleration in m/s/s
      58             :     float omni3_wheel_max_ang_vel = 50.0f;  // omni vehicle's wheel maximum angular velocity in rad/s
      59             : 
      60             :     void update_ackermann_or_skid(const struct sitl_input &input, float delta_time);
      61             :     void update_omni3(const struct sitl_input &input, float delta_time);
      62             : 
      63             :     float turn_circle(float steering) const;
      64             :     float calc_yaw_rate(float steering, float speed);
      65             :     float calc_lat_accel(float steering_angle, float speed);
      66             : 
      67             :     void update_battery() override;
      68    13407122 :     bool battery_is_empty() { return battery_voltage < 0.5f; };
      69             : };
      70             : 
      71             : } // namespace SITL

Generated by: LCOV version 1.14