Skip to content

Commit fcb83bc

Browse files
Support ROS 2 Easy Mode (#255)
* Refs #22871: Add advance options submenu Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Send easy mode info to backend Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Change Advance options button style Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Prevent accepting the dialog with invalid values using Enter key Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Add documentation Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Remove flags Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Update Release notes Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Fix SyncBackendConnection::init_monitor Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Fix compilation with BUILD_MOCK=ON Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #22871: Fix spelling. Signed-off-by: Carlosespicur <carlosespicur@proton.me> --------- Signed-off-by: Carlosespicur <carlosespicur@proton.me>
1 parent 3b98af8 commit fcb83bc

File tree

14 files changed

+260
-27
lines changed

14 files changed

+260
-27
lines changed
Loading

docs/rst/getting_started/monitor.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ No prior knowledge of the network or its architecture is required in order to cr
4040
monitor that connects with the *Participants* already running in the same network.
4141
In order to configure this kind of Domain monitoring, only the number of the Domain that is
4242
going to be tracked is needed.
43+
Additional options can be configured using the *Advanced Options* button (see :ref:`monitor_advanced_configuration`).
4344

4445
.. _discovery_server_monitor:
4546

@@ -70,3 +71,20 @@ In order to clarify how to set this parameter, please visit the
7071
`Discovery Server CLI tutorial <https://fast-dds.docs.eprosima.com/en/latest/fastddscli/cli/cli.html#discovery>`_.
7172
The parameter of the Discovery Server *Init New Monitor* button in this application will be used additionally as the
7273
input to the CLI command.
74+
75+
.. _monitor_advanced_configuration:
76+
77+
Advanced Options
78+
================
79+
*Fast DDS Monitor* allows configuring additional parameters using
80+
the *Advanced Options* button in the *Initialize Monitor* dialog.
81+
82+
In case of enabling some of the supported advanced options, *OK* button will be enabled only if all inputs are correct,
83+
so user must ensure of introducing the right values.
84+
85+
The list of supported advanced options is the following:
86+
87+
- **Easy Mode**:
88+
It allows the user to specify the IP address of the remote discovery server used in a
89+
`ROS 2 Easy Mode <https://docs.vulcanexus.org/en/latest/rst/enhancements/easy_mode/easy_mode.html>`_ scenario.
90+
In case of enabling this option, the user must introduce a valid IPv4 address in the text input.

docs/rst/notes/forthcoming_version.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@
55
###################
66
Forthcoming Version
77
###################
8+
9+
This release include the following **major changes**:
10+
11+
* Add support to configure ROS 2 Easy Mode.
12+
13+
- New Advanced Options submenu added to Initialize Monitor dialog.
14+
- Easy Mode option added to Advanced Options submenu.
15+
User can specify the IPv4 address of the remote discovery server used in a ROS 2 Easy Mode scenario.

docs/rst/notes/notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _release_notes:
22

33
.. TODO uncomment when there are forthcoming notes
4-
.. .. include:: forthcoming_version.rst
4+
.. include:: forthcoming_version.rst
55

66
##############
77
Version v3.1.0

docs/rst/spelling_wordlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ eProsima
2121
Foonathan
2222
gtest
2323
GTest
24+
IPv
2425
localhost
2526
metatraffic
2627
middleware
@@ -31,6 +32,7 @@ QoS
3132
resizable
3233
ros
3334
scalable
35+
submenu
3436
subpanel
3537
subpanels
3638
Todo

include/fastdds_monitor/Controller.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define _EPROSIMA_FASTDDS_MONITOR_CONTROLLER_H
2424

2525
#include <QDebug>
26+
#include <QMap>
2627
#include <QObject>
2728
#include <QtCharts/QVXYModelMapper>
2829

@@ -80,7 +81,8 @@ public slots:
8081

8182
//! Slot called by init a monitor with a domain number
8283
void init_monitor(
83-
int domain);
84+
int domain,
85+
QVariantMap advanced_options);
8486

8587
//! Slot called when initializing a monitor for a Discovery Server network
8688
void init_monitor(

include/fastdds_monitor/Engine.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ class Engine : public QQmlApplicationEngine
141141
/**
142142
* @brief Initialize a monitor in a domain by number
143143
* @param domain number of the domain
144+
* @param easy_mode_ip IP address of the remote discovery server used in ROS2 Easy Mode.
144145
*/
145146
void init_monitor(
146-
int domain);
147+
int domain,
148+
std::string easy_mode_ip = "");
147149

148150
/**
149151
* @brief Initialize a monitor in a domain by discovery server locators

include/fastdds_monitor/backend/SyncBackendConnection.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ class SyncBackendConnection
7878
* Calls the Backend \c init_monitor method in order to initialize a new monitor in a new Domain
7979
*
8080
* @param domain new domain number
81+
* @param easy_mode_ip IP address of the remote discovery server used in ROS2 Easy Mode.
8182
* @return EntityId of the new Domain Entity created
8283
*/
8384
EntityId init_monitor(
84-
int domain);
85+
int domain,
86+
std::string easy_mode_ip = "");
8587

