Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FOXY] Segment fault when trying to transform to pointcloud #74

Open
p0rys opened this issue Dec 15, 2020 · 0 comments
Open

[FOXY] Segment fault when trying to transform to pointcloud #74

p0rys opened this issue Dec 15, 2020 · 0 comments

Comments

@p0rys
Copy link

p0rys commented Dec 15, 2020

Hey,

i have a problem using "transformLaserScanToPointCloud" on ROS2 Foxy. I tried the deb package and also a self-compiled version of the foxy branch. The problem is that everytime my node wants to use the function it crashes without any message (even when i used a try-catch block).

I was able to hunt it down to line 68 in laser_geometry.cpp where the rows() function of eigen3 always crashes with a segment fault exception. I already tried to initlize the ArrayXXd before using rows() but it doesn't help.

I'm not sure if this is a bug (maybe in the eigen3 lib) or if i am doing something wrong with the parameters. Not a C++ Dev, so not pretty sure about all the pointer/address stuff.

If it is helpful:
Ubuntu 20.04 as VMware VM (6 Cores, 16GB RAM)
Windows 10 1909 as Host (8 Cores, 32GB RAM)

laser_geometry.cpp Line 68:
if (co_sine_map_.rows() != static_cast<int>(n_pts) || angle_min_ != scan_in.angle_min || angle_max_ != scan_in.angle_max)

my code

void ScanMerger::scan_callback(const sensor_msgs::msg::LaserScan::SharedPtr msg) const
{    
    // waiting for transform
    std::string transform_error;
    if (tf_buffer_->canTransform(
        pointcloud_frame_, 
        msg->header.frame_id, 
        tf2_ros::fromMsg(msg->header.stamp) + tf2::durationFromSec(msg->ranges.size()*msg->time_increment), 
        tf2::durationFromSec(0.1),
        &transform_error)
        )
    {
        // transform to pointcloud2
        sensor_msgs::msg::PointCloud2 cloud;
        auto target_frame = pointcloud_frame_.empty() ? msg->header.frame_id : pointcloud_frame_;
        projector_->transformLaserScanToPointCloud(target_frame, *msg, cloud, *tf_buffer_);
        
        // publish
        pointcloud_publisher_->publish(cloud);  
    }
    else
    {
        RCLCPP_ERROR(get_logger(), "Could not transform message: %s", transform_error.c_str());
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant