Skip to content

Commit

Permalink
Add sensors to a link via the GUI (#1188)
Browse files Browse the repository at this point in the history
* add an add entity button to component inspector. Currently only enabled for models

Signed-off-by: Ian Chen <[email protected]>

* add model editor gui plugin that inserts visuals to the scene in the render thread

Signed-off-by: Ian Chen <[email protected]>

* write to ECM

Signed-off-by: Ian Chen <[email protected]>

* get updated GUI ECM info in world control CB

Signed-off-by: Ashton Larkin <[email protected]>

* support adding light links

Signed-off-by: Ian Chen <[email protected]>

* working on adding tests

Signed-off-by: Ashton Larkin <[email protected]>

* remove TODO note, issue fixed by #1131

Signed-off-by: Ashton Larkin <[email protected]>

* notify other GUI plugins of added/removed entities via GUI events

Signed-off-by: Ashton Larkin <[email protected]>

* use const ref for constructor input params

Signed-off-by: Ashton Larkin <[email protected]>

* guarantee 64 bit entity IDs with gazebo::Entity instead of unsigned int

Signed-off-by: Ashton Larkin <[email protected]>

* testing makr as new entity  func

Signed-off-by: Ian Chen <[email protected]>

* rm printouts

Signed-off-by: Ian Chen <[email protected]>

* register type

Signed-off-by: Ian Chen <[email protected]>

* refactor render util

Signed-off-by: Ian Chen <[email protected]>

* apply GUI ECM's diff to server ECM at end of pause interval

Signed-off-by: Ashton Larkin <[email protected]>

* use gui event to update server

Signed-off-by: Ashton Larkin <[email protected]>

* Working on sensor addition and editing

Signed-off-by: Nate Koenig <[email protected]>

* handle step and support original control service

Signed-off-by: Ashton Larkin <[email protected]>

* Reduced code duplication

Signed-off-by: Nate Koenig <[email protected]>

* Set gazebo's default to use the event based system

Signed-off-by: Nate Koenig <[email protected]>

* Testing things out

Signed-off-by: Nate Koenig <[email protected]>

* updates

Signed-off-by: Nate Koenig <[email protected]>

* workaround for avoiding crash on exit

Signed-off-by: Ian Chen <[email protected]>

* refactor, comment out unused menu items

Signed-off-by: Ian Chen <[email protected]>

* remove commented out code, add CreateLight function

Signed-off-by: Ian Chen <[email protected]>

* add model editor src files

Signed-off-by: Ian Chen <[email protected]>

* remove more commented out code

Signed-off-by: Ian Chen <[email protected]>

* Fix build

Signed-off-by: Nate Koenig <[email protected]>

* use entity instead of entity name

Signed-off-by: Nate Koenig <[email protected]>

* Update link add menu

Signed-off-by: Nate Koenig <[email protected]>

* Updates

Signed-off-by: Nate Koenig <[email protected]>

* Added back in sensor menu

Signed-off-by: Nate Koenig <[email protected]>

* Updates

Signed-off-by: Nate Koenig <[email protected]>

* Updates

Signed-off-by: Nate Koenig <[email protected]>

* Updates

Signed-off-by: Nate Koenig <[email protected]>

* use entity instead of entity name (#1176)

Signed-off-by: Nate Koenig <[email protected]>

Co-authored-by: Nate Koenig <[email protected]>

* Adding sensors

Signed-off-by: Nate Koenig <[email protected]>

* Add link menu updates (#1177)

* use entity instead of entity name

Signed-off-by: Nate Koenig <[email protected]>

* Update link add menu

Signed-off-by: Nate Koenig <[email protected]>

Co-authored-by: Nate Koenig <[email protected]>
Co-authored-by: Ian Chen <[email protected]>

* fix adding ellipsoid

Signed-off-by: Ian Chen <[email protected]>

* merge model_editor into component_inspector

Signed-off-by: Ian Chen <[email protected]>

* fixing warnings

Signed-off-by: Ian Chen <[email protected]>

* Adjust tool tips

Signed-off-by: Nate Koenig <[email protected]>

* Updates

Signed-off-by: Nate Koenig <[email protected]>

* updates

Signed-off-by: Nate Koenig <[email protected]>

* updates

Signed-off-by: Nate Koenig <[email protected]>

* Adding lidar menu

Signed-off-by: Nate Koenig <[email protected]>

* alphabetize

Signed-off-by: Nate Koenig <[email protected]>

* Comment out sensors not supported

Signed-off-by: Nate Koenig <[email protected]>

* Added segmentation camera

Signed-off-by: Nate Koenig <[email protected]>

* fix id

Signed-off-by: Nate Koenig <[email protected]>

* fix codecheck

Signed-off-by: Nate Koenig <[email protected]>

* Fix submenue

Signed-off-by: Nate Koenig <[email protected]>

* Remove lidar menu, and address comments

Signed-off-by: Nate Koenig <[email protected]>

* fix codecheck

Signed-off-by: Nate Koenig <[email protected]>

* Merged

Signed-off-by: Nate Koenig <[email protected]>

Co-authored-by: Ian Chen <[email protected]>
Co-authored-by: Ashton Larkin <[email protected]>
Co-authored-by: Ashton Larkin <[email protected]>
Co-authored-by: Nate Koenig <[email protected]>
  • Loading branch information
5 people authored Dec 2, 2021
1 parent e427bed commit 93893f0
Show file tree
Hide file tree
Showing 19 changed files with 599 additions and 237 deletions.
2 changes: 1 addition & 1 deletion include/ignition/gazebo/rendering/RenderUtil.hh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
/// \param[in] _ecm Const reference to the entity component manager
/// \param[in] _entities Entities to create visuals for.
public: void CreateVisualsForEntities(const EntityComponentManager &_ecm,
const std::set<Entity> &_entities);
const std::set<Entity> &_entities);

/// \brief Set the rendering engine to use
/// \param[in] _engineName Name of the rendering engine.
Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/component_inspector/AirPressure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Q_INVOKABLE void AirPressure::OnAirPressureNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::AirPressureSensor>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::AirPressure *airpressure = comp->Data().AirPressureSensor();
Expand Down Expand Up @@ -100,7 +100,7 @@ Q_INVOKABLE void AirPressure::OnAirPressureReferenceAltitude(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::AirPressureSensor>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::AirPressure *airpressure = comp->Data().AirPressureSensor();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/component_inspector/Altimeter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Q_INVOKABLE void Altimeter::OnAltimeterPositionNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::Altimeter>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Altimeter *altimeter = comp->Data().AltimeterSensor();
Expand Down Expand Up @@ -106,7 +106,7 @@ Q_INVOKABLE void Altimeter::OnAltimeterVelocityNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::Altimeter>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Altimeter *altimeter = comp->Data().AltimeterSensor();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/plugins/component_inspector/ComponentInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ Entity ComponentInspector::GetEntity() const
}

/////////////////////////////////////////////////
void ComponentInspector::SetEntity(const Entity &_entity)
void ComponentInspector::SetEntity(const gazebo::Entity &_entity)
{
// If nothing is selected, display world properties
if (_entity == kNullEntity)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/plugins/component_inspector/ComponentInspector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ namespace gazebo

/// \brief Set the entity currently inspected.
/// \param[in] _entity Entity ID.
public: Q_INVOKABLE void SetEntity(const Entity &_entity);
public: Q_INVOKABLE void SetEntity(const gazebo::Entity &_entity);

/// \brief Notify that entity has changed.
signals: void EntityChanged();
Expand Down
188 changes: 177 additions & 11 deletions src/gui/plugins/component_inspector/ComponentInspector.qml
Original file line number Diff line number Diff line change
Expand Up @@ -306,34 +306,34 @@ Rectangle {
}

ToolButton {
id: addButton
id: addLinkButton
checkable: false
text: "Add entity"
visible: entityType == "model"
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "qrc:/Gazebo/images/plus.png"
source: "qrc:/Gazebo/images/plus-link.png"
sourceSize.width: 18;
sourceSize.height: 18;
}
ToolTip.text: "Add an entity to a model"
ToolTip.text: "Add a link or light to a model"
ToolTip.visible: hovered
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
onClicked: {
getSimPaused() ? addLinkMenu.open() : pausePopup.open()
getSimPaused() ? addLinkMenu.open() : linkAddPausePopup.open()
}
Popup {
id: pausePopup
id: linkAddPausePopup
modal: true
focus: true
x: parent.width - popupContentText.width
y: parent.height + popupContentText.height
x: parent.width - linkAdPopupContentText.width
y: parent.height + linkAdPopupContentText.height
contentItem: Text {
id: popupContentText
id: linkAdPopupContentText
padding: 10
text: "Pause simulation to add an entity"
text: "Pause simulation to add a link or light"
}
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
}
Expand All @@ -350,7 +350,6 @@ Rectangle {
}
}


Menu {
id: addLinkMenu

Expand Down Expand Up @@ -577,7 +576,175 @@ Rectangle {
addLinkMenu.close()
}
}
}
}

