mobility: Expose child mobility model to parent position

This commit is contained in:
Tom Henderson
2021-09-07 16:22:23 -07:00
parent 4ca947a477
commit a2cddc8da0
3 changed files with 34 additions and 1 deletions

View File

@@ -117,7 +117,7 @@ HierarchicalMobilityModel::DoGetPosition (void) const
return m_child->GetPosition ();
}
Vector parentPosition = m_parent->GetPosition ();
Vector childPosition = m_child->GetPosition ();
Vector childPosition = m_child->GetPositionWithReference (parentPosition);
return Vector (parentPosition.x + childPosition.x,
parentPosition.y + childPosition.y,
parentPosition.z + childPosition.z);

View File

@@ -65,6 +65,19 @@ MobilityModel::GetPosition (void) const
{
return DoGetPosition ();
}
Vector
MobilityModel::GetPositionWithReference (const Vector& referencePosition) const
{
return DoGetPositionWithReference (referencePosition);
}
// Default implementation ignores referencePosition
Vector
MobilityModel::DoGetPositionWithReference (const Vector& referencePosition) const
{
return DoGetPosition ();
}
Vector
MobilityModel::GetVelocity (void) const
{

View File

@@ -51,6 +51,18 @@ public:
* \return the current position
*/
Vector GetPosition (void) const;
/**
* This method may be used if the position returned may depend on some
* reference position provided. For example, in a hierarchical mobility
* model that is buildings-aware, the child mobility model may not be able
* to determine if it is inside or outside of a building unless it knows
* the parent position.
*
* \param referencePosition reference position to consider
* \return the current position based on the provided referencePosition
* \sa ns3::MobilityModel::DoGetPositionWithReference
*/
Vector GetPositionWithReference (const Vector &referencePosition) const;
/**
* \param position the position to set.
*/
@@ -100,6 +112,14 @@ private:
* implement this method.
*/
virtual Vector DoGetPosition (void) const = 0;
/**
* \param referencePosition the reference position to consider
* \return the current position.
*
* Unless subclasses override, this method will disregard the reference
* position and return "DoGetPosition (void)".
*/
virtual Vector DoGetPositionWithReference (const Vector& referencePosition) const;
/**
* \param position the position to set.
*