ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

So I created a custom message which looks like:

geometry_msgs/Vector3[] Vector3DArray

I'm just guessing, but it might be that Python doesn't like the fact that you have a message field (essentially a member variable of your msg class) that has the same name as the type of your msg class.

Alternative names I've seen used in these cases (msg with just a single field) are: data or vectors (see geometry_msgs/PoseArray for a similar msg). Using more semantically relevant names is encouraged though (but try not to tie your msg definition to your current application too much).

So I created a custom message which looks like:

geometry_msgs/Vector3[] Vector3DArray

I'm just guessing, but it might be that Python doesn't like the fact that you have a message field (essentially a member variable of your msg class) that has the same name as the type of your msg class.

Alternative names I've seen used in these cases (msg with just a single field) are: data or vectors (see geometry_msgs/PoseArray for a similar msg). Using more semantically relevant names is encouraged though (but try not to tie your msg definition to your current application too much).


Hm, just noticed this:

vec3 = Vector3()

for i in range(0, self.anzahl_punkte):
    ...
    self.vectordaten_tabelle.Vector3DArray.append(vec3)

You create a single Vector3 instance outside your for-loop, which you then update by setting its fields, and then append to the vectordaten_tabelle msg object. Afaik, Python is reference-based, which means that every .append(..) you call merely adds a new reference to the same Vector3 instance.

If you move your vec3 = Vector3() line into your for-loop, you'll get the behaviour you are after.

I would still recommend changing the name of your msg field though.

So I created a custom message which looks like:

geometry_msgs/Vector3[] Vector3DArray

I'm just guessing, but it might be that Python doesn't like the fact that you have a message field (essentially a member variable of your msg class) that has the same name as the type of your msg class.

Alternative names I've seen used in these cases (msg with just a single field) are: data or vectors (see geometry_msgs/PoseArray for a similar msg). Using more semantically relevant names is encouraged though (but try not to tie your msg definition to your current application too much).


Hm, Edit: hm, just noticed this:

vec3 = Vector3()

for i in range(0, self.anzahl_punkte):
    ...
    self.vectordaten_tabelle.Vector3DArray.append(vec3)

You create a single Vector3 instance outside your for-loop, which you then update by setting its fields, and then append to the vectordaten_tabelle msg object. Afaik, Python is reference-based, which means that every .append(..) you call merely adds a new reference to the same Vector3 instance.

If you move your vec3 = Vector3() line into your for-loop, you'll get the behaviour you are after.

I would still recommend changing the name of your msg field though.