Commit Graph
58 Commits
Author SHA1 Message Date
Andrew Tridgell fe8c06f869 SITL: expose multicopter frame model as SIM_FRM_ parameters
allows the scalar model values (mass, disc area, momentum drag etc) to
be customised as parameters for copters and quadplanes. A json model
file sets the defaults for the parameters

The SIM_FRM_BBDRAG and SIM_FRM_MDRAG drag coefficients default to
zero on planes so the plane model alone handles drag and the
auto-tests don't need retuning. Setting them on a quadplane gives
more realistic airbraking in VTOL modes
2026-08-06 16:40:54 +10:00
Peter BarkerandClaude Opus 4.8 c9374d661a SITL: add SIM_BATT_RES_OHM to control simulated battery sag
Commit d2fc8cac ("SITL: Improve SIM::Battery energy consumption") made
unlimited-capacity batteries (the SITL default) sag under load where they
previously had none. As the simulated voltage scales motor thrust linearly,
there was no longer any way to run a sim vehicle without that thrust penalty.

Add a SIM_BATT_RES_OHM parameter that overrides the vehicle model's internal
resistance: negative keeps the model value (unchanged default behaviour), 0
disables sag entirely, and a positive value sets an explicit resistance. It is
applied live via Battery::maybe_reset(), so it can be changed without a reboot.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 09:37:48 +10:00
Hunter McClelland 1beebe0f72 SITL: Multicopter overrides parent's update_battery() 2026-06-26 10:19:08 +10:00
Hunter McClelland e5cdc790c8 SITL: Aircraft & its children explicitly manage battery temperature 2026-06-20 12:39:14 +10:00
Hunter McClelland 5a0c7c491c SITL: SIM::Battery uses ambient temperature provided at setup 2026-05-23 09:22:40 +10:00
Hunter McClelland 79c76e53ba SITL: Rename SIM::Battery's set_current() to consume_energy() 2026-04-20 11:30:41 +10:00
Hunter McClelland 9569e631ce SITL: Disentangle Frame, Battery, and Aircraft (+children)
This PR clarifies the intended SIM_BATT_* param behavior

Step 1: Split Frame's battery management into smaller parts
Step 2: Move battery managagement out of Frame to Aircraft-children which have a Frame
Step 3: Move SITL::Plane's battery consumption up one level in the 'function stack'
Step 4: SIM::Battery manages its own initial voltage
Step 5: Make Aircraft responsible for managing battery resets
Step 6: Frame now does not use/have a SIM::Battery
  (It uses the batt owned by Aircraft-children which have a Frame.)
Step 7: Put battery maybe-reset logic into SITL::Battery
2026-04-17 20:52:33 +10:00
Hunter McClelland f9deeb6d6d SITL: User of SITL::Battery supplies wall-clock timestamp 2026-04-12 01:21:21 +01:00
Thomas Watson 733ddb2b81 SITL: construct multicopter frame dynamically to save RAM
Only one ever exists so there's little reason to construct all
possibilities ahead of time and store them in global RAM. Instead, keep
a list of the parameters and only construct the one requested. Saves
some 60K of RAM on hardware when using sim on hardware.

In particular, enough is saved to get esp32empty copter building again.
But esp32 sim on hardware still does not work due to other regressions.
2025-12-29 17:33:14 +11:00
rishabsingh3003 99f4f13369 SITL: Add simulator for tethered vehicle 2024-12-10 10:48:00 +11:00
Randy Mackay a1579bc31e SITL: integrate SlungPayload 2024-07-24 17:09:06 +10:00
Peter Barker 5994664bf9 SITL: add simulated tie-down clamp 2024-06-11 09:56:43 +10:00
Andrew Tridgell a0af08a3aa SITL switched to motor_mask for which actuators are motors
this allows for any output to be an ESC, which allows for proper
simulation of quadplanes with ESCs on outputs 5-8 or 9-12, for testing
notch filtering
2022-10-16 20:38:19 +11:00
Andrew Tridgell bf1f27af32 SITL: added is_lock_step_scheduled() API
used to fix panic on bad timing
2021-05-24 20:13:37 +10:00
Andrew Tridgell e07cecb264 SITL: added support for simulated battery discharge 2020-10-28 14:20:44 +11:00
Andrew Tridgell 767773da5e SITL: improved multicopter simulation
this takes account of motor expo, velocity of air over propellers,
mass, size and other factors

It also allows for frame parameters to be supplied as an external json file
2020-10-28 14:20:44 +11:00
Peter Barker abab203b32 SITL: remove zero initialisations, move more into class definitions 2020-09-28 12:15:04 +10:00
Andy Piper c807267bab SITL: add rpm-based motor noise per-motor to gyros and accels
convert multicopter thrust to rpm per motor
2019-12-17 10:07:06 +11:00
Peter Barker f7b47679bb SITL: remove home_str from constructor 2019-08-15 15:16:11 +10:00
Peter Barker 6939a9fa91 SITL: add capability to twist the aircraft
This makes the EKF very, very unhappy, but is useful for compass
calibration testing
2019-04-23 10:06:17 +10:00
Peter Barker 4db011f530 SITL: add SIM_SHOVE_* options to shove the simulated vehicle
The parameter values are time in milliseconds and body-frame
acceleration in m/s/s

So to test throw mode:
 mode throw
 param set SIM_SHOVE_Z -30
 arm throttle
 param set SIM_SHOVE_TIME 500
