* Use rcutils_get_env() instead of getenv() (#71)
Signed-off-by: Erik Boasson <eb@ilities.com>
* Keep includes in alphabetical order
Signed-off-by: Erik Boasson <eb@ilities.com>
Cyclone's original code for dds_create_domain() appears to create a
domain entity that is automatically deleted when the last attached
participant disappears. In reality, it leaks a reference while
returning DDS_RETCODE_OK, making it appear as-if it is a regular entity
that remains into existence until explicitly deleted.
The RMW code assumed that it would be automatically deleted when the
last node was destroyed and that a subsequent call to rmw_create_node
could create the domain anew. This then fails with "precondition not
met".
In an upcoming fixed version of dds_create_domain() the domain entities
will behave normally (return a handle, require an explicit delete).
This commit provides a workaround for the bug in the original
implementation: by recovering the handle from the first participant the
preceding commits that were intended to future-proof the code will
ensure that the entity now gets deleted explicitly.
Signed-off-by: Erik Boasson <eb@ilities.com>
* Support localhost-only communications
Signed-off-by: Erik Boasson <eb@ilities.com>
* Future-proof localhost-only for upcoming Cyclone fix
Signed-off-by: Erik Boasson <eb@ilities.com>
The rmw_return_loaned_message and rmw_release_loaned_message functions
are still expected by rcl, even if they are scheduled to be replaced.
We need a working build, so add them for now.
Signed-off-by: Erik Boasson <eb@ilities.com>
* Add localhost boolean parameter to create node function
Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
* Cast to void to avoid compilation warning
Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
* Validation in Deserializer
Added validation in CDR deserialization: max buffer length is checked
when deserializing fields and strings are checked for null-terminator
(except for wstrings, which are serialized without null-terminator).
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
* Catch exceptions in serdata functions
In serdata functions rmw_print, rmw_to_sample and rmw_from_sample
catch exceptions so that correct return code is given when functions
are called from ddsi.
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
* Improve deserialisation validation
Refactored the deserialisation validation functions so that sequence
length is checked more properly and protection against overflows.
Renamed source files for exceptions so that it conforms to ros2 /
google c++ style guide.
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
Cyclone DDS always returns immediately from ``dds_waitset_wait`` when
there are no entities in the waitset, but the rcl timer test implies
that the expectation is that blocks. By adding a guard condition that
is never triggered this expectation is met.
Signed-off-by: Erik Boasson <eb@ilities.com>
* Return history depth even when KEEP_ALL is selected
* Return deadline, lifespan, liveliness
This doesn't fix it completely: the latter three are not actually
supported and are still ignored when creating an publisher or subscriber
node; and moreover it is not clear how to map infinity.
Signed-off-by: Erik Boasson <eb@ilities.com>
Otherwise each writer/reader gets its own, and at approximately 1kB
each, with hundreds of endpoints that starts adding up to a meaningful
amount of memory.
Signed-off-by: Erik Boasson <eb@ilities.com>
The built-in topics readers in the RMW node are currently not used for
anything other than triggering the guard condition. All the query
functions just get their own data set from Cyclone. Taking all samples
instead of just the not-alive ones reduces memory usage.
Signed-off-by: Erik Boasson <eb@ilities.com>
Misuse of std::vector resize as if it would leave any reserved entries
unchanged caused a misinterpretation of entries whenever the number of
triggering entities was larger than the number of triggering entities in
the preceding call to rmw_wait: these would all be mapped to the first
entity in the set.
If the waitset is reused from call to call and spurious events are
handled gracefully, this is recoverable; otherwise, no such luck.
Moreover, not accounting for a sentinel entry added to the list of
triggered entities means it would never return RMW_RET_TIMEOUT.
Signed-off-by: Erik Boasson <eb@ilities.com>
The graph guard condition is triggered whenever the underlying DDS
topology changes using a listener set on readers for the DDS built-in
topics. The graph guard condition was destroyed before ensuring the listeners
would no longer be invoked, and this would lead to trying to trigger the
graph guard condition after it had been destroyed.
With this commit, the built-in readers are deleted explicitly before
destroying the graph guard condition.
This leaves as the big gaping holes:
* Cyclone DDS does not allow creating a waitset or a guard condition
outside a participant, and this forces the creation of an additional
participant. It can be fixed in the RMW layer, or it can be dealt
with in Cyclone DDS, but the trouble with the latter is that there are
solid reasons for not allowing it, even if it is easy to support it
today. (E.g., a remote procedure call interface ...)
* Cyclone DDS does not currently support multiple domains
simultaneously, and so this RMW implementation ignores the domain_id
parameter in create_node, instead creating all nodes/participants
(including the special participant mentioned above) in the default
domain, which can be controlled via CYCLONEDDS_URI.
* Deserialization only handles native format (it doesn't do any byte
swapping). This is pure laziness, adding it is trivial.
* Deserialization assumes the input is valid and will do terrible things
if it isn't. Again, pure laziness, it's just adding some bounds
checks and other validation code.
* There are some "oddities" with the way service requests and replies
are serialized and what it uses as a "GUID". (It actually uses an
almost-certainly-unique 64-bit number, the Cyclone DDS instance id,
instead of a real GUID.) I'm pretty sure the format is wildly
different from that in other RMW implementations, and so services
presumably will not function cross-implementation.
* The name mangling seems to be compatibl-ish with the FastRTPS
implementation and in some cases using the ros2 CLI for querying the
system works cross-implementation, but not always. The one in this
implementation is reverse-engineered, so trouble may be lurking
somewhere. As a related point: the "no_demangle" option is currently
ignored ... it causes a compiler warning.
Almost there! Known issues:
* mangling/demangling is still wrong
* it necessarily has to run in the Cyclone default domain id: (1)
Cyclone is today still limited to a single domain at a time; and (2)
there is the "extra" participant that pops up here and there for
creating guard conditions and waitsets without a node existing
* almost all query operations create a reader for a builtin topic and
throw it away afterward, that might be a little excessive (on the other
hand, those readers are pretty cheap, so using them as a throwaway
reader is not so bad).
Still missing:
* get_service_names_and_types
* get_service_names_and_types_by_node
I haven't been able to actually try everything yet, so bugs are probably
lurking here-and-there.
passes a decent subset of the tests ...
fixes:
* sequences of simple types: remove accidental alignment
* trigger graph guard on any built-in topic
* create a participant for each node, with node name/namespace in user data
It is still only a proof-of-concept, but it might now actually be usable ...