Commit Graph
72 Commits
Author SHA1 Message Date
Codir de5add012e SITL: fix the ROMFS fallback when loading json models
Both loaders build "@ROMFS/models/<name>" into fname when the model is not
found on the filesystem, then stat() the original path again -- the one
already known to be missing -- so the fallback can never succeed and a model
that exists only in ROMFS panics. fname was also never passed to load_json()
and never freed.

Stat and load the resolved path, guard it against a failed asprintf, and free
it.
2026-08-09 10:13:42 +10:00
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 Fable 5 c9c5fe1d7f SITL: add heli-quad frame
A collective pitch quadcopter matching AP_MotorsHeli_Quad's layout,
with rotor speed control on channel 8 to match AP_MotorsHeli_RSC's
default channel.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-25 10:14:55 +10:00
Leonard Hall ee39af11ec SITL: Fix octa_quad_cw_x frame 2026-06-24 07:43:02 +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
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
Bob Long ffdb017f3e SITL: fix SIM_BATT_CAP_AH 2025-12-02 20:49:09 +11:00
Andrew Tridgell 621e542ac9 SITL: octa-quad-cor (co-rotating) frames 2025-12-02 11:16:21 +11:00
Peter Barker 5b5dc8a128 SITL: add dotriaconta_octaquad_x frame 2025-01-27 14:03:41 +11:00
murata 7de6eb5b20 SITL: Support Hexadeca-Octa (OCTA-X16) 2025-01-27 14:03:41 +11:00
Andrew Tridgell bb96db5466 SITL: support up to 32 rotors in a frame 2025-01-07 09:32:33 +11:00
Peter Barker fea17e6f59 SITL: remove superfluous linefeed from panic strings
panic adds this within the HAL layer.
2024-12-14 10:06:13 +11:00
Andrew Tridgell 67c506e75c SITL: use new atmospheric tables
and improve pitot handling
2024-05-07 21:19:06 +10:00
Andrew Tridgell cb01789b9f SITL: use AP_JSON 2024-02-21 12:09:48 +11:00
Andrew Tridgell 9225b9f76d SITL: added 4 motor tilt vectored quadplane
from 2 motors tilt for "quadplane-tilt". This is the most common tilt
quadplane setup
2024-02-18 16:28:43 +11:00
Jacob Olson 689a5c7b52 SITL: SIM_Frame: fixed per_motor_vars config loading 2024-01-09 10:53:33 +11:00
Andrew Tridgell 1b6c329de5 SITL: use NaN for invalid rangefinder data
needed to cope properly with terrain errors leading to negative
rangefinder data
2023-08-24 13:06:40 +10:00
Andy Piper 3224cf19a8 SITL: remove unused variables 2023-07-13 11:02:40 +10:00
Andrew Tridgell 7a4483b091 SITL: new XPlane backend
this makes use of DRefs to greatly improve XPlane support. It only
supports XPlane 11 and later

The key change is the use of a JSON file to map ArduPilot output
channels to DataRefs, and map raw joystick inputs to RC inputs

