Skip to content

Commit

Permalink
Add acoustic environment vis scaffolding
Browse files Browse the repository at this point in the history
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
  • Loading branch information
arjo129 committed Sep 23, 2022
1 parent d96e226 commit 8ae371d
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/gui/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ add_subdirectory(copy_paste)
add_subdirectory(entity_context_menu)
add_subdirectory(entity_tree)
add_subdirectory(environment_loader)
add_subdirectory(environment_visualization)
add_subdirectory(joint_position_controller)
add_subdirectory(lights)
add_subdirectory(playback_scrubber)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/plugins/environment_loader/EnvironmentLoader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ GridLayout {
Layout.fillWidth: true
enabled: EnvironmentLoader.configured
model: EnvironmentLoader.referenceList
currentText: EnvironmentLoader.reference
//currentText: EnvironmentLoader.reference
onCurrentTextChanged: {
EnvironmentLoader.reference = currentText
}
Expand Down
8 changes: 8 additions & 0 deletions src/gui/plugins/environment_visualization/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
gz_add_gui_plugin(EnvironmentVisualization
SOURCES EnvironmentVisualization.cc
QT_HEADERS EnvironmentVisualization.hh
PRIVATE_LINK_LIBS
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
gz-common${GZ_COMMON_VER}::io
gz-math${GZ_MATH_VER}::gz-math${GZ_MATH_VER}
)
105 changes: 105 additions & 0 deletions src/gui/plugins/environment_visualization/EnvironmentVisualization.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (C) 2022 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 "EnvironmentVisualization.hh"

#include <gz/gui/Application.hh>
#include <gz/gui/MainWindow.hh>
#include <gz/sim/components/Environment.hh>
#include <gz/sim/Util.hh>

#include <gz/plugin/Register.hh>

#include <atomic>
#include <mutex>
#include <string>
#include <utility>
#include <vector>

#include <gz/common/CSVStreams.hh>
#include <gz/common/DataFrame.hh>

using namespace gz;
using namespace sim;

namespace gz
{
namespace sim
{
inline namespace GZ_SIM_VERSION_NAMESPACE
{
/// \brief Private data class for EnvironmentVisualization
class EnvironmentVisualizationPrivate
{
/// \brief To synchronize member access.
public: std::mutex mutex;

/// \brief Whether to attempt an environmental data load.
public: std::atomic<bool> needsLoad{false};

/// \brief Setup publishers
public:

/// \brief first load we need to scan for existing data sensor
public: bool first;
};
}
}
}

/////////////////////////////////////////////////
EnvironmentVisualization::EnvironmentVisualization()
: GuiSystem(), dataPtr(new EnvironmentVisualizationPrivate)
{
gui::App()->Engine()->rootContext()->setContextProperty(
"EnvironmentVisualization", this);
}

/////////////////////////////////////////////////
EnvironmentVisualization::~EnvironmentVisualization()
{
}

/////////////////////////////////////////////////
void EnvironmentVisualization::LoadConfig(const tinyxml2::XMLElement *)
{
if (this->title.empty())
this->title = "Environment Visualization Resolution";

gui::App()->findChild<gui::MainWindow *>()->installEventFilter(this);
}

/////////////////////////////////////////////////
void EnvironmentVisualization::Update(const UpdateInfo &,
EntityComponentManager &_ecm)
{
_ecm.EachNew<components::Environment>(
[](
const Entity &_entity,
const components::Environment* environment
) {

}
);

auto environData =
_ecm.Component<components::Environment>(
worldEntity(_ecm));
}

// Register this plugin
GZ_ADD_PLUGIN(gz::sim::EnvironmentVisualization, gz::gui::Plugin)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2022 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 GZ_SIM_GUI_ENVIRONMENTVISUALIZATION_HH_
#define GZ_SIM_GUI_ENVIRONMENTVISUALIZATION_HH_

#include <memory>

#include "gz/sim/gui/GuiSystem.hh"
#include "gz/gui/qt.h"

namespace gz
{
namespace sim
{
// Inline bracket to help doxygen filtering.
inline namespace GZ_SIM_VERSION_NAMESPACE
{
class EnvironmentVisualizationPrivate;

/// \class EnvironmentVisualization EnvironmentVisualization.hh
/// gz/sim/systems/EnvironmentVisualization.hh
/// \brief A GUI plugin for a user to load an Environment
/// component into the ECM on a live simulation.
class EnvironmentVisualization : public gz::sim::GuiSystem
{
Q_OBJECT

/// \brief Constructor
public: EnvironmentVisualization();

/// \brief Destructor
public: ~EnvironmentVisualization() override;

// Documentation inherited
public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;

// Documentation inherited
public: void Update(const UpdateInfo &,
EntityComponentManager &_ecm) override;

/// \internal
/// \brief Pointer to private data
private: std::unique_ptr<EnvironmentVisualizationPrivate> dataPtr;
};
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2022 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.
*
*/
import QtQuick 2.9
import QtQuick.Controls 2.1
import QtQuick.Dialogs 1.0
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
import "qrc:/qml"


GridLayout {
columns: 8
columnSpacing: 10
Layout.minimumWidth: 350
Layout.minimumHeight: 400
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10

Label {
Layout.row: 0
Layout.columnSpan: 8
horizontalAlignment: Text.AlignCenter
id: instructionLabel
color: "dimgrey"
text: qsTr("For the actual pointcloud please open the point_cloud panel")
}

Label {
Layout.row: 1
Layout.columnSpan: 2
horizontalAlignment: Text.AlignRight
id: dimensionLabelX
color: "dimgrey"
text: qsTr("X resolution")
}

Slider {
Layout.row: 1
Layout.column: 2
Layout.columnSpan: 6
id: stepSliderX
from: 10
value: 2
to: 1000
}

Label {
Layout.row: 2
Layout.columnSpan: 2
horizontalAlignment: Text.AlignRight
id: dimensionLabelY
color: "dimgrey"
text: qsTr("Y resolution")
}

Slider {
Layout.row: 2
Layout.column: 2
Layout.columnSpan: 6
id: stepSliderY
from: 10
value: 2
to: 1000
}

Label {
Layout.row: 3
Layout.columnSpan: 2
horizontalAlignment: Text.AlignRight
id: dimensionLabelZ
color: "dimgrey"
text: qsTr("Z resolution")
}

Slider {
Layout.row: 3
Layout.column: 2
Layout.columnSpan: 6
id: stepSliderZ
from: 10
value: 2
to: 1000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="EnvironmentVisualization">
<file>EnvironmentVisualization.qml</file>
</qresource>
</RCC>

0 comments on commit 8ae371d

Please sign in to comment.