Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 4

Send an array or a list between nodes?

Previous: Answer by stevemacenski for Hi, i'm using ROS2 Humble. I'm trying to collect my sensordata in one node and want to use these sensordata in another node. therefore i ceated a numpy array to save the data in self.sens_data=np.zeros((1, self.timesteps, self.features)) then i tried to convert it to a list and publish it. msg = Float32MultiArray() msg.data = self.sens_data.tolist() self.publisher_.publish(msg) but then i get this error. AssertionError: The 'data' field must be a set or sequence and each value of type 'float' and each float in [-340282346600000016151267322115014000640.000000, 340282346600000016151267322115014000640.000000] [ros2run]: Process exited with failure 1 The output of print(sens_data.dtype) is float 64. The output of print(type(data)) after converting sens_data to a list like data = self.sens_data.tolist() is <class 'list'>.For example my array has the size (1,80,6). I also found out that it is possible to save the message to a ros bag which might be faster. But there i have the same problem with converting the Data. How can i send a list or an array to another Node?EDIT:The data i collect is Sensordata. The purpose of sending this data is, that i have a AI which is predicting something based on the Sensordata. The AI is a LSTM-Network, thats why the data has to be in that shape. Maybe there is a better way of getting the data to my AI node?
$
0
0
Hi, i'm using ROS2 Humble. I'm trying to collect my sensordata in one node and want to use these sensordata in another node. therefore i ceated a numpy array to save the data in self.sens_data=np.zeros((1, self.timesteps, self.features)) then i tried to convert it to a list and publish it. msg = Float32MultiArray() msg.data = self.sens_data.tolist() self.publisher_.publish(msg) but then i get this error. AssertionError: The 'data' field must be a set or sequence and each value of type 'float' and each float in [-340282346600000016151267322115014000640.000000, 340282346600000016151267322115014000640.000000] [ros2run]: Process exited with failure 1 The output of `print(sens_data.dtype)` is `float 64`. The output of `print(type(data))` after converting sens_data to a list like `data = self.sens_data.tolist()` is ``. For example my array has the size (1,80,6). I also found out that it is possible to save the message to a ros bag which might be faster. But there i have the same problem with converting the Data. How can i send a list or an array to another Node? EDIT: The data i collect is Sensordata. The purpose of sending this data is, that i have a AI which is predicting something based on the Sensordata. The AI is a LSTM-Network, thats why the data has to be in that shape. Maybe there is a better way of getting the data to my AI node?

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images