From 581629b332b40dd7124ef66a26ead1a3aa9378f7 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 11 Oct 2021 16:05:28 +1100 Subject: [PATCH] SITL: make Ship simulator optional --- libraries/SITL/SIM_Aircraft.cpp | 7 ++++++- libraries/SITL/SIM_Ship.cpp | 5 +++++ libraries/SITL/SIM_Ship.h | 10 ++++++++++ libraries/SITL/SITL.cpp | 2 ++ libraries/SITL/SITL.h | 2 ++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libraries/SITL/SIM_Aircraft.cpp b/libraries/SITL/SIM_Aircraft.cpp index ddf6f910fa..30658d8bc5 100644 --- a/libraries/SITL/SIM_Aircraft.cpp +++ b/libraries/SITL/SIM_Aircraft.cpp @@ -626,9 +626,12 @@ void Aircraft::update_dynamics(const Vector3f &rot_accel) // get speed of ground movement (for ship takeoff/landing) float yaw_rate = 0; +#if AP_SIM_SHIP_ENABLED const Vector2f ship_movement = sitl->shipsim.get_ground_speed_adjustment(location, yaw_rate); const Vector3f gnd_movement(ship_movement.x, ship_movement.y, 0); - +#else + const Vector3f gnd_movement; +#endif switch (ground_behavior) { case GROUND_BEHAVIOR_NONE: break; @@ -955,7 +958,9 @@ void Aircraft::update_external_payload(const struct sitl_input &input) fetteconewireesc->update(*this); } +#if AP_SIM_SHIP_ENABLED sitl->shipsim.update(); +#endif // update IntelligentEnergy 2.4kW generator if (ie24) { diff --git a/libraries/SITL/SIM_Ship.cpp b/libraries/SITL/SIM_Ship.cpp index bf8ae75973..7cc89ac005 100644 --- a/libraries/SITL/SIM_Ship.cpp +++ b/libraries/SITL/SIM_Ship.cpp @@ -17,6 +17,9 @@ */ #include "SIM_Ship.h" + +#if AP_SIM_SHIP_ENABLED + #include "SITL.h" #include @@ -205,3 +208,5 @@ void ShipSim::send_report(void) mav_socket.send(buf, len); } } + +#endif diff --git a/libraries/SITL/SIM_Ship.h b/libraries/SITL/SIM_Ship.h index 5f98999f86..16e97152a6 100644 --- a/libraries/SITL/SIM_Ship.h +++ b/libraries/SITL/SIM_Ship.h @@ -18,6 +18,14 @@ #pragma once +#include + +#ifndef AP_SIM_SHIP_ENABLED +#define AP_SIM_SHIP_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_SHIP_ENABLED + #include #include #include @@ -84,3 +92,5 @@ private: }; } // namespace SITL + +#endif // AP_SIM_SHIP_ENABLED diff --git a/libraries/SITL/SITL.cpp b/libraries/SITL/SITL.cpp index 530341301f..88327dc89e 100644 --- a/libraries/SITL/SITL.cpp +++ b/libraries/SITL/SITL.cpp @@ -74,7 +74,9 @@ const AP_Param::GroupInfo SIM::var_info[] = { AP_GROUPINFO("SONAR_POS", 55, SIM, rngfnd_pos_offset, 0), AP_GROUPINFO("FLOW_POS", 56, SIM, optflow_pos_offset, 0), AP_GROUPINFO("ENGINE_FAIL", 58, SIM, engine_fail, 0), +#if AP_SIM_SHIP_ENABLED AP_SUBGROUPINFO(shipsim, "SHIP_", 59, SIM, ShipSim), +#endif AP_SUBGROUPEXTENSION("", 60, SIM, var_mag), AP_SUBGROUPEXTENSION("", 61, SIM, var_gps), AP_SUBGROUPEXTENSION("", 62, SIM, var_info3), diff --git a/libraries/SITL/SITL.h b/libraries/SITL/SITL.h index 56b44d163e..85e14bfbad 100644 --- a/libraries/SITL/SITL.h +++ b/libraries/SITL/SITL.h @@ -400,7 +400,9 @@ public: Sprayer sprayer_sim; // simulated ship takeoffs +#if AP_SIM_SHIP_ENABLED ShipSim shipsim; +#endif Gripper_Servo gripper_sim; Gripper_EPM gripper_epm_sim;