Hi,
I have this problem where i need to plot elements that are stored into an list containing a UDT.
the class is the following:
class Measurement:
def __init__(self, time, mh_dist, color, x, y):
self.time = float(time)
self.mh_dist = float(mh_dist)
self.color = color
self.x = float( x )
self.y = float( y )
The I create a list containing elements of this class.
processedMeasurements = []
for topic, meas, t in bag.read_messages(topics=['/Measurements']):
if meas.accepted:
processedMeasurements.append( Measurement( t.to_sec(),
meas.distance,
'b',
meas.pose.position.x,
meas.pose.position.y) )
else:
processedMeasurements.append( Measurement( t.to_sec(),
meas.distance,
'r',
meas.pose.position.x,
meas.pose.position.y) )
The only thing that is important to understan here is that I am saving data readed from a file. Later I would like to plot this data.
For example, the measurements contains a x and y position. I would like to plot this position for every element in the list processedMeasurements.
However, doing something like:
for measurement in processedMeasurements:
p1.plot(measurement.x, measurement.y, pen=None, symbol='o')
Gives me the following error:
Traceback (most recent call last):
File "/home/agotelli/catkin_ws/src/Project1/plotting/scripts/plotting", line 514, in <module>
p1.plot(measurement.x, measurement.y, pen=None, symbol='o')
File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/graphicsItems/PlotItem/PlotItem.py", line 640, in plot
item = PlotDataItem(*args, **kargs)
File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 185, in __init__
self.setData(*args, **kargs)
File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 395, in setData
raise Exception('When passing two unnamed arguments, both must be a list or array of values. (got %s, %s)' % (str(type(args[0])), str(type(args[1]))))
Exception: When passing two unnamed arguments, both must be a list or array of values. (got <type 'float'>, <type 'float'>)
Does anybody knows how to solve this problem??
Thank you in advance.