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

Comment by stevemacenski for Just running these in an ipython terminal to look at the data, this is definitely not just a 1D list of data. Its a list of lists... of lists. You'd need to either flatten this out or create a new ROS message that is a list of list of lists of floats (though the outer most list only as the 1 enter, so maybe just list of lists). sens_data=np.zeros((1, 100, 10)) sens_data.tolist() Out[4]: [[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]]

Next: 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?
Previous: Comment by LucB for Just running these in an ipython terminal to look at the data, this is definitely not just a 1D list of data. Its a list of lists... of lists. You'd need to either flatten this out or create a new ROS message that is a list of list of lists of floats (though the outer most list only as the 1 enter, so maybe just list of lists). sens_data=np.zeros((1, 100, 10)) sens_data.tolist() Out[4]: [[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ... [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]]
$
0
0
Recovering the shape would be up to you to figure out as the implementer. But if you can't, then define a new message which can contain the information you're interested in. That tutorial you linked to is pretty straight forward. You need an array of arrays (of arrays? if that 3rd level ever changes). Then do what you did here to populate it.

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>