From b9413309eb082b0790694011f47bbd2e26625bc2 Mon Sep 17 00:00:00 2001 From: Giovanni Grieco Date: Wed, 5 Jun 2024 00:02:31 +0200 Subject: [PATCH] Fix release regressions --- scenario/ntn-hap.json | 4 --- scenario/paper_simple.json | 26 +++++++++++++++++-- .../helper/model-configuration-helper.cc | 15 +++++++---- src/entity/drone-energy-model.cc | 3 +++ src/main.cc | 5 ++-- ...stant-acceleration-drone-mobility-model.cc | 22 +++++++++++----- .../parametric-speed-drone-mobility-model.cc | 21 ++++++++++----- 7 files changed, 69 insertions(+), 27 deletions(-) diff --git a/scenario/ntn-hap.json b/scenario/ntn-hap.json index 8e435c3..6a89efc 100644 --- a/scenario/ntn-hap.json +++ b/scenario/ntn-hap.json @@ -156,10 +156,6 @@ { "name": "OperatingFrequency", "value": 20e9 - }, - { - "name": "AntennaInclination", - "value": 0.0 // 0 deg } ] } diff --git a/scenario/paper_simple.json b/scenario/paper_simple.json index 54c4da0..17f438a 100644 --- a/scenario/paper_simple.json +++ b/scenario/paper_simple.json @@ -87,11 +87,33 @@ ], "mechanics": { "name": "ns3::Drone", - "attributes": [] + "attributes": [ + { + "name": "Mass", + "value": 0.75 + }, + { + "name": "RotorDiskArea", + "value": 0.18 + }, + { + "name": "DragCoefficient", + "value": 0.08 + } + ] }, "battery": { "name": "ns3::LiIonEnergySource", - "attributes": [] + "attributes": [ + { + "name": "LiIonEnergySourceInitialEnergyJ", + "value": 200.0 + }, + { + "name": "LiIonEnergyLowBatteryThreshold", + "value": 0.2 + } + ] }, "peripherals": [] } diff --git a/src/configuration/helper/model-configuration-helper.cc b/src/configuration/helper/model-configuration-helper.cc index b9207db..52ddcf9 100644 --- a/src/configuration/helper/model-configuration-helper.cc +++ b/src/configuration/helper/model-configuration-helper.cc @@ -231,11 +231,6 @@ ModelConfigurationHelper::DecodeAttributeValue(const std::string& modelName, values.push_back(el.GetString()); attrValue = attrInfo.checker->CreateValidValue(StrVecValue(values)); } - else if (arr.Size() == 3 && arr[0].IsDouble()) - { - const Vector3D vec{arr[0].GetDouble(), arr[1].GetDouble(), arr[2].GetDouble()}; - attrValue = attrInfo.checker->CreateValidValue(Vector3DValue(vec)); - } else if ((attrInfo.name == "SpeedCoefficients" || attrInfo.name == "PowerConsumption") && arr[0].IsNumber()) { @@ -339,6 +334,16 @@ ModelConfigurationHelper::DecodeAttributeValue(const std::string& modelName, } else if (arr[0].IsDouble()) { + // first of all, let's see if it can be decoded as a Vector3D + if (arr.Size() == 3) + { + const Vector3D vec{arr[0].GetDouble(), arr[1].GetDouble(), arr[2].GetDouble()}; + attrValue = attrInfo.checker->CreateValidValue(Vector3DValue(vec)); + } + + if (attrValue) + break; + std::vector els; for (auto& c : arr) els.push_back(c.GetDouble()); diff --git a/src/entity/drone-energy-model.cc b/src/entity/drone-energy-model.cc index 8ed9ed2..c5b161c 100644 --- a/src/entity/drone-energy-model.cc +++ b/src/entity/drone-energy-model.cc @@ -122,6 +122,9 @@ DroneEnergyModel::GetPower() const double DroneEnergyModel::DoGetCurrentA(void) const { + if (Simulator::Now() <= Time()) + return 0; + double PowerConsumption = GetPower() + GetPeripheralsPowerConsumption(); double VoltageV = m_source->GetSupplyVoltage(); double CurrentA = (PowerConsumption / VoltageV); diff --git a/src/main.cc b/src/main.cc index 3a911c4..06ec69e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -695,8 +695,7 @@ Scenario::ConfigureEntityMobility(const std::string& entityKey, { mobility.Install(m_drones.Get(entityId)); std::ostringstream oss; - oss << "/NodeList/" << m_drones.Get(entityId)->GetId() - << "/$ns3::MobilityModel/CourseChange"; + oss << "/DroneList/" << entityId << "/$ns3::MobilityModel/CourseChange"; Config::Connect(oss.str(), MakeCallback(&Scenario::CourseChange, this)); } else if (entityKey == "ZSPs") @@ -1210,7 +1209,7 @@ void Scenario::CourseChange(std::string context, Ptr model) { Vector position = model->GetPosition(); - std::string start = "/NodeList/"; + std::string start = "/DroneList/"; std::string end = "/$ns3::MobilityModel/CourseChange"; std::string id = context.substr(context.find(start) + start.length(), context.length() - end.length() - start.length()); diff --git a/src/mobility/constant-acceleration/constant-acceleration-drone-mobility-model.cc b/src/mobility/constant-acceleration/constant-acceleration-drone-mobility-model.cc index 63dbb54..81b56df 100644 --- a/src/mobility/constant-acceleration/constant-acceleration-drone-mobility-model.cc +++ b/src/mobility/constant-acceleration/constant-acceleration-drone-mobility-model.cc @@ -145,14 +145,14 @@ void ConstantAccelerationDroneMobilityModel::DoInitialize() { NS_LOG_FUNCTION(this); - + GeocentricMobilityModel::DoInitialize(); + m_flightPlan = (m_useGeodedicSystem) + ? GeographicToProjectedCoordinates(m_flightPlan, GetEarthSpheroidType()) + : m_flightPlan; m_flightParams = {m_acceleration, m_maxSpeed}; - m_planner = Planner(m_flightPlan, m_flightParams, m_curveStep); - - MobilityModel::DoInitialize(); } void @@ -290,9 +290,17 @@ void ConstantAccelerationDroneMobilityModel::SetFlightPlan(const FlightPlan& flightPlan) { NS_LOG_FUNCTION(this << flightPlan); - m_flightPlan = (m_useGeodedicSystem) - ? GeographicToProjectedCoordinates(flightPlan, GetEarthSpheroidType()) - : flightPlan; + if (IsInitialized()) + { + m_flightPlan = (m_useGeodedicSystem) + ? GeographicToProjectedCoordinates(flightPlan, GetEarthSpheroidType()) + : flightPlan; + } + else + { + // Temporally store raw Flight Plan. Will convert at object inizialization. + m_flightPlan = flightPlan; + } } } // namespace ns3 diff --git a/src/mobility/parametric-speed/parametric-speed-drone-mobility-model.cc b/src/mobility/parametric-speed/parametric-speed-drone-mobility-model.cc index 75e934f..17c6359 100644 --- a/src/mobility/parametric-speed/parametric-speed-drone-mobility-model.cc +++ b/src/mobility/parametric-speed/parametric-speed-drone-mobility-model.cc @@ -138,12 +138,13 @@ void ParametricSpeedDroneMobilityModel::DoInitialize() { NS_LOG_FUNCTION(this); - + GeocentricMobilityModel::DoInitialize(); + m_flightPlan = (m_useGeodedicSystem) + ? GeographicToProjectedCoordinates(m_flightPlan, GetEarthSpheroidType()) + : m_flightPlan; m_planner = Planner(m_flightPlan, m_flightParams, m_curveStep); - - MobilityModel::DoInitialize(); } void @@ -282,9 +283,17 @@ void ParametricSpeedDroneMobilityModel::SetFlightPlan(const FlightPlan& flightPlan) { NS_LOG_FUNCTION(this << flightPlan); - m_flightPlan = (m_useGeodedicSystem) - ? GeographicToProjectedCoordinates(flightPlan, GetEarthSpheroidType()) - : flightPlan; + if (IsInitialized()) + { + m_flightPlan = (m_useGeodedicSystem) + ? GeographicToProjectedCoordinates(flightPlan, GetEarthSpheroidType()) + : flightPlan; + } + else + { + // Temporally store raw Flight Plan. Will convert at object inizialization. + m_flightPlan = flightPlan; + } } void