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

Populate plugins that were empty #366

Merged
merged 3 commits into from
Mar 4, 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
13 changes: 13 additions & 0 deletions src/plugins/camera_tracking/CameraTracking.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ namespace plugins
{
class CameraTrackingPrivate;

/// \brief This plugin provides camera tracking capabilities such as "move to"
/// and "follow".
///
/// Services:
/// * `/gui/move_to`: Move the user camera to look at a given target,
/// identified by name.
/// * `/gui/move_to/pose`: Move the user camera to a given pose.
/// * `/gui/follow`: Set the user camera to follow a given target,
/// identified by name.
/// * `/gui/follow/offset`: Set the offset for following.
///
/// Topics:
/// * `/gui/camera/pose`: Publishes the current user camera pose.
class CameraTracking : public Plugin
{
Q_OBJECT
Expand Down
33 changes: 25 additions & 8 deletions src/plugins/camera_tracking/CameraTracking.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,31 @@
*
*/

import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick 2.9
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3

// TODO: remove invisible rectangle, see
// https://github.com/ignitionrobotics/ign-gui/issues/220
Rectangle {
visible: false
Layout.minimumWidth: 100
Layout.minimumHeight: 100
ColumnLayout {
Layout.minimumWidth: 350
Layout.minimumHeight: 260
anchors.fill: parent
anchors.margins: 10

property string message: 'Services provided:<br><ul>' +
'<li>/gui/move_to</li>' +
'<li>/gui/move_to/pose</li>' +
'<li>/gui/follow</li>' +
'<li>/gui/follow/offset</li></ul><br>Topics provided:<br><ul>' +
'<li>/gui/camera/pose</li></ul>'

Label {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: message
}

Item {
width: 10
Layout.fillHeight: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ InteractiveViewControl::~InteractiveViewControl() = default;
void InteractiveViewControl::LoadConfig(
const tinyxml2::XMLElement * /*_pluginElem*/)
{
if (this->title.empty())
this->title = "Interactive view control";

// camera view control mode
this->dataPtr->cameraViewControlService = "/gui/camera/view_control";
this->dataPtr->node.Advertise(this->dataPtr->cameraViewControlService,
Expand Down
29 changes: 21 additions & 8 deletions src/plugins/interactive_view_control/InteractiveViewControl.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,27 @@
*
*/

import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick 2.9
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3

// TODO: remove invisible rectangle, see
// https://github.com/ignitionrobotics/ign-gui/issues/220
Rectangle {
visible: false
Layout.minimumWidth: 100
Layout.minimumHeight: 100
ColumnLayout {
Layout.minimumWidth: 350
Layout.minimumHeight: 110
anchors.fill: parent
anchors.margins: 10

property string message: '<ul><li>Adding mouse controls to the 3D scene.</li>' +
'<li>Providing the /gui/camera/view_control service</li></ul>'

Label {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: message
}

Item {
width: 10
Layout.fillHeight: true
}
}
88 changes: 48 additions & 40 deletions src/plugins/marker_manager/MarkerManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <map>
#include <string>

#include <QQmlProperty>

#include <ignition/common/Console.hh>
#include <ignition/common/Profiler.hh>
#include <ignition/common/StringUtils.hh>
Expand Down Expand Up @@ -677,6 +679,7 @@ void MarkerManager::LoadConfig(const tinyxml2::XMLElement * _pluginElem)
this->title = "Marker Manager";

// Custom parameters
std::string statsTopic;
if (_pluginElem)
{
auto elem = _pluginElem->FirstChildElement("topic_name");
Expand Down Expand Up @@ -704,59 +707,64 @@ void MarkerManager::LoadConfig(const tinyxml2::XMLElement * _pluginElem)
}
}

// World name from window, to construct default topics and services
std::string worldName = "example";
auto worldNames = gui::worldNames();
if (!worldNames.empty())
worldName = worldNames[0].toStdString();

// Subscribe to world stats
std::string statsTopic;
// Stats topic
auto statsTopicElem = _pluginElem->FirstChildElement("stats_topic");
if (nullptr != statsTopicElem && nullptr != statsTopicElem->GetText())
statsTopic = statsTopicElem->GetText();
}

// Service specified with different world name
auto parts = common::Split(statsTopic, '/');
if (!worldName.empty() &&
parts.size() == 4 &&
parts[0] == "" &&
parts[1] == "world" &&
parts[2] != worldName &&
parts[3] == "stats")
{
ignwarn << "Ignoring topic [" << statsTopic
<< "], world name different from [" << worldName
<< "]. Fix or remove your <stats_topic> tag." << std::endl;
// World name from window, to construct default topics and services
std::string worldName = "example";
auto worldNames = gui::worldNames();
if (!worldNames.empty())
worldName = worldNames[0].toStdString();

// Subscribe to world stats
// Service specified with different world name
auto parts = common::Split(statsTopic, '/');
if (!worldName.empty() &&
parts.size() == 4 &&
parts[0] == "" &&
parts[1] == "world" &&
parts[2] != worldName &&
parts[3] == "stats")
{
ignwarn << "Ignoring topic [" << statsTopic
<< "], world name different from [" << worldName
<< "]. Fix or remove your <stats_topic> tag." << std::endl;

statsTopic = "/world/" + worldName + "/stats";
}
statsTopic = "/world/" + worldName + "/stats";
}

if (statsTopic.empty() && !worldName.empty())
{
statsTopic = "/world/" + worldName + "/stats";
}
if (statsTopic.empty() && !worldName.empty())
{
statsTopic = "/world/" + worldName + "/stats";
}

statsTopic = transport::TopicUtils::AsValidTopic(statsTopic);
if (!statsTopic.empty())
statsTopic = transport::TopicUtils::AsValidTopic(statsTopic);
if (!statsTopic.empty())
{
// Subscribe to world_stats
if (!this->dataPtr->node.Subscribe(statsTopic,
&MarkerManagerPrivate::OnWorldStatsMsg, this->dataPtr.get()))
{
// Subscribe to world_stats
if (!this->dataPtr->node.Subscribe(statsTopic,
&MarkerManagerPrivate::OnWorldStatsMsg, this->dataPtr.get()))
{
ignerr << "Failed to subscribe to [" << statsTopic << "]" << std::endl;
}
else
{
ignmsg << "Listening to stats on [" << statsTopic << "]" << std::endl;
}
ignerr << "Failed to subscribe to [" << statsTopic << "]" << std::endl;
}
else
{
ignerr << "Failed to create valid topic for world [" << worldName << "]"
<< std::endl;
ignmsg << "Listening to stats on [" << statsTopic << "]" << std::endl;
}
}
else
{
ignerr << "Failed to create valid topic for world [" << worldName << "]"
<< std::endl;
}

QQmlProperty::write(this->PluginItem(), "topicName",
QString::fromStdString(this->dataPtr->topicName));
QQmlProperty::write(this->PluginItem(), "statsTopic",
QString::fromStdString(statsTopic));

App()->findChild<MainWindow *>()->installEventFilter(this);
}
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/marker_manager/MarkerManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ namespace plugins
{
class MarkerManagerPrivate;

/// \brief This plugin will be in charge of handeling the markers in the
/// \brief This plugin will be in charge of handling the markers in the
/// scene. It will allow to add, modify or remove markers.
///
/// ## Parameters
///
/// * `<topic_name>`: Options. Name of topic for marker service. Defaults
/// * `<topic_name>`: Optional. Name of topic for marker service. Defaults
/// to `/marker`.
/// * `<stats_topic>`: Optional. Name of topic to receive world stats.
/// Defaults to `/world/[world name]/stats`.
/// * `<warn_on_action_failure>`: True to display warnings if the user
/// attempts to perform an invalid action. Defaults to true.
class MarkerManager : public Plugin
Expand Down
35 changes: 27 additions & 8 deletions src/plugins/marker_manager/MarkerManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,33 @@
*
*/

import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick 2.9
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3

// TODO: remove invisible rectangle, see
// https://github.com/ignitionrobotics/ign-gui/issues/220
Rectangle {
visible: false
Layout.minimumWidth: 100
Layout.minimumHeight: 100
ColumnLayout {
Layout.minimumWidth: 350
Layout.minimumHeight: 230
anchors.fill: parent
anchors.margins: 10

property string topicName: ''
property string statsTopic: ''

property string message: 'Services provided:<br><ul>' +
'<li>' + topicName + '</li>' +
'<li>' + topicName + '_array</li>' +
'<li>' + topicName + '/list</li></ul><br>Topics subscribed:<br><ul>' +
'<li>' + statsTopic + '</li></ul>'

Label {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: message
}

Item {
width: 10
Layout.fillHeight: true
}
}