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

fix set_message_fields for numpy array #81

Merged
merged 1 commit into from
Aug 26, 2019
Merged
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
4 changes: 4 additions & 0 deletions rosidl_runtime_py/rosidl_runtime_py/set_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from typing import Any
from typing import Dict

import numpy

from rosidl_parser.definition import AbstractNestedType
from rosidl_parser.definition import NamespacedType
from rosidl_runtime_py.convert import get_message_slot_types
Expand All @@ -38,6 +40,8 @@ def set_message_fields(msg: Any, values: Dict[str, str]) -> None:
field_type = type(field)
if field_type is array.array:
value = field_type(field.typecode, field_value)
elif field_type is numpy.ndarray:
value = numpy.array(field_value, dtype=field.dtype)
elif type(field_value) is field_type:
value = field_value
else:
Expand Down