-
Notifications
You must be signed in to change notification settings - Fork 22
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
AttributeError: 'numpy.ndarray' object has no attribute 'get_fields_and_field_types' #3
Comments
The same problem. Did you find a solution? |
Afraid I did not, decided to use a solution that doesn't require ros2 bag. |
Even after the merging, I'm still getting this error. Has anyone made any more advances? Tank you very much. |
Did you guys finish the probelem? |
Guys this problem is caused by the "message_conventer.py". Here is the resolution of this problem: def _is_ros_binary_type(field_type): Add the octet type here. |
you can try modify the convert_ros_message_to_dictionary function to: def convert_ros_message_to_dictionary(message):
"""
Takes in a ROS message and returns a Python dictionary.
Example:
ros_message = std_msgs.msg.String(data="Hello, Robot")
dict_message = convert_ros_message_to_dictionary(ros_message)
"""
dictionary = {}
if hasattr(message, 'get_fields_and_field_types'):
message_fields = message.get_fields_and_field_types()
for (field_name, field_type) in message_fields.items():
field_value = getattr(message, field_name)
dictionary[field_name] = _convert_from_ros_type(field_type, field_value)
else:
dictionary = None
return dictionary Also, add create csv if not exist function to save_csv_file.py: def save_csv_file(data, csv_file_name, version=0, print_out=False):
""" Save data to a csv_file_name (use it after 'read_from_all_topics').
"""
# Create csv file
import os
if not os.path.exists(os.path.dirname(csv_file_name)):
os.makedirs(os.path.dirname(csv_file_name))
................................... |
This is a package that modified the code based on the above advice. You can use git clone as it is. |
When attempting to run with my rosbag I generated from a simulation I received this error, tried both in ubuntu 20 and windows 10
Working on ROS2 Foxy.
`
['/simulation/d9/gps', '/simulation/d9/imu/acceleration', '/simulation/d9/imu/orientation', '/simulation/d9/imu/orientation/rate', '/simulation/d9/imu/velocity']
Traceback (most recent call last):
File "/home/simteam/.local/bin/ros2bag-convert", line 8, in
sys.exit(main())
File "/home/simteam/.local/lib/python3.8/site-packages/ros2bag_convert/main.py", line 14, in main
data = read_bag.read_from_all_topics(file_url,True)
File "/home/simteam/.local/lib/python3.8/site-packages/ros2bag_convert/ros2bag_convert/read_bag.py", line 210, in read_from_all_topics
timestamps, messages = read_from_topic(bag_file, topic_names[i], print_out)
File "/home/simteam/.local/lib/python3.8/site-packages/ros2bag_convert/ros2bag_convert/read_bag.py", line 183, in read_from_topic
dic_data = message_converter.convert_ros_message_to_dictionary(msg)
File "/home/simteam/.local/lib/python3.8/site-packages/ros2bag_convert/ros2bag_convert/message_converter.py", line 243, in convert_ros_message_to_dictionary
dictionary[field_name] = _convert_from_ros_type(field_type, field_value)
File "/home/simteam/.local/lib/python3.8/site-packages/ros2bag_convert/ros2bag_convert/message_converter.py", line 259, in _convert_from_ros_type
field_value = convert_ros_message_to_dictionary(field_value)
File "/home/simteam/.local/lib/python3.8/site-packages/ros2bag_convert/ros2bag_convert/message_converter.py", line 240, in convert_ros_message_to_dictionary
message_fields = message.get_fields_and_field_types()
AttributeError: 'numpy.ndarray' object has no attribute 'get_fields_and_field_types'
`
The text was updated successfully, but these errors were encountered: