-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added graph queries getTopicNamesAndTypes, getServiceNamesAndTypes an…
…d getActionNamesAndTypes to Ros2 singleton.
- Loading branch information
1 parent
b740c78
commit b30874c
Showing
4 changed files
with
236 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import QtQuick 2.6 | ||
import QtQuick.Controls 2.2 | ||
import QtQuick.Controls.Material 2.2 | ||
import QtQuick.Layouts 1.0 | ||
import Ros2 1.0 | ||
|
||
ApplicationWindow { | ||
id: page | ||
width: 620 | ||
height: 400 | ||
|
||
// This connection makes sure the application exits if this ROS node is requested to shutdown | ||
Connections { | ||
target: Ros2 | ||
function onShutdown() { | ||
Qt.quit() | ||
} | ||
} | ||
property var topics: ({}) | ||
property var services: ({}) | ||
property var actions: ({}) | ||
|
||
function update() { | ||
Ros2.info("Updating.") | ||
topics = Ros2.getTopicNamesAndTypes() | ||
services = Ros2.getServiceNamesAndTypes() | ||
actions = Ros2.getActionNamesAndTypes() | ||
} | ||
function printNamesAndTypes(map) { | ||
let result = "" | ||
for (let key in map) { | ||
result += key + ": " + map[key] + "\n" | ||
} | ||
return result | ||
} | ||
|
||
ScrollView { | ||
anchors.fill: parent | ||
|
||
ColumnLayout { | ||
anchors.margins: 12 | ||
|
||
|
||
Button { | ||
Layout.columnSpan: 3 | ||
text: "Update" | ||
onClicked: page.update() | ||
} | ||
|
||
Text { | ||
text: "Topics:" | ||
} | ||
Text { | ||
leftPadding: 12 | ||
text: printNamesAndTypes(topics) | ||
} | ||
Text { | ||
text: "Services:" | ||
} | ||
Text { | ||
leftPadding: 12 | ||
text: printNamesAndTypes(services) | ||
} | ||
Text { | ||
text: "Actions:" | ||
} | ||
Text { | ||
leftPadding: 12 | ||
text: printNamesAndTypes(actions) | ||
} | ||
} | ||
} | ||
|
||
Component.onCompleted: { | ||
// Initialize ROS with the given name. The command line args are passed by the plugin | ||
// Optionally, you can call init with a string list ["arg1", "arg2"] after the name to use those | ||
// args instead of the ones supplied by the command line. | ||
Ros2.init("qml_graph_queries_demo") | ||
update() | ||
} | ||
|
||
} |
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