8688
/**
8789
* @brief Init a monitor by setting a string with one or many locators of Discovery Servers

mock/complex_mock/StatisticsBackend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ EntityId StatisticsBackend::init_monitor(
7272
CallbackMask callback_mask,
7373
DataKindMask data_mask,
7474
std::string app_id,
75-
std::string app_metadata)
75+
std::string app_metadata,
76+
std::string easy_mode_ip)
7677
{
78+
static_cast<void>(easy_mode_ip);
7779
return init_monitor(std::to_string(domain), domain_listener, callback_mask, data_mask, app_id, app_metadata);
7880
}
7981

mock/static_mock/StatisticsBackend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ EntityId StatisticsBackend::init_monitor(
9090
CallbackMask callback_mask,
9191
DataKindMask data_mask,
9292
std::string app_id,
93-
std::string app_metadata)
93+
std::string app_metadata,
94+
std::string easy_mode_ip)
9495
{
9596
static_cast<void>(domain);
9697
static_cast<void>(domain_listener);
9798
static_cast<void>(callback_mask);
9899
static_cast<void>(data_mask);
99100
static_cast<void>(app_id);
100101
static_cast<void>(app_metadata);
102+
static_cast<void>(easy_mode_ip);
101103
return EntityId(++ID);
102104
}
103105

qml/InitMonitorDialog.qml

Lines changed: 199 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,215 @@ import Theme 1.0
2323

2424
Dialog {
2525
id: dialogInitMonitor
26+
27+
readonly property int layout_vertical_spacing_: 10 // vertical spacing between the components in a row
28+
readonly property int layout_horizontal_spacing_: 15 // horizontal spacing between rows
29+
readonly property int item_height_: 40 // Height of header item and each item of
30+
// advanced options submenu (title + options)
31+
readonly property int dialog_width_: 300 // Width of the dialog
32+
2633
modal: true
27-
title: "Initialize Monitor"
28-
standardButtons: Dialog.Ok | Dialog.Cancel
34+
35+
header: Item {
36+
width: parent.width
37+
height: item_height_
38+
Rectangle {
39+
color: "transparent"
40+
width: parent.width
41+
height: parent.height
42+
Text {
43+
topPadding: 5
44+
text: "Initialize Monitor"
45+
font.pointSize: 15
46+
anchors.centerIn: parent
47+
}
48+
}
49+
}
50+
51+
footer: DialogButtonBox {
52+
id: dialogButtons
53+
standardButtons: Dialog.Ok | Dialog.Cancel
54+
}
2955

3056
x: (parent.width - width) / 2
3157
y: (parent.height - height) / 2
58+
width: dialog_width_
3259

3360
onAccepted: {
34-
controller.init_monitor(simpleDiscoveryAnswer.value)
61+
let advancedOptions = {}
62+
if (easyModeOptionCheckBox.checked) {
63+
advancedOptions["easy_mode_ip"] = easyModeOptionTextInput.text
64+
}
65+
controller.init_monitor(simpleDiscoveryAnswer.value, advancedOptions)
3566
}
3667

37-
RowLayout {
68+
contentItem: ColumnLayout {
69+
spacing: layout_horizontal_spacing_
3870

39-
Label {
40-
text: "DDS Domain: "
71+
Row {
72+
spacing: dialogInitMonitor.layout_vertical_spacing_
73+
74+
Label {
75+
text: "DDS Domain: "
76+
anchors.verticalCenter: parent.verticalCenter
77+
}
78+
79+
SpinBox {
80+
id: simpleDiscoveryAnswer
81+
anchors.verticalCenter: parent.verticalCenter
82+
editable: true
83+
value: 0
84+
from: 0
85+
to: 232
86+
Layout.alignment: Qt.AlignTop
87+
Keys.onReturnPressed: {
88+
// Prevent accepting the dialog if OK button is disabled
89+
if (dialogButtons.standardButton(Dialog.Ok).enabled) {
90+
dialogInitMonitor.accept()
91+
}
92+
}
93+
}
4194
}
42-
SpinBox {
43-
id: simpleDiscoveryAnswer
44-
editable: true
45-
value: 0
46-
from: 0
47-
to: 232
48-
Layout.alignment: Qt.AlignTop
49-
Keys.onReturnPressed: dialogInitMonitor.accept()
95+
96+
Rectangle {
97+
98+
id: advancedOptionsSubmenu
99+
color: "transparent"
100+
101+
property bool isExpanded: false
102+
readonly property int item_height_: dialogInitMonitor.item_height_
103+
readonly property int collapsed_options_box_height_: item_height_
104+
readonly property int options_box_body_height_: item_height_
105+
readonly property int expanded_options_box_height_: collapsed_options_box_height_ + options_box_body_height_
106+
107+
Layout.fillWidth: true
108+
Layout.preferredHeight: isExpanded
109+
? expanded_options_box_height_ + 20
110+
: collapsed_options_box_height_ + 20
111+
112+
Column {
113+
anchors.fill: parent
114+
spacing: layout_horizontal_spacing_
115+
RowLayout {
116+
width: parent.width
117+
118+
Rectangle {
119+
Layout.fillWidth: true
120+
height: 2
121+
color: Theme.lightGrey
122+
}
123+
124+
Rectangle {
125+
width: 175
126+
height: 30
127+
radius: 15
128+
color: advancedOptionsMouseArea.containsMouse ? Theme.grey : "transparent"
129+
Row {
130+
anchors.verticalCenter: parent.verticalCenter
131+
spacing: dialogInitMonitor.layout_vertical_spacing_
132+
leftPadding: 10
133+
134+
IconSVG {
135+
anchors.verticalCenter: parent.verticalCenter
136+
name: advancedOptionsSubmenu.isExpanded ? "cross" : "plus"
137+
size: 12
138+
color: advancedOptionsMouseArea.containsMouse ? "white" : "grey"
139+
}
140+
141+
Label {
142+
anchors.verticalCenter: parent.verticalCenter
143+
text: "Advanced options"
144+
color: advancedOptionsMouseArea.containsMouse ? "white" : "grey"
145+
}
146+
}
147+
148+
MouseArea {
149+
id: advancedOptionsMouseArea
150+
width: parent.width
151+
height: parent.height
152+
hoverEnabled: true
153+
onClicked: {
154+
advancedOptionsSubmenu.isExpanded = !advancedOptionsSubmenu.isExpanded
155+
}
156+
}
157+
}
158+
}
159+
160+
Column {
161+
width: parent.width
162+
visible: advancedOptionsSubmenu.isExpanded
163+
height: advancedOptionsSubmenu.isExpanded ? advancedOptionsSubmenu.item_height_ : 0
164+
spacing: dialogInitMonitor.layout_horizontal_spacing_
165+
166+
Row {
167+
id: easyModeOption
168+
spacing: dialogInitMonitor.layout_vertical_spacing_
169+
CheckBox {
170+
id: easyModeOptionCheckBox
171+
text: "Easy Mode"
172+
checked: false
173+
174+
indicator: Rectangle {
175+
implicitWidth: 16
176+
implicitHeight: 16
177+
anchors.verticalCenter: parent.verticalCenter
178+
border.color: Theme.grey
179+
border.width: 2
180+
Rectangle {
181+
visible: easyModeOptionCheckBox.checked
182+
color: Theme.eProsimaLightBlue
183+
radius: 1
184+
anchors.margins: 3
185+
anchors.fill: parent
186+
}
187+
}
188+
189+
onCheckedChanged: {
190+
if (!checked)
191+
{
192+
dialogButtons.standardButton(Dialog.Ok).enabled = true
193+
}
194+
else
195+
{
196+
easyModeOptionTextInput.validateInputTest()
197+
}
198+
}
199+
}
200+
201+
TextField {
202+
id: easyModeOptionTextInput
203+
enabled: easyModeOptionCheckBox.checked
204+
selectByMouse: true
205+
placeholderText: "IPv4 Address"
206+
width: 130
207+
height: 5/6*advancedOptionsSubmenu.item_height_
208+
anchors.verticalCenter: parent.verticalCenter
209+
210+
validator: RegExpValidator {
211+
regExp: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))$/
212+
}
213+
214+
background: Rectangle {
215+
color: !easyModeOptionCheckBox.checked ? "#a0a0a0" : Theme.whiteSmoke
216+
border.color: !easyModeOptionCheckBox.checked ? Theme.grey :
217+
easyModeOptionTextInput.acceptableInput ? "lightgreen" : "salmon"
218+
}
219+
220+
onTextChanged: {
221+
validateInputTest()
222+
}
223+
224+
function validateInputTest() {
225+
if (acceptableInput) {
226+
dialogButtons.standardButton(Dialog.Ok).enabled = true
227+
} else {
228+
dialogButtons.standardButton(Dialog.Ok).enabled = false
229+
}
230+
}
231+
}
232+
}
233+
}
234+
}
50235
}
51236
}
52237
}

src/Controller.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@
2828
#include <fastdds_monitor/utils.h>
2929

3030
void Controller::init_monitor(
31-
int domain)
32-
{
33-
engine_->init_monitor(domain);
31+
int domain,
32+
QVariantMap advanced_options)
33+
{
34+
/* Create engine input parameters from advance options */
35+
// ROS2 Easy Mode IP
36+
std::string easy_mode_ip = "";
37+
if (advanced_options.contains("easy_mode_ip"))
38+
{
39+
easy_mode_ip = advanced_options["easy_mode_ip"].toString().toStdString();
40+
}
41+
engine_->init_monitor(domain, easy_mode_ip);
3442
}
3543

3644
void Controller::init_monitor(

0 commit comments

Comments
 (0)