this gets rid of the awful throttle hack handling, and allows for
control of a much wider range of aircraft
2023-01-31 11:22:08 +11: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
Iampete1 f61d96dd5c SITL: SIM_Frame: add number of motors to json spec 2022-05-03 10:03:07 +10:00
Iampete1 6a8fff67f7 SITL: SIM_Frame: remove motor evaluation debug code 2022-05-03 10:03:07 +10:00
Iampete1 6eea4d12ee SITL: apply momentum drag per-motor 2022-05-01 09:17:23 +10:00
Iampete1 f9050c3040 SITL: Frame: take drag from thrust not accel 2022-05-01 09:17:23 +10:00
Iampete1 92135400f8 SITL: Frame: stop adding random physics noise 2022-05-01 09:17:23 +10:00
Iampete1 f869506b0a SITL: Motor: acount for airflow due to vehicle rotation 2022-05-01 09:17:23 +10:00
Iampete1 bead0ac0f8 SITL: JSON allow to set motor rotation direciton 2022-05-01 09:17:23 +10:00
Iampete1 f0c17f0e49 SITL: use AP_SIM_ENABLED define more 2022-04-26 10:26:29 +10:00
Iampete1 a7abfeeb4a SITL: allow cutom motor postions and thrust vectors to be specified 2022-04-19 09:43:51 +10:00
Iampete1 47f327b500 SITL: allow Vector3f inertia to be set via JSON 2022-04-19 09:43:51 +10:00
Iampete1 6272dc33dd SITL: move moments inertia to frame property 2022-04-19 09:43:51 +10:00
Iampete1 7936f3bb0a SITL: move motor related constants to motor object 2022-04-19 09:43:51 +10:00
Randy Mackay 375ab84e56 SITL: correct suggestion to user re wind estimatation param value
EK3_MCOEF becomes EK3_DRAG_MCOEF
EK3_BCOEF_ becomes EK3_DRAG_BCOEF_
2022-04-13 07:57:35 +09:00
Peter Barker 3cf7091525 SITL: make parsing of json files dependent on PICOJSON
picojson uses the standard library; this will be a problem on embedded
platforms
2022-03-17 14:39:55 +11:00
Peter Barker 9ef959b93b SITL: make C_TO_KELVIN a function macro; create KELVIN_TO_C
These are in celsius
2022-01-13 18:31:46 +11:00
Andrew Tridgell ba58558bd1 SITL: fixed default BATT_CAPACITY for SITL
don't override from JSON model unless we have a value
2021-12-21 19:53:43 +11:00
Iampete1 6628fd2837 SITL: swap rotation direciton of motor 2 for lower yaw offset 2021-08-28 10:32:59 +09:00
Peter Barker d38e704115 SITL: fix memory over-read detected by Valgrind
==15803== Conditional jump or move depends on uninitialised value(s)
==15803==    at 0x4C34975: index (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15803==    by 0x444D8D: SITL::Frame::load_frame_params(char const*) (SIM_Frame.cpp:363)
==15803==    by 0x445415: SITL::Frame::init(char const*, SITL::Battery*) (SIM_Frame.cpp:432)
==15803==    by 0x3696ED: SITL::MultiCopter::MultiCopter(char const*) (SIM_Multicopter.cpp:35)
==15803==    by 0x34B49C: SITL::MultiCopter::create(char const*) (SIM_Multicopter.h:44)
==15803==    by 0x34C58E: HALSITL::SITL_State::_parse_command_line(int, char* const*) (SITL_cmdline.cpp:480)
==15803==    by 0x344005: HALSITL::SITL_State::init(int, char* const*) (SITL_State.cpp:923)
==15803==    by 0x33D854: HAL_SITL::run(int, char* const*, AP_HAL::HAL::Callbacks*) const (HAL_SITL_Class.cpp:182)
==15803==    by 0x15ACDD: main (Copter.cpp:678)
==15803==
2021-05-05 21:21:56 +10:00
Peter Barker 0661a27400 SITL: ensure st.size is valid when loading model json
Before this patch st.size is undefined when we use it to create a buffer
on the stack - probably not a good thing.
2021-05-05 21:21:56 +10:00
Paul Riseborough b258cb0539 SITL: Add momentum drag to Z axis to work around thrust model deficiencies 2020-12-11 15:21:41 +11:00
Paul Riseborough a907c10733 SITL: Add momentum drag to multicopter model 2020-12-11 15:21:41 +11:00
murata 13c7980f0b SITL: Support for decacopters 2020-12-08 11:59:10 +11:00
Andrew Tridgell d8337cf9e5 SITL: allow loading of model from ROMFS 2020-10-28 14:20:44 +11:00
Andrew Tridgell e07cecb264 SITL: added support for simulated battery discharge 2020-10-28 14:20:44 +11:00
Andrew Tridgell a0bc9d3148 SITL: fixed quadplane mass and rpm indexing 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
Andrew Tridgell 7c2d13c571 SITL: added simulation of pressure altitude for multicopter
this gives us a ceiling of 5.4km above sea level for the default
copter
2020-06-05 11:35:53 +10:00
Rishabh 08f27f7668 SITL: Added cwx motor setup for hexa, octa and octaquad 2020-02-19 11:28:25 +09:00
Rishabh dc662a56b2 SITL: Added DJI Hexa and Octa for SITL 2020-01-29 16:57:23 +09:00
Andrew Tridgell dc80df23e9 SITL: added betaflight-rev-x frame 2020-01-16 19:13:13 +11:00