[ROS2 Humble] Segmentation Fault for assigning Header/Frame ID to shared pointer
Hi Community,
i am currently struggling with some segmentation fault which i don't understand while assigning the Frame ID to the header of a Odometry Message
auto odom_pose = nav_msgs::msg::Odometry::SharedPtr();
// odom_pose->header.stamp = pose->header.stamp;
odom_pose->header.frame_id = std::string("map");
odom_pose->child_frame_id = "track_"+std::to_string(uuid_);
odom_pose->pose = pose->pose;
setCurrentOdomPose(odom_pose);
Does SegFault at the assignment of frame_id, but it also occured that it seg faulted at assigning the stamp or if i would assign directly the header of pose to my odom_pose. I changed the code to create only the Odometry message and later create a shared pointer of it which does not seg fault at the assignment of the Header.
auto odom_pose = nav_msgs::msg::Odometry();
// odom_pose->header.stamp = pose->header.stamp;
odom_pose.header.frame_id = std::string("map");
odom_pose.child_frame_id = "track_"+std::to_string(uuid_);
odom_pose.pose = pose->pose;
auto odom_pose_ptr = std::make_shared<nav_msgs::msg::Odometry>(odom_pose);
setCurrentOdomPose(odom_pose_ptr);
The backtrace didn't give any good information too, it only showed where the segfault occured and in case of assigning the header instead of directly the sub variables i got this additional frame on top.
#0 0x00007f420c3c1904 in std_msgs::msg::Header_<std::allocator<void> >::operator= (
this=0x0)
at /opt/ros/humble/include/std_msgs/std_msgs/msg/detail/header__struct.hpp:36