ToolButton {
id: addSensorButton
checkable: false
text: "Add sensor"
visible: entityType == "link"
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: "qrc:/Gazebo/images/plus-sensor.png"
sourceSize.width: 18;
sourceSize.height: 18;
}
ToolTip.text: "Add a sensor to a link"
ToolTip.visible: hovered
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
onClicked: {
getSimPaused() ? addSensorMenu.open() : sensorAddPausePopup.open()
}
Popup {
id: sensorAddPausePopup
modal: true
focus: true
x: parent.width - sensorAddPopupContentText.width
y: parent.height + sensorAddPopupContentText.height
contentItem: Text {
id: sensorAddPopupContentText
padding: 10
text: "Pause simulation to add a sensor"
}
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
}

Menu {
id: addSensorMenu
MenuItem {
id: airPressure
text: "Air pressure"
onTriggered: {
ComponentInspector.OnAddEntity(airPressure.text, "sensor");
}
}

MenuItem {
id: altimeter
text: "Altimeter"
onTriggered: {
ComponentInspector.OnAddEntity(altimeter.text, "sensor");
}
}

MenuItem {
id: cameraSensorMenu
text: "Camera >"

MouseArea {
id: viewSubCameraArea
anchors.fill: parent
hoverEnabled: true
onEntered: cameraSubmenu.open()
}
}

MenuItem {
id: contact
text: "Contact"
onTriggered: {
ComponentInspector.OnAddEntity(contact.text, "sensor");
}
}

MenuItem {
id: forceTorque
text: "Force torque"
onTriggered: {
ComponentInspector.OnAddEntity(forceTorque.text, "sensor");
}
}

/*MenuItem {
id: gps
text: "GPS"
onTriggered: {
ComponentInspector.OnAddEntity(gps.text, "sensor");
}
}*/

MenuItem {
id: gpuLidar
text: "GPU Lidar"
onTriggered: {
ComponentInspector.OnAddEntity("gpu_lidar", "sensor");
}
}

MenuItem {
id: imu
text: "IMU"
onTriggered: {
ComponentInspector.OnAddEntity(imu.text, "sensor");
}
}

MenuItem {
id: magnetometer
text: "Magnetometer"
onTriggered: {
ComponentInspector.OnAddEntity(magnetometer.text, "sensor");
}
}
}

