Skip to content

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

Description

@p0rys

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());
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions