Skip to content

Commit

Permalink
SITL: add frame SA_GD2000
Browse files Browse the repository at this point in the history
  • Loading branch information
magicrub committed Sep 5, 2024
1 parent 9353a41 commit 71a53a3
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libraries/AP_HAL_SITL/SITL_cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <SITL/SIM_FlightAxis.h>
#include <SITL/SIM_Calibration.h>
#include <SITL/SIM_XPlane.h>
#include <SITL/SIM_SA_GD2000.h>
#include <SITL/SIM_Submarine.h>
#include <SITL/SIM_SilentWings.h>
#include <SITL/SIM_Morse.h>
Expand Down Expand Up @@ -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
Expand Down
66 changes: 66 additions & 0 deletions libraries/SITL/SIM_SA_GD2000.cpp
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
/*
SA_GD2000 simulator class
*/

#include "SIM_SA_GD2000.h"

#if AP_SIM_SA_GD2000_ENABLED

#include <AP_Logger/AP_Logger.h>

#include <stdio.h>

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
53 changes: 53 additions & 0 deletions libraries/SITL/SIM_SA_GD2000.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
/*
a stratospheric blimp simulator class
*/

#pragma once

#include "SIM_config.h"

#if AP_SIM_SA_GD2000_ENABLED

#include "SIM_Plane.h"
#include <AP_Param/AP_Param.h>

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
4 changes: 4 additions & 0 deletions libraries/SITL/SIM_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions libraries/SITL/SITL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
};

Expand Down
5 changes: 5 additions & 0 deletions libraries/SITL/SITL.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct float_array {
};

class StratoBlimp;
class SA_GD2000;
class Glider;

struct sitl_fdm {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 71a53a3

Please sign in to comment.