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

Handle arrays that contain non primitives #30

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 10 additions & 2 deletions src/rqt_publisher/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ def _change_publisher_expression(self, publisher_info, topic_name, new_value):
slot_path = topic_name.replace(publisher_info['topic_name'], '', 1)
slot_path, slot_array_index = self._extract_array_info(slot_path)

# Remove all "indexes" from slot_path, so get_slot_type works
opening_bracket = slot_path.find('[')
closing_bracket = slot_path.find(']')
while opening_bracket != -1 and closing_bracket != -1:
slot_path = slot_path[:opening_bracket] + slot_path[closing_bracket+1:]
opening_bracket = slot_path.find('[')
closing_bracket = slot_path.find(']')

# Get the property type from the message class
slot_type, is_array = \
get_slot_type(publisher_info['message_instance'].__class__, slot_path)
Expand Down Expand Up @@ -263,8 +271,8 @@ def _change_publisher_expression(self, publisher_info, topic_name, new_value):

def _extract_array_info(self, type_str):
array_size = None
if '[' in type_str and type_str[-1] == ']':
type_str, array_size_str = type_str.split('[', 1)
if type_str[-1] == ']':
type_str, array_size_str = type_str.rsplit('[', 1)
array_size_str = array_size_str[:-1]
if len(array_size_str) > 0:
array_size = int(array_size_str)
Expand Down