Auterion / px4-ros2-interface-lib

Library to interface with PX4 from a companion computer using ROS 2
BSD 3-Clause "New" or "Revised" License
60 stars 21 forks source link

fix usage of ROS namespaces #39

Closed damien-robotsix closed 4 months ago

damien-robotsix commented 4 months ago

Currently the library do not take into account the namespace if specified. The micro DDS client allows in PX4 to configure a custom namespace (multiple drones on the same network). To reflect this, it would be good to also allow this library to use custom namespaces. Removing "/" in front of topic definitions solve this. The topics will reflect the chosen namespace for the node.

bkueng commented 4 months ago

There's already a topic_namespace_prefix for that. You can pass that to the Mode's constructor. That said I'm not sure whether that's the best solution though.

damien-robotsix commented 4 months ago

Ho, my bad, I was too fast on this, I didn't see the topic prefix in the constructor.

However that breaks the ability to set the namespace using ROS arguments when running the mode Node.

Anyway both approaches are compatible. With this PR, you can:

How does that sound?

bkueng commented 4 months ago

However that breaks the ability to set the namespace using ROS arguments when running the mode Node.

That is correct. It's separate, as someone might want to write a node that controls/consumes telemetry from multiple vehicles.

Anyway both approaches are compatible. With this PR, you can:

I'm fine with both approaches, just the default needs to work with the PX4 default, independent from the node name. Which looks like it's the case here, right?

damien-robotsix commented 4 months ago

It will if the node has no namespace (default in ROS2)

damien-robotsix commented 4 months ago

Thanks for merging :)