Can't view lidar points in rviz.

asked 2020-02-13 18:16:41 -0600

Pujie gravatar image

Hi,

I try to view the lidar points in Rviz, and I tf broadcast topic /scan to /world. But I don't write a tf listener. Here is broadcaster.

#include <ros/ros.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2_ros/transform_broadcaster.h>
#include <geometry_msgs/TransformStamped.h>


int main(int argc, char** argv){
  ros::init(argc, argv, "lidar_tf");
  ros::NodeHandle node;
    static tf2_ros::TransformBroadcaster br;

    ros::Rate r(100);

  geometry_msgs::TransformStamped transformStamped;

  transformStamped.header.stamp = ros::Time::now();
  transformStamped.header.frame_id = "world";
  transformStamped.child_frame_id = "scan";
  transformStamped.transform.translation.x = -0.12;
  transformStamped.transform.translation.y = -0.057;
  transformStamped.transform.translation.z = 0.0101;
  tf2::Quaternion q;
  q.setRPY(1.6620416578885813e+00, 2.7298435352041510e-02,1.5608089396014240e+00);
  transformStamped.transform.rotation.x = q.x();
  transformStamped.transform.rotation.y = q.y();
  transformStamped.transform.rotation.z = q.z();
  transformStamped.transform.rotation.w = q.w();

    while(node.ok()){
        br.sendTransform(transformStamped);
    }

  return 0;
}

Here is what my rviz show. image description

When I rostopic echo /scan, I do get the data.I am pretty sure /scan really return the data. However, I can't find scan points in rviz.

Could you please help to give any recommendation?

edit retag flag offensive close merge delete

Comments

what happens if you change global options from world to scan , do you see laserscan then ?

Fetullah Atas gravatar image Fetullah Atas  ( 2020-02-13 19:12:33 -0600 )edit

It seems that something wrong in my broadcaster. Because when I turn off the broadcaster, and then I set Fixed frame as "scan", the lidar points show. Thank you for your recommendation.

Pujie gravatar image Pujie  ( 2020-02-13 19:18:01 -0600 )edit
1

you may consider to use tf static_transform_publisher, if your LIDAR is fixed to the base which I think it should be. This could be frequency related,just a wild guess

Fetullah Atas gravatar image Fetullah Atas  ( 2020-02-13 19:20:56 -0600 )edit