Skip to content

Commit

Permalink
Fast DDS Visualizer Plugin migration to Fast DDS v3.0.0 (#58)
Browse files Browse the repository at this point in the history
* Refs #21388: Refactor DynamicTypes

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Fix persistence bug in time series

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Fix types manually added using XML profile

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

Fix load types from XML file

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Add support for sequence types

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Add application metadata

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Add readthedocs.yaml

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Update github workflows

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Uncrustify

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Update requirements.txt

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Fix documentation tests

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

* Refs #21388: Add review changes

Signed-off-by: Carlosespicur <carlosespicur@proton.me>

---------

Signed-off-by: Carlosespicur <carlosespicur@proton.me>
  • Loading branch information
Carlosespicur authored Sep 16, 2024
1 parent 265a22e commit 03bc170
Show file tree
Hide file tree
Showing 21 changed files with 900 additions and 462 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/requirements.repos
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repositories:
type: git
url: https://github.com/eProsima/Fast-CDR.git
version: master
fastrtps:
fastdds:
type: git
url: https://github.com/eProsima/Fast-DDS.git
version: master
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
if: always()

- name: Upload Logs
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: colcon-logs-ubuntu
path: log/
Expand Down Expand Up @@ -134,13 +134,13 @@ jobs:
if: always()

- name: Upload documentation
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: Documentation HTML
path: install/fastdds_visualizer_plugin/docs/fastdds_visualizer_plugin_docs/sphinx/html/

- name: Upload Logs
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: colcon-logs-ubuntu
path: log/
Expand Down Expand Up @@ -294,7 +294,7 @@ jobs:
${MODIFIED_FILES}
- name: Upload uncrustify results
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: uncrustify_results
path: uncrustify_results.xml
9 changes: 7 additions & 2 deletions docs/readthedocs.yaml → .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ version: 2
sphinx:
configuration: docs/conf.py

# Set OS specifically for version compatibility
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml
Expand All @@ -18,6 +24,5 @@ formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def select_css(html_css_dir):
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
13 changes: 11 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
doc8==0.10.1
docutils==0.16.0
GitPython==3.1.24
setuptools==59.4.0
GitPython==3.1.41
setuptools==65.5.1
sphinx_rtd_theme==0.5.2
sphinx-sitemap==2.2.0
sphinx-tabs==3.2.0
sphinx==4.3.1
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-imagehelper==1.1.1
sphinxcontrib-plantuml==0.22
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sphinxcontrib.spelling==7.2.1
vcstool==0.3.0
xmlschema==2.1.1
2 changes: 1 addition & 1 deletion docs/rst/developer_manual/installation/sources/linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The following packages will be installed:

- ``foonathan_memory_vendor``, an STL compatible C++ memory allocator library.
- ``fastcdr``, a C++ library that serializes according to the standard CDR serialization mechanism.
- ``fastrtps``, the core library of eProsima Fast DDS library.
- ``fastdds``, the core library of eProsima Fast DDS library.

First of all, the :ref:`Requirements <requirements>` and :ref:`Dependencies <dependencies>` detailed below need to be
met.
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<!-- Fast DDS dependencies -->
<depend>fastcdr</depend>
<depend>fastrtps</depend>
<depend>fastdds</depend>

<!-- Plotjuggler -->
<depend>plotjuggler</depend>
Expand Down
4 changes: 2 additions & 2 deletions plugins/datastreamer_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ project(fastdds_visualizer_plugin_datastream_plugin)
###############################################################################
# Load eProsima packages
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)
find_package(fastdds REQUIRED)