Menu {
id: cameraSubmenu
x: addSensorMenu.x - addSensorMenu.width
y: addSensorMenu.y + cameraSensorMenu.y

MenuItem {
id: depth
text: "Depth"
onTriggered: {
ComponentInspector.OnAddEntity("depth_camera", "sensor");
}
}
MenuItem {
id: logical
text: "Logical"
onTriggered: {
ComponentInspector.OnAddEntity("logical_camera", "sensor");
}
}
MenuItem {
id: monocular
text: "Monocular"
onTriggered: {
ComponentInspector.OnAddEntity("camera", "sensor");
}
}
/*MenuItem {
id: multicamera
text: "Multicamera"
onTriggered: {
ComponentInspector.OnAddEntity("multicamera", "sensor");
}
}*/
MenuItem {
id: rgbd
text: "RGBD"
onTriggered: {
ComponentInspector.OnAddEntity("rgbd_camera", "sensor");
}
}
MenuItem {
id: segmentation
text: "Segmentation"
onTriggered: {
ComponentInspector.OnAddEntity("segmentation_camera", "sensor");
}
}
MenuItem {
id: thermal
text: "Thermal"
onTriggered: {
ComponentInspector.OnAddEntity("thermal_camera", "sensor");
}
}
}
}

Expand All @@ -592,7 +759,6 @@ Rectangle {
}
}


