Getting polar_scan_matcher package working with published laser scanner message [closed]
I am running 2 nodes. One is psm_node (from polar_scan_matcher package) and the other one is my own node (publisher_node) that publishes scan messages.
When running those 2 nodes, I had a warning that I guess causing the rviz not visualizing as expected. The publisher is publishing messsages, however, in the rviz, from laser scan tab, it says "Showing [0] points from [0] messages". The warning is as below, from the terminal:
[ WARN] [1322334049.869100511]: ScanMatcherNode: Could get initial laser transform, skipping scan (Frame id /laser_frame does not exist! Frames (3): Frame /laser exists with parent /base_link.
Frame /base_link exists with parent NO_PARENT.
Anyway, the following is my launch file:
<launch>
<param name="/use_sim_time" value="false"/>
<node pkg="rviz" type="rviz" name="rviz"
args="-d $(find polar_scan_matcher)/demo/demo.vcg"/>
<!-- I include this, our own node -->
<node pkg="pcd_robot" type="publisher_node" name="publisher_node">
<remap from="/scan" to="scan"/>
</node>
<node pkg="polar_scan_matcher" type="psm_node" name="psm_node" output="screen">
<param name="max_error" value="0.20"/>
<param name="search_window" value="100"/>
</node>
<node pkg="tf" type="static_transform_publisher" name="base_link_to_laser"
args="0.0 0.0 0.0 0 0 0 /base_link /laser 40" />
</launch>
Below is my code that is supposed to publish the laser scan messages(it's already working as a single node, but still cannot be used with psm_node):
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>
#include <fstream>
#include <sensor_msgs/LaserScan.h>
#include <sensor_msgs/PointCloud.h>
#include <sensor_msgs/PointCloud2.h>
#include "geometry_msgs/Twist.h"
#include "geometry_msgs/Pose.h"
#include "geometry_msgs/PoseStamped.h"
#include <vector>
#include "laser_geometry/laser_geometry.h"
#include <tf/transform_listener.h>
#include <boost/algorithm/string.hpp>
#include "tf/tf.h"
#include "tf/transform_datatypes.h"
#include <tf/transform_broadcaster.h>
// PCL specific includes
#include <pcl/ros/conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/ros/conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include "pcl/common/angles.h"
using namespace std;
const int num_row = 264;
const int num_column = 1089;
class PointCloud
{
private:
ros::NodeHandle n;
// ros::Publisher chatter_pub;
ros::Publisher scan_pub;
ros::Publisher pose_pub;
int count;
vector<vector<double> > data_set;
public:
PointCloud();
~PointCloud();
/**
* Opens and reads file
*/
bool operateFile();
void publishLaser();
// void display(); //translate and publish
};
PointCloud::PointCloud()
{
scan_pub = n.advertise<sensor_msgs::LaserScan>("/scan", 50);
count = 0;
}
PointCloud::~PointCloud()
{
ROS_INFO("Shutting down publisher_node node.");
}
/**
* @brief Opens and reads file for further processing
*
* @param
*
* @return True if the file is successfully manipulated
*/
bool PointCloud::operateFile()
{
ifstream inFile; // object for reading from a file
ofstream outFile; // object for writing to a file
char inputFilename[] = "/home/alfa/ros_workspace/dataset1.txt";
inFile.open(inputFilename, ios::in);
if (!inFile) {
cerr << "Can't open input file " << inputFilename << endl;
exit(1);
}
else
cout << "The file is successfully opened :-)" << endl;
// Set up sizes. (num_row x num_column)
data_set.resize(num_row);
for (int i = 0; i < num_row; ++i)
data_set[i].resize(num_column);
// Store in a buffer/vector what have been read.
for (int j = 0; j < num_row; j++)
for (int k = 0; k < num_column; k++)
{
inFile >> data_set ...