-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lidar component inspector (#1203)
* Support editing air pressure sensor in the GUI Signed-off-by: Nate Koenig <[email protected]> * Add noise to qrc Signed-off-by: Nate Koenig <[email protected]> * Add noise to qrc Signed-off-by: Nate Koenig <[email protected]> * Added altimeter sensor inspector Signed-off-by: Nate Koenig <[email protected]> * Added magnetometer inspector Signed-off-by: Nate Koenig <[email protected]> * Fix lint Signed-off-by: Michael Carroll <[email protected]> * Update sensor icon Signed-off-by: Nate Koenig <[email protected]> * Move AirPressure functions out of ComponentInspector (#1179) Signed-off-by: Louise Poubel <[email protected]> * Fix get decimals, and address comments Signed-off-by: Nate Koenig <[email protected]> * cleanup and simplification Signed-off-by: Nate Koenig <[email protected]> * Require sdf 12.1.0 Signed-off-by: Nate Koenig <[email protected]> * missign width Signed-off-by: Nate Koenig <[email protected]> * Added simulation state aware spin box Signed-off-by: Nate Koenig <[email protected]> * Merged Signed-off-by: Nate Koenig <[email protected]> * merged Signed-off-by: Nate Koenig <[email protected]> * Remove console output Signed-off-by: Nate Koenig <[email protected]> * alphabetize Signed-off-by: Nate Koenig <[email protected]> * Fix build Signed-off-by: Nate Koenig <[email protected]> * Add IMU component inspector Signed-off-by: Nate Koenig <[email protected]> * Added lidar component inspector Signed-off-by: Nate Koenig <[email protected]> * Fix codecheck Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> Co-authored-by: Michael Carroll <[email protected]> Co-authored-by: Louise Poubel <[email protected]>
- Loading branch information
1 parent
5d7c95f
commit 65cc189
Showing
11 changed files
with
1,005 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Copyright (C) 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#include <sdf/Lidar.hh> | ||
|
||
#include <ignition/common/Console.hh> | ||
#include <ignition/gazebo/components/GpuLidar.hh> | ||
#include <ignition/gazebo/EntityComponentManager.hh> | ||
|
||
#include "ComponentInspector.hh" | ||
#include "Lidar.hh" | ||
#include "Types.hh" | ||
|
||
using namespace ignition; | ||
using namespace gazebo; | ||
|
||
///////////////////////////////////////////////// | ||
Lidar::Lidar(ComponentInspector *_inspector) | ||
{ | ||
_inspector->Context()->setContextProperty("LidarImpl", this); | ||
this->inspector = _inspector; | ||
|
||
ComponentCreator creator = | ||
[=](EntityComponentManager &_ecm, Entity _entity, QStandardItem *_item) | ||
{ | ||
auto comp = _ecm.Component<components::GpuLidar>(_entity); | ||
if (nullptr == _item || nullptr == comp) | ||
return; | ||
const sdf::Lidar *lidar = comp->Data().LidarSensor(); | ||
|
||
_item->setData(QString("Lidar"), | ||
ComponentsModel::RoleNames().key("dataType")); | ||
_item->setData(QList({ | ||
QVariant(lidar->LidarNoise().Mean()), | ||
QVariant(lidar->LidarNoise().BiasMean()), | ||
QVariant(lidar->LidarNoise().StdDev()), | ||
QVariant(lidar->LidarNoise().BiasStdDev()), | ||
QVariant(lidar->LidarNoise().DynamicBiasStdDev()), | ||
QVariant(lidar->LidarNoise().DynamicBiasCorrelationTime()), | ||
|
||
QVariant(lidar->HorizontalScanSamples()), | ||
QVariant(lidar->HorizontalScanResolution()), | ||
QVariant(lidar->HorizontalScanMinAngle().Radian()), | ||
QVariant(lidar->HorizontalScanMaxAngle().Radian()), | ||
|
||
QVariant(lidar->VerticalScanSamples()), | ||
QVariant(lidar->VerticalScanResolution()), | ||
QVariant(lidar->VerticalScanMinAngle().Radian()), | ||
QVariant(lidar->VerticalScanMaxAngle().Radian()), | ||
|
||
QVariant(lidar->RangeMin()), | ||
QVariant(lidar->RangeMax()), | ||
QVariant(lidar->RangeResolution()), | ||
|
||
}), ComponentsModel::RoleNames().key("data")); | ||
}; | ||
|
||
this->inspector->RegisterComponentCreator( | ||
components::GpuLidar::typeId, creator); | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
Q_INVOKABLE void Lidar::OnLidarNoise( | ||
double _mean, double _meanBias, double _stdDev, | ||
double _stdDevBias, double _dynamicBiasStdDev, | ||
double _dynamicBiasCorrelationTime) | ||
{ | ||
ignition::gazebo::UpdateCallback cb = | ||
[=](EntityComponentManager &_ecm) | ||
{ | ||
auto comp = _ecm.Component<components::GpuLidar>( | ||
this->inspector->Entity()); | ||
if (comp) | ||
{ | ||
sdf::Lidar *lidar = comp->Data().LidarSensor(); | ||
if (lidar) | ||
{ | ||
sdf::Noise noise = lidar->LidarNoise(); | ||
|
||
setNoise(noise, _mean, _meanBias, _stdDev, _stdDevBias, | ||
_dynamicBiasStdDev, _dynamicBiasCorrelationTime); | ||
|
||
lidar->SetLidarNoise(noise); | ||
} | ||
else | ||
ignerr << "Unable to get the lidar noise data.\n"; | ||
} | ||
else | ||
{ | ||
ignerr << "Unable to get the lidar component.\n"; | ||
} | ||
}; | ||
this->inspector->AddUpdateCallback(cb); | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
Q_INVOKABLE void Lidar::OnLidarChange( | ||
double _rangeMin, double _rangeMax, | ||
double _rangeResolution, double _horizontalScanSamples, | ||
double _horizontalScanResolution, | ||
double _horizontalScanMinAngle, | ||
double _horizontalScanMaxAngle, double _verticalScanSamples, | ||
double _verticalScanResolution, double _verticalScanMinAngle, | ||
double _verticalScanMaxAngle) | ||
{ | ||
ignition::gazebo::UpdateCallback cb = | ||
[=](EntityComponentManager &_ecm) | ||
{ | ||
auto comp = _ecm.Component<components::GpuLidar>( | ||
this->inspector->Entity()); | ||
if (comp) | ||
{ | ||
sdf::Lidar *lidar = comp->Data().LidarSensor(); | ||
if (lidar) | ||
{ | ||
lidar->SetRangeMin(_rangeMin); | ||
lidar->SetRangeMax(_rangeMax); | ||
lidar->SetRangeResolution(_rangeResolution); | ||
|
||
lidar->SetHorizontalScanSamples(_horizontalScanSamples); | ||
lidar->SetHorizontalScanResolution(_horizontalScanResolution); | ||
lidar->SetHorizontalScanMinAngle(_horizontalScanMinAngle); | ||
lidar->SetHorizontalScanMaxAngle(_horizontalScanMaxAngle); | ||
|
||
lidar->SetVerticalScanSamples(_verticalScanSamples); | ||
lidar->SetVerticalScanResolution(_verticalScanResolution); | ||
lidar->SetVerticalScanMinAngle(_verticalScanMinAngle); | ||
lidar->SetVerticalScanMaxAngle(_verticalScanMaxAngle); | ||
} | ||
else | ||
ignerr << "Unable to get the lidar data.\n"; | ||
} | ||
else | ||
{ | ||
ignerr << "Unable to get the lidar component.\n"; | ||
} | ||
}; | ||
this->inspector->AddUpdateCallback(cb); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef IGNITION_GAZEBO_GUI_COMPONENTINSPECTOR_LIDAR_HH_ | ||
#define IGNITION_GAZEBO_GUI_COMPONENTINSPECTOR_LIDAR_HH_ | ||
|
||
#include <ignition/gazebo/gui/GuiSystem.hh> | ||
|
||
namespace ignition | ||
{ | ||
namespace gazebo | ||
{ | ||
class ComponentInspector; | ||
|
||
/// \brief A class that handles Lidar sensor changes. | ||
class Lidar : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
/// \brief Constructor | ||
/// \param[in] _inspector The component inspector. | ||
public: explicit Lidar(ComponentInspector *_inspector); | ||
|
||
/// \brief This function is called when a user changes values in the | ||
/// Lidar sensor's linear acceleration X noise values. | ||
/// \param[in] _mean Mean value | ||
/// \param[in] _meanBias Bias mean value | ||
/// \param[in] _stdDev Standard deviation value | ||
/// \param[in] _stdDevBias Bias standard deviation value | ||
/// \param[in] _dynamicBiasStdDev Dynamic bias standard deviation value | ||
/// \param[in] _dynamicBiasCorrelationTime Dynamic bias correlation time | ||
/// value | ||
public: Q_INVOKABLE void OnLidarNoise( | ||
double _mean, double _meanBias, double _stdDev, | ||
double _stdDevBias, double _dynamicBiasStdDev, | ||
double _dynamicBiasCorrelationTime); | ||
|
||
public: Q_INVOKABLE void OnLidarChange( | ||
double _rangeMin, double _rangeMax, | ||
double _rangeResolution, double _horizontalScanSamples, | ||
double _horizontalScanResolution, | ||
double _horizontalScanMinAngle, | ||
double _horizontalScanMaxAngle, double _verticalScanSamples, | ||
double _verticalScanResolution, double _verticalScanMinAngle, | ||
double _verticalScanMaxAngle); | ||
|
||
/// \brief Pointer to the component inspector. This is used to add | ||
/// update callbacks that modify the ECM. | ||
private: ComponentInspector *inspector{nullptr}; | ||
}; | ||
} | ||
} | ||
#endif |
Oops, something went wrong.