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

Publishing Marker arrow causes Segmentation fault (core dumped)

asked 2021-05-19 10:54:58 -0500

RaphaelHoefer gravatar image

Hello,

I am trying to publish a marker arrow and want to visualize it in rviz with a start and an end point.

When I am using the points member as described here http://wiki.ros.org/rviz/DisplayTypes... and try to run it I am getting the following error: Segmentation fault (core dumped).

When I am just using the pose.position and pose.orientatien without the points member the arrow is appearing.

    visualization_msgs::Marker markers_msg;
    markers_msg.header.frame_id = "world";
    markers_msg.header.stamp = ros::Time::now();
    markers_msg.ns = "drop";
    markers_msg.id = 0;
    markers_msg.type = visualization_msgs::Marker::ARROW;
    markers_msg.action = visualization_msgs::Marker::ADD;
    markers_msg.pose.position.x = 1;
    markers_msg.pose.position.y = 1;
    markers_msg.pose.position.z = 1;
    markers_msg.pose.orientation.x = 0.0;
    markers_msg.pose.orientation.y = 0.0;
    markers_msg.pose.orientation.z = 0.0;
    markers_msg.pose.orientation.w = 1.0;
    markers_msg.lifetime = ros::Duration(0);
    markers_msg.scale.x = 1;
    markers_msg.scale.y = 0.1;
    markers_msg.scale.z = 0.1;
    markers_msg.color.a = 1.0; // Don't forget to set the alpha!
    markers_msg.color.r = 1.0;
    markers_msg.color.g = 0.0;
    markers_msg.color.b = 0.0;
    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;

I hope anyone can help me. Thank you very much in advance!

Kind regards,

Raphael

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-05-19 11:46:54 -0500

gvdhoorn gravatar image

This looks more like a C++ issue:

visualization_msgs::Marker markers_msg;
...
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;

marker_msgs.points is a std::vector. You don't seem to resize(..) or reserve(..) any elements, so markers_msg.points[1] almost certainly indexes into uninitialised memory.

The [] operator does not perform any bounds checking, so you don't get any errors, but it does cause undefined behaviour.

edit flag offensive delete link more

Comments

Thank you very much! This solved the problem.

RaphaelHoefer gravatar image RaphaelHoefer  ( 2021-05-19 11:58:29 -0500 )edit

Question Tools

Stats

Asked: 2021-05-19 10:54:58 -0500

Seen: 309 times

Last updated: May 19 '21