ListView {
anchors.top: header.bottom
anchors.bottom: parent.bottom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Rectangle {
fillMode: Image.Pad
Layout.alignment : Qt.AlignVCenter
source: content.show ?
"qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png"
"qrc:/Gazebo/images/chevron-down.svg" : "qrc:/Gazebo/images/chevron-right.svg"
}
TypeHeader {
id: typeHeader
Expand Down
12 changes: 6 additions & 6 deletions src/gui/plugins/component_inspector/Imu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Q_INVOKABLE void Imu::OnLinearAccelerationXNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::Imu>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Imu *imu = comp->Data().ImuSensor();
Expand Down Expand Up @@ -137,7 +137,7 @@ Q_INVOKABLE void Imu::OnLinearAccelerationYNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::Imu>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Imu *imu = comp->Data().ImuSensor();
Expand Down Expand Up @@ -171,7 +171,7 @@ Q_INVOKABLE void Imu::OnLinearAccelerationZNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::Imu>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Imu *imu = comp->Data().ImuSensor();
Expand Down Expand Up @@ -205,7 +205,7 @@ Q_INVOKABLE void Imu::OnAngularVelocityXNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::Imu>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Imu *imu = comp->Data().ImuSensor();
Expand Down Expand Up @@ -239,7 +239,7 @@ Q_INVOKABLE void Imu::OnAngularVelocityYNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::Imu>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Imu *imu = comp->Data().ImuSensor();
Expand Down Expand Up @@ -273,7 +273,7 @@ Q_INVOKABLE void Imu::OnAngularVelocityZNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::Imu>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Imu *imu = comp->Data().ImuSensor();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/component_inspector/JointType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ Q_INVOKABLE void JointType::OnJointType(QString _jointType)
[=](EntityComponentManager &_ecm)
{
components::JointType *comp =
_ecm.Component<components::JointType>(this->inspector->Entity());
_ecm.Component<components::JointType>(this->inspector->GetEntity());

components::ParentEntity *parentComp =
_ecm.Component<components::ParentEntity>(this->inspector->Entity());
_ecm.Component<components::ParentEntity>(this->inspector->GetEntity());

if (comp && parentComp)
{
Expand Down
4 changes: 2 additions & 2 deletions src/gui/plugins/component_inspector/Lidar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Q_INVOKABLE void Lidar::OnLidarNoise(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::GpuLidar>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Lidar *lidar = comp->Data().LidarSensor();
Expand Down Expand Up @@ -120,7 +120,7 @@ Q_INVOKABLE void Lidar::OnLidarChange(
[=](EntityComponentManager &_ecm)
{
auto comp = _ecm.Component<components::GpuLidar>(
this->inspector->Entity());
this->inspector->GetEntity());
if (comp)
{
sdf::Lidar *lidar = comp->Data().LidarSensor();
Expand Down
Loading

0 comments on commit 93893f0

Please sign in to comment.