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 26, 2019
1 parent 3815e92 commit 3ec595e
Showing 1 changed file with 4 additions and 0 deletions.
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

0 comments on commit 3ec595e

Please sign in to comment.