Can't view lidar points in rviz.
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.
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?
what happens if you change global options from
world
toscan
, do you see laserscan then ?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.
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