From ac1089278a063cfddc9b1322d1abcbb1ce760c00 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 9 Feb 2021 09:48:45 -0800 Subject: [PATCH 1/2] Make topics configurable for joint controllers (#584) Signed-off-by: Louise Poubel --- examples/worlds/joint_position_controller.sdf | 7 ++++--- src/systems/joint_controller/JointController.cc | 4 ++++ .../joint_position_controller/JointPositionController.cc | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/worlds/joint_position_controller.sdf b/examples/worlds/joint_position_controller.sdf index 6d2ad62e83f..b2bd1045097 100644 --- a/examples/worlds/joint_position_controller.sdf +++ b/examples/worlds/joint_position_controller.sdf @@ -4,9 +4,9 @@ Try sending joint position commands: - ign topic -t "/model/joint_position_controller_demo/joint/j1/0/cmd_pos" -m ignition.msgs.Double -p "data: -1.0" + ign topic -t "/rotor_cmd" -m ignition.msgs.Double -p "data: -1.0" - ign topic -t "/model/joint_position_controller_demo/joint/j1/0/cmd_pos" -m ignition.msgs.Double -p "data: 1.0" + ign topic -t "/rotor_cmd" -m ignition.msgs.Double -p "data: 1.0" --> @@ -45,7 +45,7 @@ 72 121 1 - + floating @@ -156,6 +156,7 @@ filename="ignition-gazebo-joint-position-controller-system" name="ignition::gazebo::systems::JointPositionController"> j1 + rotor_cmd 1 0.1 0.01 diff --git a/src/systems/joint_controller/JointController.cc b/src/systems/joint_controller/JointController.cc index 42990d44477..695ee62d6db 100644 --- a/src/systems/joint_controller/JointController.cc +++ b/src/systems/joint_controller/JointController.cc @@ -133,6 +133,10 @@ void JointController::Configure(const Entity &_entity, // Subscribe to commands std::string topic{"/model/" + this->dataPtr->model.Name(_ecm) + "/joint/" + this->dataPtr->jointName + "/cmd_vel"}; + if (_sdf->HasElement("topic")) + { + topic = _sdf->Get("topic"); + } this->dataPtr->node.Subscribe(topic, &JointControllerPrivate::OnCmdVel, this->dataPtr.get()); diff --git a/src/systems/joint_position_controller/JointPositionController.cc b/src/systems/joint_position_controller/JointPositionController.cc index c048ff0e236..691336d901f 100644 --- a/src/systems/joint_position_controller/JointPositionController.cc +++ b/src/systems/joint_position_controller/JointPositionController.cc @@ -150,6 +150,10 @@ void JointPositionController::Configure(const Entity &_entity, std::string topic{"/model/" + this->dataPtr->model.Name(_ecm) + "/joint/" + this->dataPtr->jointName + "/" + std::to_string(this->dataPtr->jointIndex) + "/cmd_pos"}; + if (_sdf->HasElement("topic")) + { + topic = _sdf->Get("topic"); + } this->dataPtr->node.Subscribe( topic, &JointPositionControllerPrivate::OnCmdPos, this->dataPtr.get()); From 87b2f4ba27cc10a1a586bda8d635aa929e1070ce Mon Sep 17 00:00:00 2001 From: Atharva Pusalkar Date: Thu, 11 Feb 2021 02:48:59 +0530 Subject: [PATCH 2/2] Add About dialog (#609) Signed-off-by: atharva-18 --- src/gui/AboutDialogHandler.cc | 67 ++++++++++++++++++++++++++++++ src/gui/AboutDialogHandler.hh | 58 ++++++++++++++++++++++++++ src/gui/CMakeLists.txt | 1 + src/gui/Gui.cc | 5 +++ src/gui/resources/GazeboDrawer.qml | 55 +++++++++++++++++++----- 5 files changed, 176 insertions(+), 10 deletions(-) create mode 100644 src/gui/AboutDialogHandler.cc create mode 100644 src/gui/AboutDialogHandler.hh diff --git a/src/gui/AboutDialogHandler.cc b/src/gui/AboutDialogHandler.cc new file mode 100644 index 00000000000..545f6fbb66f --- /dev/null +++ b/src/gui/AboutDialogHandler.cc @@ -0,0 +1,67 @@ +/* + * 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 "AboutDialogHandler.hh" + +#include +#include +#include + +using namespace ignition; +using namespace gazebo; +using namespace gazebo::gui; + +///////////////////////////////////////////////// +AboutDialogHandler::AboutDialogHandler() +{ + aboutText += std::string(IGNITION_GAZEBO_VERSION_HEADER); + aboutText += "" + "" + "" + "" + "" + "" + "" + "" + "" + "
Documentation:" + "" + "" + "https://ignitionrobotics.org/libs/gazebo" + "" + "
" + "Tutorials:" + "" + "" + "https://ignitionrobotics.org/docs/" + "" + "
"; +} + +///////////////////////////////////////////////// +QString AboutDialogHandler::getVersionInformation() +{ + return QString::fromStdString(this->aboutText); +} + +///////////////////////////////////////////////// +void AboutDialogHandler::openURL(QString _url) +{ + QDesktopServices::openUrl(QUrl(_url)); +} diff --git a/src/gui/AboutDialogHandler.hh b/src/gui/AboutDialogHandler.hh new file mode 100644 index 00000000000..b5f71b543df --- /dev/null +++ b/src/gui/AboutDialogHandler.hh @@ -0,0 +1,58 @@ +/* + * 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_ABOUTDIALOGHANDLER_HH_ +#define IGNITION_GAZEBO_GUI_ABOUTDIALOGHANDLER_HH_ + +#include +#include +#include + +#include "ignition/gazebo/EntityComponentManager.hh" +#include "ignition/gazebo/Export.hh" + +namespace ignition +{ +namespace gazebo +{ +// Inline bracket to help doxygen filtering. +inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE { +namespace gui +{ +/// \brief Class for handling about dialog +class IGNITION_GAZEBO_VISIBLE AboutDialogHandler : public QObject +{ + Q_OBJECT + + /// \brief Constructor + public: AboutDialogHandler(); + + /// \brief Get version information + /// \return Version information in rich text format + Q_INVOKABLE QString getVersionInformation(); + + /// \brief Function called from QML when user clicks on a link + /// \param[in] _url Url to web page. + Q_INVOKABLE void openURL(QString _url); + + /// \brief Version information and links to online resources + private: std::string aboutText; +}; +} +} +} +} +#endif diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 5d536223228..46d4be7f5c2 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,4 +1,5 @@ set (gui_sources + AboutDialogHandler.cc Gui.cc GuiFileHandler.cc GuiRunner.cc diff --git a/src/gui/Gui.cc b/src/gui/Gui.cc index 00c3b7215f3..04340d116d6 100644 --- a/src/gui/Gui.cc +++ b/src/gui/Gui.cc @@ -28,6 +28,7 @@ #include "ignition/gazebo/gui/TmpIface.hh" #include "ignition/gazebo/gui/Gui.hh" +#include "AboutDialogHandler.hh" #include "GuiFileHandler.hh" #include "PathManager.hh" @@ -63,6 +64,9 @@ std::unique_ptr createGui( auto tmp = new ignition::gazebo::TmpIface(); tmp->setParent(app->Engine()); + auto aboutDialogHandler = new ignition::gazebo::gui::AboutDialogHandler(); + aboutDialogHandler->setParent(app->Engine()); + auto guiFileHandler = new ignition::gazebo::gui::GuiFileHandler(); guiFileHandler->setParent(app->Engine()); @@ -102,6 +106,7 @@ std::unique_ptr createGui( // Let QML files use TmpIface' functions and properties auto context = new QQmlContext(app->Engine()->rootContext()); context->setContextProperty("TmpIface", tmp); + context->setContextProperty("AboutDialogHandler", aboutDialogHandler); context->setContextProperty("GuiFileHandler", guiFileHandler); // Instantiate GazeboDrawer.qml file into a component diff --git a/src/gui/resources/GazeboDrawer.qml b/src/gui/resources/GazeboDrawer.qml index 8ca3f273a76..647883da349 100644 --- a/src/gui/resources/GazeboDrawer.qml +++ b/src/gui/resources/GazeboDrawer.qml @@ -60,6 +60,9 @@ Rectangle { case "loadWorld": loadWorldDialog.open(); break + case "aboutDialog": + aboutDialog.open(); + break // Forward others to default drawer default: parent.onAction(_action); @@ -73,46 +76,50 @@ Rectangle { // Custom action which calls custom C++ code /*ListElement { title: "New world" - action: "newWorld" + actionElement: "newWorld" type: "world" } ListElement { title: "Load world" - action: "loadWorld" + actionElement: "loadWorld" type: "world" }*/ ListElement { title: "Save world" - action: "saveWorld" + actionElement: "saveWorld" enabled: false type: "world" } ListElement { title: "Save world as..." - action: "saveWorldAs" + actionElement: "saveWorldAs" type: "world" } // Actions provided by Ignition GUI, with custom titles ListElement { title: "Load client configuration" - action: "loadConfig" + actionElement: "loadConfig" } ListElement { title: "Save client configuration" - action: "saveConfig" + actionElement: "saveConfig" } ListElement { title: "Save client configuration as" - action: "saveConfigAs" + actionElement: "saveConfigAs" } ListElement { title: "Style settings" - action: "styleSettings" + actionElement: "styleSettings" + } + ListElement { + title: "About" + actionElement: "aboutDialog" } ListElement { title: "Quit" - action: "close" + actionElement: "close" } } @@ -125,7 +132,7 @@ Rectangle { text: title highlighted: ListView.isCurrentItem onClicked: { - customDrawer.onAction(action); + customDrawer.onAction(actionElement); customDrawer.parent.closeDrawer(); } } @@ -165,6 +172,34 @@ Rectangle { } } + /** + * About dialog + */ + Dialog { + id: aboutDialog + title: "Ignition Gazebo" + + modal: true + focus: true + parent: ApplicationWindow.overlay + width: parent.width / 3 > 500 ? 500 : parent.width / 3 + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + closePolicy: Popup.CloseOnEscape + standardButtons: StandardButton.Ok + + Text { + anchors.fill: parent + id: aboutMessage + wrapMode: Text.Wrap + verticalAlignment: Text.AlignVCenter + color: Material.theme == Material.Light ? "black" : "white" + textFormat: Text.RichText + text: AboutDialogHandler.getVersionInformation() + onLinkActivated: AboutDialogHandler.openURL(link) + } + } + /** * Dialog with configurations for SDF generation */