Implements DDS communication using FastDDS.
More...
#include <rtctk/telSub/ddsWaitSet.hpp>
|
| using | Alloc = std::pmr::polymorphic_allocator<std::byte> |
| |
Implements DDS communication using FastDDS.
◆ Alloc
◆ DdsWaitSet() [1/3]
| rtctk::telSub::DdsWaitSet::DdsWaitSet |
( |
const DdsParams & | params, |
|
|
const Alloc & | alloc = {} ) |
|
explicit |
Constructs a DDS subscriber from given configuration parameters.
The constructor will initialise the DDS subsystem and allocate necessary resources by constructing appropriate rtctk::componentFramework::DdsSub object. Individual DDS topic objects and DDS readers are created inside rtctk::componentFramework::DdsSub for each topic found in the params.m_topics vector.
There is a one to one correspondence between the topic in params.m_topics and the DDS reader and DDS topic object created. The order of the topics matters and is preserved, meaning that the n'th topic in params.m_topics will equal GetTopicName(n) after successful construction. In addition, the TakeSamples method will return DDS samples for the n'th DDS reader in its output parameter samples[n], which also corresponds to the configured topic GetTopicName(n).
- Parameters
-
| params | The structure containing all needed parameters to construct the DDS objects. |
| alloc | The memory allocator to use for memory management. |
- Postcondition
- GetNumberOfTopics() == params.m_topics.size(), i.e. the number of topics and corresponding DDS readers created will match the topic names passed in as configuration parameters.
◆ ~DdsWaitSet()
| rtctk::telSub::DdsWaitSet::~DdsWaitSet |
( |
| ) |
|
|
overridenoexcept |
Destroys the DDS subscriber and releases all DDS resources.
The destructor will release all resources associate with this subscriber object that were allocated by DDS. This is done by deleting all DDS object that were created. Errors during this procedure cannot be propagated as exceptions, therefore the errors will simply be logged and execution allowed to continue.
◆ DdsWaitSet() [2/3]
| rtctk::telSub::DdsWaitSet::DdsWaitSet |
( |
const DdsWaitSet & | rhs | ) |
|
|
delete |
◆ DdsWaitSet() [3/3]
| rtctk::telSub::DdsWaitSet::DdsWaitSet |
( |
DdsWaitSet && | rhs | ) |
|
|
delete |
◆ CheckDdsConnections()
| void rtctk::telSub::DdsWaitSet::CheckDdsConnections |
( |
| ) |
|
|
overridevirtual |
◆ GetNumberOfTopics()
| size_t rtctk::telSub::DdsWaitSet::GetNumberOfTopics |
( |
| ) |
const |
|
overridevirtualnoexcept |
Returns the number of configured topics.
This returns the number of topics that were configured during construction of the subscriber object. This corresponds to the size of the DdsParams::m_topics vector passed to the constructor.
- Returns
- The number of configured topics.
Implements rtctk::telSub::DdsWaitSetIf.
◆ GetSamples()
Returns reference to data structure holding taken data samples.
To update structure with new samples TakeSamples() must be used.
- See also
- TakeSamples()
Implements rtctk::telSub::DdsWaitSetIf.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ ReturnLoan()
| std::error_code rtctk::telSub::DdsWaitSet::ReturnLoan |
( |
const std::string & | topic, |
|
|
DdsSampleSeq & | samples, |
|
|
DdsInfoSeq & | infos ) |
|
overridevirtualnoexcept |
Returns loaned sample sequence.
After invoking this method successfully the provided sequences will be emptied.
- Postcondition
Empty() == true
- Parameters
-
| topic | Topic name. |
| samples | Sample sequence. |
| infos | Sample information sequence. |
Implements rtctk::telSub::SeqLoanerIf.
◆ Take()
| std::optional< DdsWaitSetError > rtctk::telSub::DdsWaitSet::Take |
( |
std::chrono::nanoseconds | timeout | ) |
|
|
overridevirtualnoexcept |
Takes new samples from DDS readers and updates data structure accessable from GetSamples()
The method waits for new DDS samples to become available on one or more of the DDS topic readers as needed to fill up AgnosticDataSamples from GetSamples() with a non-empty sample sequence for each topic.
An empty / zero error code is returned if the operation completed successfully, meaning at least one non-empty sample sequence was taken.
If no samples were available within the timeout period then a std::errc::timed_out error code is returned. If some other error occurred, an appropriate error code is returned.
It is expected that the caller processes the samples and when done with them calls AgnosticAgnosticDataSamples::Clear() to return the samples to DDS. It is not required that all sample sequences are cleared at the same time.
- Parameters
-
| [in] | timeout | The maximum amount of time to wait for this operation to complete, measured in nanoseconds. |
- Returns
- An error code indicating success, failure or timeout of the operation.
The following is the list of possible error codes returned:
0
- At least one samples was successfully returned.
std::errc::timed_out
- The operation timed out while waiting for DDS samples.
std::errc::protocol_error
- A call to the DDS API failed.
std::errc::bad_address
- Could not identify the associated topic reader for a sample.
- See also
- GetSamples()
Implements rtctk::telSub::DdsWaitSetIf.
The documentation for this class was generated from the following files: