Skip to content

Commit

Permalink
Added seed value
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya <[email protected]>
  • Loading branch information
adityapande-1995 committed Nov 17, 2022
1 parent 1f39def commit 5d8e097
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/worlds/acoustic_comms_propagation.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<source_power>0.001</source_power>
<noise_level>150</noise_level>
<spectral_efficiency>7</spectral_efficiency>
<seed>0</seed>
</propagation_model>

</plugin>
Expand Down
5 changes: 5 additions & 0 deletions src/systems/acoustic_comms/AcousticComms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class AcousticComms::Implementation

/// \brief Flag to store if the propagation model should be used.
public: bool usePropagationModel = false;

/// \brief Seed value for random sampling.
public: unsigned int seed = 0;
};

//////////////////////////////////////////////////
Expand Down Expand Up @@ -125,6 +128,7 @@ bool AcousticComms::Implementation::propagationModel(
1.0 - std::exp(static_cast<double>(_numBytes) *
std::log(1 - ber));

gz::math::Rand::Seed(this->seed);
double randDraw = gz::math::Rand::DblUniform();
return randDraw > packetDropProb;
}
Expand Down Expand Up @@ -165,6 +169,7 @@ void AcousticComms::Load(
this->dataPtr->noiseLevel = propElement->Get<double>("noise_level");
this->dataPtr->spectralEfficiency =
propElement->Get<double>("spectral_efficiency");
this->dataPtr->seed = propElement->Get<int>("seed");
}

gzmsg << "AcousticComms configured with max range : " <<
Expand Down
1 change: 1 addition & 0 deletions src/systems/acoustic_comms/AcousticComms.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ namespace systems
/// over a given bandwidth in a specific
/// communication system, in (bits/sec)/Hz.
/// Defaults to 7 bits/sec/Hz.
/// * <seed> : Seed value to be used for random sampling.
///
/// Here's an example:
/// <plugin
Expand Down

0 comments on commit 5d8e097

Please sign in to comment.