Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for loading CSV files via the UI #211

Merged
merged 6 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lrauv_ignition_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ add_lrauv_plugin(TimeAnalysisPlugin)
add_lrauv_plugin(WorldCommPlugin
PROTO
lrauv_init)
add_lrauv_plugin(WorldConfigPlugin GUI)

#============================================================================
# Install public headers
Expand Down
2 changes: 1 addition & 1 deletion lrauv_ignition_plugins/src/ScienceSensorsSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -941,4 +941,4 @@ IGNITION_ADD_PLUGIN(
tethys::ScienceSensorsSystem::ISystemPostUpdate)

IGNITION_ADD_PLUGIN_ALIAS(tethys::ScienceSensorsSystem,
"tethys::ScienceSensorsSystem")
"tethys::ScienceSensorsSystem")
70 changes: 70 additions & 0 deletions lrauv_ignition_plugins/src/WorldConfigPlugin.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.
*
*/

/*
* Development of this module has been funded by the Monterey Bay Aquarium
* Research Institute (MBARI) and the David and Lucile Packard Foundation
*/

#include "WorldConfigPlugin.hh"
#include <gz/common/Console.hh>
#include <gz/plugin/Register.hh>

#include <gz/gui/Application.hh>
#include <gz/gui/Conversions.hh>
#include <gz/gui/GuiEvents.hh>
#include <gz/gui/MainWindow.hh>

namespace tethys
{

WorldConfig::WorldConfig() : gz::gui::Plugin()
{
gz::gui::App()->Engine()->rootContext()->setContextProperty(
"WorldConfig", this);
this->pub =
this->node.Advertise<gz::msgs::StringMsg>(
"/world/science_sensor/environment_data_path");
}

WorldConfig::~WorldConfig()
{

}

void WorldConfig::LoadConfig(const tinyxml2::XMLElement *_pluginElem)
{
if (this->title.empty())
this->title = "World Configuration";

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

void WorldConfig::SetFilePath(QUrl _filePath)
{
igndbg << "setting file path " << _filePath.path().toStdString() << std::endl;

gz::msgs::StringMsg msg;
msg.set_data(_filePath.path().toStdString());
this->pub.Publish(msg);
}

}
// Register this plugin
IGNITION_ADD_PLUGIN(tethys::WorldConfig,
gz::gui::Plugin)
60 changes: 60 additions & 0 deletions lrauv_ignition_plugins/src/WorldConfigPlugin.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.
*
*/

/*
* Development of this module has been funded by the Monterey Bay Aquarium
* Research Institute (MBARI) and the David and Lucile Packard Foundation
*/

#ifndef TETHYS_CONTROLPANEL_HH_
#define TETHYS_CONTROLPANEL_HH_

#include <gz/gui/Plugin.hh>

#include <gz/transport/Node.hh>

namespace tethys
{

/// \brief Control Panel for controlling the tethys using the GUI.
class WorldConfig : public gz::gui::Plugin
{
Q_OBJECT

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

/// \brief Destructor
public: ~WorldConfig();

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

/// \brief Set the file path to be loaded
/// \param[in] _filePath The file path to be loaded
public: Q_INVOKABLE void SetFilePath(QUrl _filePath);

/// \brief Transport node
private: gz::transport::Node node;

/// \brief Transport publisher
private: gz::transport::Node::Publisher pub;
};

}

#endif
65 changes: 65 additions & 0 deletions lrauv_ignition_plugins/src/WorldConfigPlugin.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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.
*
*/


/*
* Development of this module has been funded by the Monterey Bay Aquarium
* Research Institute (MBARI) and the David and Lucile Packard Foundation
*/

import QtQuick 2.9
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.0

GridLayout {
id: mainLayout
columns: 5
rowSpacing: 2
columnSpacing: 2
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10
Layout.minimumWidth: 400
Layout.minimumHeight: 300

Label {
text: "Load Environment Data CSV"
Layout.columnSpan: 3
}
Button {
id: vehicleNameValue
Layout.columnSpan: 2
Layout.fillWidth: true
text: "Browse files..."
onClicked: fileDialog.open()
}

FileDialog {
id: fileDialog
title: "Please choose a file"
folder: shortcuts.home
visible: false
onAccepted: {
WorldConfig.SetFilePath(fileDialog.fileUrl)
}
onRejected: {
}
//Component.onCompleted: visible = true
}
}
5 changes: 5 additions & 0 deletions lrauv_ignition_plugins/src/WorldConfigPlugin.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="WorldConfigPlugin">
<file>WorldConfigPlugin.qml</file>
</qresource>
</RCC>
8 changes: 8 additions & 0 deletions lrauv_ignition_plugins/worlds/buoyant_tethys.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@
<topic>/tethys/navsat</topic>
<topic_picker>true</topic_picker>
</plugin>

<!-- Sensor Data Map -->
<plugin filename="WorldConfigPlugin" name="Environmental Configuration">
<ignition-gui>
<title>Environmental Configuration</title>
<property type="string" key="state">docked_collapsed</property>
</ignition-gui>
</plugin>
</gui>

<light type="directional" name="sun">
Expand Down
8 changes: 8 additions & 0 deletions lrauv_ignition_plugins/worlds/empty_environment.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@
<topic>/tethys/navsat</topic>
<topic_picker>true</topic_picker>
</plugin>

<!-- Sensor Data Map -->
<plugin filename="WorldConfigPlugin" name="Environmental Configuration">
<ignition-gui>
<title>Environmental Configuration</title>
<property type="string" key="state">docked_collapsed</property>
</ignition-gui>
</plugin>
</gui>

<light type="directional" name="sun">
Expand Down
7 changes: 7 additions & 0 deletions lrauv_ignition_plugins/worlds/portuguese_ledge.sdf.em
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ for tile in tiles:
<property type="string" key="state">docked_collapsed</property>
</ignition-gui>
</plugin>
<!-- Sensor Data Map -->
<plugin filename="WorldConfigPlugin" name="Environmental Configuration">
<ignition-gui>
<title>Environmental Configuration</title>
<property type="string" key="state">docked_collapsed</property>
</ignition-gui>
</plugin>
<plugin filename="SpawnPanelPlugin" name="Spawn LRAUV Panel">
<ignition-gui>
<title>Spawn LRAUVs</title>
Expand Down