ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
This is quite similar to #q321354, but in Python and with a different message type.
visualization_msgs/MarkerArray has a single field:
visualization_msgs/Marker[] markers
markers
is an unbounded array (or list). For Python, those are mapped onto tuples (see wiki/msg).
Hence, I tried printing
msg.markers.pose.position.x
andmsg.markers.points.x
but both of them trigger the same error, msg.markers does not have that attribute
If msg
is a MarkerArray
, you must first select one of the elements in the markers
tuple before you can access any of the properties of that Marker
.
So to access the second Marker
in the markers
tuple, you'd do:
`msg.markers[1].pose.position.x`
(after making sure it actually contains at least two markers, of course)
2 | No.2 Revision |
This is quite similar to #q321354, but in Python and with a different message type.
visualization_msgs/MarkerArray has a single field:
visualization_msgs/Marker[] markers
markers
is an unbounded array (or list). For Python, those are mapped onto tuples (see wiki/msg).
Hence, I tried printing
msg.markers.pose.position.x
andmsg.markers.points.x
but both of them trigger the same error, msg.markers does not have that attribute
If msg
is a MarkerArray
, you must first select one of the elements in the markers
tuple before you can access any of the properties of that Marker
.
So to access the second Marker
in the markers
tuple, you'd do:
`msg.markers[1].pose.position.x`
msg.markers[1].pose.position.x
(after making sure it actually contains at least two markers, of course)