转换到ros消息时,要进行基础类型转换

This commit is contained in:
Xuwznln
2025-07-05 12:43:27 +08:00
parent b69aceaff3
commit a6ec20e279

View File

@@ -343,7 +343,7 @@ def convert_to_ros_msg(ros_msg_type: Union[Type, Any], obj: Any) -> Any:
if hasattr(ros_msg, key):
attr = getattr(ros_msg, key)
if isinstance(attr, (float, int, str, bool)):
setattr(ros_msg, key, value)
setattr(ros_msg, key, type(attr)(value))
elif isinstance(attr, (list, tuple)) and isinstance(value, Iterable):
td = ros_msg.SLOT_TYPES[ind].value_type
if isinstance(td, NamespacedType):