2019-03-12 11:09:37 +11:00
Andrew Tridgell 358c570d9d SITL: added simulated battery for quadplane
needed for motor interference for mag
2019-01-14 08:23:47 +11:00
Pierre Kancir 37f7cc4bcf SITL: rearrange Grippers and Sprayers in SITL 2018-07-31 23:34:43 +10:00
Pierre Kancir b176ba53d7 SIM_Aircraft: move advance in time from update_position to time_advance 2017-06-07 20:29:02 +10:00
Peter Barker b751f836bb SITL: attach a string with a mass on the end to servo gripper 2016-12-02 12:04:05 +11:00
Peter Barker d9cbcd9487 SITL: a simulator for the EPM grabber 2016-11-05 10:20:43 +09:00
Peter Barker d439bbe5bf SITL: SIM_Gripper_Servo, a simulated servo gripper 2016-11-05 10:20:29 +09:00
murata c808ee2f49 Global: To nullptr from NULL.
RC_Channel: To nullptr from NULL.

AC_Fence: To nullptr from NULL.

AC_Avoidance: To nullptr from NULL.

AC_PrecLand: To nullptr from NULL.

DataFlash: To nullptr from NULL.

SITL: To nullptr from NULL.

GCS_MAVLink: To nullptr from NULL.

DataFlash: To nullptr from NULL.

AP_Compass: To nullptr from NULL.

Global: To nullptr from NULL.

Global: To nullptr from NULL.
2016-11-02 16:04:47 -02:00
Peter Barker 1997a4e044 SITL: include mass of sprayer payload in vehicle mass 2016-10-29 15:02:56 +09:00
Peter Barker a7867603a0 SITL: SIM_Sprayer: a simulated sprayer 2016-10-29 15:02:48 +09:00
Mathieu OTHACEHE 152edf7189 Global: remove mode line from headers
Using a global .dir-locals.el file is a better alternative than
reincluding the same emacs header in every file of the project.
2016-10-24 09:42:01 -02:00
Andrew Tridgell 4faa57074a SITL: removed vehicle specific ground handling 2016-07-19 14:47:47 +10:00
Andrew Tridgell e7a54c83d1 SITL: allow SITL to use terrain data for ground height 2016-07-19 14:42:31 +10:00
Paul Riseborough 078284e2e2 SITL: Add magnetic field environment to simulation
Includes parameters enabling a ground level magnetic anomaly to be modelled.
TODO - add automatic setting of declination, inclination and field strength using WGS-84 position.
2016-06-19 12:51:34 +10:00
Gustavo Jose de Sousa 45754ef37c SITL: Multicopter: remove leftover comment
That went unnoticed by 8a98ce4 ("SITL: moved to common code for attitude/pos
update")
2016-05-10 16:16:37 +10:00
Andrew Tridgell 9e01d7de6c SITL: added support for "quad-fast" frame
much more powerful copter for testing nav at high speed
2016-04-28 10:05:04 +10:00
Andrew Tridgell c262d6a1b4 SITL: break up multicopter into Motor/Frame/Multicopter classes
ready for more tiltrotors
2016-04-21 19:56:44 +10:00
Andrew Tridgell 57aef8e1e9 SITL: added basic wind support in multicopter, plane and quadplane
this adds non-turbulent wind support for the built-in simulators. I
added it primarily for quadplane testing, but it should also be useful
for multicopter navigation testing.
2016-04-20 11:48:37 +10:00
Andrew Tridgell 7dcd17a2fa SITL: make multicopter motors only effective above 10% 2016-04-02 22:45:05 +11:00
Andrew Tridgell d820eeaec6 SITL: use AP_Motors conventions for multicopters
this makes it easier to add a simulated vehicle to match a
MotorsMatrix frame type
2016-02-08 10:58:56 +11:00
Andrew Tridgell 5efe98a814 SITL: allow quadplane simulator to simulate other frame types 2016-02-08 09:17:22 +11:00
Andrew Tridgell e62d6711c3 SITL: added very simple tiltrotor simulation
uses channel 9 to control tilt of rotors
2016-01-30 09:45:43 +11:00
Andrew Tridgell 8a98ce427c SITL: moved to common code for attitude/pos update 2016-01-01 15:12:33 +11:00
Andrew Tridgell 6f9e9d761f SITL: move calculations into multicopter frame class
this will enable a QuadPlane model
2016-01-01 14:35:15 +11:00
Caio Marcelo de Oliveira Filho 288dc2a385 SITL: clean up includes
Remove unnecessary includes, reorder them in blocks separated by a blank
line

   - Corresponding header file (if exists)
   - System headers
   - Other ArduPilot library headers
   - "Local" headers (from the same library)
2015-10-22 13:36:19 -02:00
Caio Marcelo de Oliveira Filho 8a55b26443 SITL: no need to use #ifdefs
Now that SITL is compiled only when it's needed (i.e. using the SITL
board), there's no need to ifdef its files based on the
CONFIG_HAL_BOARD. So remove them.
2015-10-22 13:36:19 -02:00
Caio Marcelo de Oliveira Filho e2fa456742 SITL: remove "constructor" comment 2015-10-22 11:16:39 -02:00
Caio Marcelo de Oliveira Filho 49a42dc985 SITL: use a SITL namespace 2015-10-22 11:04:42 -02:00
Gustavo Jose de Sousa a02e7730ea SITL: standardize inclusion of libaries headers
This commit changes the way libraries headers are included in source files:

 - If the header is in the same directory the source belongs to, so the
 notation '#include ""' is used with the path relative to the directory
 containing the source.

 - If the header is outside the directory containing the source, then we use
 the notation '#include <>' with the path relative to libraries folder.

Some of the advantages of such approach:

 - Only one search path for libraries headers.

 - OSs like Windows may have a better lookup time.
2015-08-11 16:38:25 +10:00
Lucas De Marchi 5c9bf90d94 SITL: use ARRAY_SIZE macro 2015-07-21 14:25:19 +09:00