# Load Qt requirements
find_package(Qt5 REQUIRED COMPONENTS
Expand Down Expand Up @@ -145,7 +145,7 @@ target_link_libraries(
${PROJECT_NAME}
${QT_LINK_LIBRARIES}
${plotjuggler_LIBRARIES}
fastrtps
fastdds
)


Expand Down
71 changes: 50 additions & 21 deletions plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,8 @@ bool FastDdsDataStreamer::start(
}

// Get all series from topics and create them
// NUMERIC
std::vector<types::DatumLabel> numeric_series = fastdds_handler_.numeric_data_series_names();
for (const auto& series : numeric_series)
{
// Create a series
DEBUG("Creating numeric series: " << series);
dataMap().addNumeric(series);
}

// STRING
std::vector<types::DatumLabel> string_series = fastdds_handler_.string_data_series_names();
for (const auto& series : string_series)
{
// Create a series
DEBUG("Creating string series: " << series);
dataMap().addStringSeries(series);
}
dataMap().clear();
create_series_();

running_ = true;
return true;
Expand Down Expand Up @@ -161,6 +146,20 @@ bool FastDdsDataStreamer::xmlLoadState(
// FASTDDS LISTENER METHODS
////////////////////////////////////////////////////

void FastDdsDataStreamer::on_data_available()
{
DEBUG("FastDdsDataStreamer on_data_available");

// Locking DataStream
std::lock_guard<std::mutex> lock(mutex());

// Clear data created from previous sample
dataMap().clear();

// Create series from new received sample
create_series_();
}

void FastDdsDataStreamer::on_double_data_read(
const std::vector<std::pair<std::string, double>>& data_per_topic_value,
double timestamp)
Expand All @@ -173,11 +172,15 @@ void FastDdsDataStreamer::on_double_data_read(
for (const auto& data : data_per_topic_value)
{
DEBUG("Adding to numeric series " << data.first << " value " << data.second << " with timestamp " << timestamp);

if (dataMap().numeric.find(data.first) == dataMap().numeric.end())
{
throw InconsistencyException("Series " + data.first + " not found.");
}
// Get data map
auto& series = dataMap().numeric.find(data.first)->second;
// Add data to series
series.pushBack( { timestamp, data.second});
DEBUG("...Data added to series");
}

emit dataReceived();
Expand Down Expand Up @@ -207,16 +210,20 @@ void FastDdsDataStreamer::on_string_data_read(

void FastDdsDataStreamer::on_topic_discovery(
const std::string& topic_name,
const std::string& type_name,
bool type_registered)
const std::string& type_name)
{
DEBUG("FastDdsDataStreamer topic_discovery_signal " << topic_name);
bool type_info_available = fastdds_handler_.get_topic_data_base()->operator [](topic_name).second;

// __FLAG__
DEBUG("topic discovery signal with type name " << type_name << " and type info available " << type_info_available);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Emit signal to UI so it is handled from Qt thread
emit select_topics_dialog_.topic_discovery_signal(
utils::string_to_QString(topic_name),
utils::string_to_QString(type_name),
type_registered);
type_info_available);
}

////////////////////////////////////////////////////
Expand Down Expand Up @@ -255,6 +262,28 @@ void FastDdsDataStreamer::connect_to_domain_(
select_topics_dialog_.connect_to_domain(domain_id);
}

void FastDdsDataStreamer::create_series_()
{
// Get all series from topics and create them
// NUMERIC
std::vector<types::DatumLabel> numeric_series = fastdds_handler_.numeric_data_series_names();
for (const auto& series : numeric_series)
{
// Create a series
DEBUG("Creating numeric series: " << series);
dataMap().addNumeric(series);
}

// STRING
std::vector<types::DatumLabel> string_series = fastdds_handler_.string_data_series_names();
for (const auto& series : string_series)
{
// Create a series
DEBUG("Creating string series: " << series);
dataMap().addStringSeries(series);
}
}

} /* namespace datastreamer */
} /* namespace plotjuggler */
} /* namespace eprosima */
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class FastDdsDataStreamer :
////////////////////////////////////////////////////
// FASTDDS LISTENER METHODS
////////////////////////////////////////////////////
virtual void on_data_available() override;

virtual void on_double_data_read(
const std::vector<types::NumericDatum>& data_per_topic_value,
Expand All @@ -102,8 +103,7 @@ class FastDdsDataStreamer :

virtual void on_topic_discovery(
const std::string& topic_name,
const std::string& type_name,
bool type_registered) override;
const std::string& type_name) override;


////////////////////////////////////////////////////
Expand Down Expand Up @@ -132,6 +132,7 @@ class FastDdsDataStreamer :
void connect_to_domain_(
unsigned int domain_id);

void create_series_();

////////////////////////////////////////////////////
// INTERNAL VALUES
Expand Down
11 changes: 7 additions & 4 deletions plugins/datastreamer_plugin/fastdds/FastDdsListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include <string>

#include "utils/utils.hpp"
#include "utils/types.hpp"
#include "utils/utils.hpp"

namespace eprosima {
namespace plotjuggler {
Expand All @@ -41,6 +41,11 @@ class FastDdsListener
{
public:

virtual void on_data_available()
{
DEBUG("Calling on_data_available");
}

virtual void on_double_data_read(
const std::vector<types::NumericDatum>& numeric_data,
double timestamp)
Expand All @@ -61,13 +66,11 @@ class FastDdsListener

virtual void on_topic_discovery(
const std::string& topic_name,
const std::string& type_name,
bool type_registered)
const std::string& type_name)
{
DEBUG("Calling on_topic_discovery");
static_cast<void>(topic_name);
static_cast<void>(type_name);
static_cast<void>(type_registered);
}

};
Expand Down
Loading

0 comments on commit 03bc170

Please sign in to comment.