Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/custom_sensor/Odometer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool Odometer::Load(const sdf::Sensor &_sdf)
}

// Load custom sensor params
auto customElem = _sdf.Element()->GetElement("gz:odometer");
auto customElem = _sdf.Element()->FindElement("gz:odometer");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should check here if customElem is different to nullptr

Suggested change
auto customElem = _sdf.Element()->FindElement("gz:odometer");
auto customElem = _sdf.Element()->FindElement("gz:odometer");
if (customElem)
{

same below

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually there is a HasElement("gz:odometer") check above already so should be fine. Same for the one below.


if (!customElem->HasElement("noise"))
{
Expand All @@ -62,7 +62,7 @@ bool Odometer::Load(const sdf::Sensor &_sdf)
}

sdf::Noise noiseSdf;
noiseSdf.Load(customElem->GetElement("noise"));
noiseSdf.Load(customElem->FindElement("noise"));
this->noise = gz::sensors::NoiseFactory::NewNoiseModel(noiseSdf);
if (nullptr == this->noise)
{
Expand Down