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

Results not aligned with the rest of the map and with scans #59

Open
Marabir opened this issue May 25, 2023 · 2 comments
Open

Results not aligned with the rest of the map and with scans #59

Marabir opened this issue May 25, 2023 · 2 comments

Comments

@Marabir
Copy link

Marabir commented May 25, 2023

I run turtlebot simulation with amcl localization in gazebo, change laser scan to pointcloud with code attached below.

filtered_cloud which I got is well aligned in rviz, but the result of the kf_tracker is not. It is shifted as it does not get proper localization from amcl or tf tree and when I ordered robot to move around, it rotates in the opposite direction as the robot does.

Screenshot from 2023-05-25 19-54-02

where maybe better visible
Screenshot from 2023-05-25 20-16-59

this is the code which I use to transform scans to pointclouds, but as I mentioned, filtered_cloud is aligned well in rviz :/

#include "ros/ros.h"
#include "sensor_msgs/LaserScan.h"
#include "sensor_msgs/PointCloud2.h"
#include "laser_geometry/laser_geometry.h"
#include "tf/transform_listener.h"


int main(int argc, char** argv){
    
    ros::init(argc, argv, "laser_scan_to_pointcloud");

    ros::NodeHandle nh;
    laser_geometry::LaserProjection projector;
    tf::TransformListener listener_;
    

    ros::Publisher pub = nh.advertise<sensor_msgs::PointCloud2>("/filtered_cloud",1);

    ros::Subscriber sub = nh.subscribe<sensor_msgs::LaserScan>("/scan", 1, [&](const sensor_msgs::LaserScan::ConstPtr& scan) {
        
        if(!listener_.waitForTransform(
            scan->header.frame_id,
            "/base_link",
            scan->header.stamp + ros::Duration().fromSec(scan->ranges.size()*scan->time_increment),
            ros::Duration(1.0))){
                return;
            }
        
        
        // Convert the laser scan to a point cloud
        sensor_msgs::PointCloud2 cloud;
        projector.transformLaserScanToPointCloud("base_link",*scan, cloud,listener_);

        // Publish the point cloud
        pub.publish(cloud);
    });

    ros::spin();

   return 0;
}

I will be grateful for your help 😃

@wangsh386
Copy link

Hello, could you please share your point cloud file? We would like to try the effect you did, and we would greatly appreciate it [email protected]

@Marabir
Copy link
Author

Marabir commented May 31, 2023

Hi, I've sent you an email with rosbag containing important topics 😃

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

2 participants