Skip to content

Commit

Permalink
Fix release regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovanniGrieco committed Jun 4, 2024
1 parent 70ab20c commit b941330
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 27 deletions.
4 changes: 0 additions & 4 deletions scenario/ntn-hap.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@
{
"name": "OperatingFrequency",
"value": 20e9
},
{
"name": "AntennaInclination",
"value": 0.0 // 0 deg
}
]
}
Expand Down
26 changes: 24 additions & 2 deletions scenario/paper_simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
Expand Down
15 changes: 10 additions & 5 deletions src/configuration/helper/model-configuration-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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<double> els;
for (auto& c : arr)
els.push_back(c.GetDouble());
Expand Down
3 changes: 3 additions & 0 deletions src/entity/drone-energy-model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -1210,7 +1209,7 @@ void
Scenario::CourseChange(std::string context, Ptr<const MobilityModel> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConstantAccelerationParam, ConstantAccelerationFlight>(m_flightPlan,
m_flightParams,
m_curveStep);

MobilityModel::DoInitialize();
}

void
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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<ParametricSpeedParam, ParametricSpeedFlight>(m_flightPlan,
m_flightParams,
m_curveStep);

MobilityModel::DoInitialize();
}

void
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b941330

Please sign in to comment.