Assign values to arrow marker starting position
Hello,
I am trying to publish an arrow marker and want to display this arrow in rviz. I want the starting point of the arrow to be at a point of a sensor_msgs/PointCloud message. When I am defining a starting and end point of the arrow marker like the following, it works:
visualization_msgs::Marker markers_msg;
markers_msg.points.resize(2);
markers_msg.points[0].x = 0.0f;
markers_msg.points[0].y = 0.0f;
markers_msg.points[0].z = 0.0f;
markers_msg.points[1].x = 1.0f;
markers_msg.points[1].y = 1.0f;
markers_msg.points[1].z = 1.0f;
Now I am trying to assign a specific point of the point cloud to be the starting point of the arrow marker, but it is not working. When I am echoing the cloud.points[] message values are output.
sensor_msgs::PointCloud cloud;
visualization_msgs::Marker markers_msg;
markers_msg.points.resize(2);
markers_msg.points[0].x = cloud.points[...].x;
markers_msg.points[0].y = cloud.points[...].y;
markers_msg.points[0].z = cloud.points[...].z;
markers_msg.points[1].x = 1.0f;
markers_msg.points[1].y = 1.0f;
markers_msg.points[1].z = 1.0f;
I get the error message: "Segmentation fault (core dumped)"
Can someone may help me?
Thank you very much in advance!
Kind regards,
Raphael
I'm confused. Is this not the same issue as #q378596?
Not exactly, now I am trying so assgin values from a message to the sarting arrow marker, if I am assigning specific values like 1.0f the arrow appear without any error. But if I try to assign the starting point to a point from the pointcloud like in the secound code example the error appears
The code you show seems to do the exact same thing as you did earlier: without
reserve(..)
orresize(..)
indexing into astd::vector
. That's a good recipe for running intoSEGFAULT
s.That's what I meant by: isn't the same issue?
Sorry, I forgot the part in my question, i edited it accordingly. I am using the
resize(...)
.