Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add queue size parameter for remote and local topics #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ parameter_polling_hz: 1

**Note**: Don't add to remote or local topics the topic `/rosout`.

# Additional Parameters in this fork
For `remote_topics` and `local_topics`, there are two additional parameters you can provide after the topic name, message type, and alias name. You can also provide a boolean which represents whether the topic should latch, and also a queue_size, which defines the size of the message queue. These should be specified in the order `[<topic name>, <message type>, <alias name>, <latch>, <queue size>]`.

# Example usage with Docker
This tool came to be mainly to solve a problem with Docker containers. If you are running the Docker container that wants bidirectional communication with a ROS robot, and you are using Linux you can just add `--net host` to your `docker run` command (just after run). But if you are using a Mac [this won't work](https://github.com/docker/for-mac/issues/68). To work around it you can use this package.

Expand Down
18 changes: 16 additions & 2 deletions src/rosduct/rosduct_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,35 +119,48 @@ def initialize(self):
topic_name, topic_type = r_t
local_name = topic_name
latch = False
queue_size = 1
elif len(r_t) == 3:
topic_name, topic_type, local_name = r_t
latch = False
queue_size = 1
elif len(r_t) == 4:
topic_name, topic_type, local_name, latch = r_t
queue_size = 1
elif len(r_t) == 5:
topic_name, topic_type, local_name, latch, queue_size = r_t


msg = ROSDuctConnection()
msg.conn_name = topic_name
msg.conn_type = topic_type
msg.alias_name = local_name
msg.latch = latch if latch.__class__==bool else latch.lower() == 'true'
msg.queue_size = queue_size if queue_size.__class__==int else 1
self.add_remote_topic(msg)

for l_t in self.local_topics:
if len(l_t) == 2:
topic_name, topic_type = l_t
remote_name = topic_name
latch = False
queue_size = 1
elif len(l_t) == 3:
topic_name, topic_type, remote_name = l_t
latch = False
queue_size = 1
elif len(l_t) == 4:
topic_name, topic_type, remote_name, latch = l_t
queue_size = 1
elif len(l_t) == 5:
topic_name, topic_type, remote_name, latch, queue_size = l_t

msg = ROSDuctConnection()
msg.conn_name = topic_name
msg.conn_type = topic_type
msg.alias_name = remote_name
msg.latch = latch if latch.__class__==bool else latch.lower() == 'true'
msg.queue_size = queue_size if queue_size.__class__==int else 1
self.add_local_topic(msg)

# Services
Expand Down Expand Up @@ -188,7 +201,8 @@ def initialize(self):
def add_local_topic(self, msg):
bridgepub = self.client.publisher(msg.alias_name,
msg.conn_type,
latch=msg.latch)
latch=msg.latch,
queue_size=msg.queue_size)

cb_l_to_r = self.create_callback_from_local_to_remote(msg.conn_name,
msg.conn_type,
Expand Down Expand Up @@ -217,7 +231,7 @@ def add_remote_topic(self, msg):
rospub = rospy.Publisher(msg.alias_name,
get_ROS_class(msg.conn_type),
# SubscribeListener added later
queue_size=1,
queue_size=msg.queue_size,
latch=msg.latch)

cb_r_to_l = self.create_callback_from_remote_to_local(msg.conn_name,
Expand Down
1 change: 1 addition & 0 deletions srv/ROSDuctConnection.srv
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ string conn_name
string conn_type
string alias_name
bool latch
uint32 queue_size
---