Skip to content

Commit

Permalink
fix set_message_fields for numpy array
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
  • Loading branch information
dirk-thomas committed Aug 23, 2019
1 parent 3815e92 commit 2ecfb1c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rosidl_runtime_py/rosidl_runtime_py/set_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import array
import numpy

from typing import Any
from typing import Dict
Expand All @@ -38,6 +39,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

0 comments on commit 2ecfb1c

Please sign in to comment.