diff --git a/libraries/AP_HAL_SITL/SITL_cmdline.cpp b/libraries/AP_HAL_SITL/SITL_cmdline.cpp index 042bb2ce7f212..80bd103003dd0 100644 --- a/libraries/AP_HAL_SITL/SITL_cmdline.cpp +++ b/libraries/AP_HAL_SITL/SITL_cmdline.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -179,6 +180,9 @@ static const struct { { "JSON", JSON::create }, { "blimp", Blimp::create }, { "novehicle", NoVehicle::create }, +#if AP_SIM_SA_GD2000_ENABLED + { "sa_gd2000", SA_GD2000::create }, +#endif #if AP_SIM_STRATOBLIMP_ENABLED { "stratoblimp", StratoBlimp::create }, #endif diff --git a/libraries/SITL/SIM_SA_GD2000.cpp b/libraries/SITL/SIM_SA_GD2000.cpp new file mode 100644 index 0000000000000..b061214b5477d --- /dev/null +++ b/libraries/SITL/SIM_SA_GD2000.cpp @@ -0,0 +1,66 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/* + SA_GD2000 simulator class +*/ + +#include "SIM_SA_GD2000.h" + +#if AP_SIM_SA_GD2000_ENABLED + +#include + +#include + +using namespace SITL; + +extern const AP_HAL::HAL& hal; + +// SITL SA_GD2000 parameters +const AP_Param::GroupInfo SA_GD2000::var_info[] = { + // @Param: MASS + // @DisplayName: mass + // @Description: mass of SA_GD2000 + // @Units: kg + AP_GROUPINFO("MASS", 1, SA_GD2000, param_mass, 907), // 907kg = 2000lbs + + AP_GROUPEND +}; + +SA_GD2000::SA_GD2000(const char *frame_str) : + Plane(frame_str) +{ + AP_Param::setup_object_defaults(this, var_info); + + AP_Param::load_defaults_file("@ROMFS/models/sa_gd2000.parm", false); + + mass = param_mass; + thrust_scale = 0; + + launch_accel = 50; + launch_time = 1; + + coefficient.c_drag_p = 0.05; +} + +/* + update the vehicle simulation by one time step + */ +void SA_GD2000::update(const struct sitl_input &input) +{ + Plane::update(input); +} + +#endif // AP_SIM_SA_GD2000_ENABLED \ No newline at end of file diff --git a/libraries/SITL/SIM_SA_GD2000.h b/libraries/SITL/SIM_SA_GD2000.h new file mode 100644 index 0000000000000..14383d19546e4 --- /dev/null +++ b/libraries/SITL/SIM_SA_GD2000.h @@ -0,0 +1,53 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +/* + a stratospheric blimp simulator class +*/ + +#pragma once + +#include "SIM_config.h" + +#if AP_SIM_SA_GD2000_ENABLED + +#include "SIM_Plane.h" +#include + +namespace SITL { + +/* + a Silent Arrow GD2000 simulator + */ + +class SA_GD2000 : public Plane { +public: + SA_GD2000(const char *frame_str); + + /* update model by one time step */ + void update(const struct sitl_input &input) override; + + /* static object creator */ + static Aircraft *create(const char *frame_str) { + return NEW_NOTHROW SA_GD2000(frame_str); + } + + static const struct AP_Param::GroupInfo var_info[]; + +private: + AP_Float param_mass; +}; + +} +#endif // AP_SIM_SA_GD2000_ENABLED \ No newline at end of file diff --git a/libraries/SITL/SIM_config.h b/libraries/SITL/SIM_config.h index aa281c45f753a..8ef0acdd88d65 100644 --- a/libraries/SITL/SIM_config.h +++ b/libraries/SITL/SIM_config.h @@ -126,6 +126,10 @@ #define AP_SIM_STRATOBLIMP_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) #endif +#ifndef AP_SIM_SA_GD2000_ENABLED +#define AP_SIM_SA_GD2000_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + #ifndef AP_SIM_GLIDER_ENABLED #define AP_SIM_GLIDER_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) #endif diff --git a/libraries/SITL/SITL.cpp b/libraries/SITL/SITL.cpp index ee9d59f28183f..8ec3d52f6a196 100644 --- a/libraries/SITL/SITL.cpp +++ b/libraries/SITL/SITL.cpp @@ -38,6 +38,7 @@ #endif // SFML_JOYSTICK #include "SIM_StratoBlimp.h" +#include "SIM_SA_GD2000.h" #include "SIM_Glider.h" extern const AP_HAL::HAL& hal; @@ -1263,6 +1264,12 @@ const AP_Param::GroupInfo SIM::ModelParm::var_info[] = { AP_SUBGROUPINFO(slung_payload_sim, "SLUP_", 4, SIM::ModelParm, SlungPayloadSim), #endif +#if AP_SIM_SA_GD2000_ENABLED + // @Group: GD2K_ + // @Path: ./SIM_SA_GD2000.cpp + AP_SUBGROUPPTR(sa_gd2000_ptr, "GD2K_", 5, SIM::ModelParm, SA_GD2000), +#endif + AP_GROUPEND }; diff --git a/libraries/SITL/SITL.h b/libraries/SITL/SITL.h index d3ad9ebbd962a..8fdda6c11e337 100644 --- a/libraries/SITL/SITL.h +++ b/libraries/SITL/SITL.h @@ -50,6 +50,7 @@ struct float_array { }; class StratoBlimp; +class SA_GD2000; class Glider; struct sitl_fdm { @@ -318,6 +319,10 @@ class SIM { #if AP_SIM_STRATOBLIMP_ENABLED StratoBlimp *stratoblimp_ptr; #endif +#if AP_SIM_SA_GD2000_ENABLED + SA_GD2000 *sa_gd2000_ptr; +#endif + #if AP_SIM_SHIP_ENABLED ShipSim shipsim; #endif