I defined the two following message structures for a ROS package:
point.msg
float64 x
float64 y
points.msg
point[] points
I am instantiating and filling a points array in Python as follows:
point_list = points()
pt = point()
for element in self.points:
pt.x = element[0,0]
pt.y = element[1,0]
point_list += (pt,)
And this is the error I am getting:
unsupported operand type(s) for +=: 'points' and 'tuple'
PS : tried .append
and it is still not working
The message points
is not directly a list of point
messages, but a structure, that has a member called points
which is a list.
To add elements to this list, you have to access the member, not the containing structure:
point_list.points.append(pt)