Getting polar_scan_matcher package working with published laser scanner message [closed]

asked 2011-12-02 06:28:05 -0600

alfa_80 gravatar image

updated 2011-12-07 18:06:50 -0600

kwc gravatar image

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 ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2013-09-06 13:29:20

Comments

Have you tried using laser_scan_matcher? I moved my efforts to that one.
Ivan Dryanovski gravatar image Ivan Dryanovski  ( 2011-12-03 05:27:33 -0600 )edit
I've just tried laser_scan_matcher, however, I still got the similar error([ WARN] [1323010737.488732601]: ScanMatcher: Could not get initial laser transform(Frame id /laser_frame does not exist! Frames (3): Frame /laser exists with parent /base_link. Frame /base_link exists with parent NO_PARENT. )
alfa_80 gravatar image alfa_80  ( 2011-12-04 01:02:39 -0600 )edit
Hopefully, you can guide me on this..thanks in advance.
alfa_80 gravatar image alfa_80  ( 2011-12-04 01:04:15 -0600 )edit
The strange thing also, the publisher is publishing messsages (after running "rostopic echo -c /scan" in the terminal), however, in the rviz, from laser scan tab, it says "Showing [0] points from [0] messages".
alfa_80 gravatar image alfa_80  ( 2011-12-04 01:28:20 -0600 )edit
In rviz, instead of setting fixed frame as /world, can I set it to "/laser"? I've tried to set the fixed frame as /laser and target frame as "base_link", it works but still in the TF option, for /world, it complaints "No transform from [/world] to frame [/laser]". Having /world is important right?
alfa_80 gravatar image alfa_80  ( 2011-12-04 01:55:23 -0600 )edit
Try running the laser_scan_matcher demo, and look at how the tf's and topics look in rviz
Ivan Dryanovski gravatar image Ivan Dryanovski  ( 2011-12-04 02:29:12 -0600 )edit
As I followed the setting in laser_scan_matcher demo, I got 2 errors in rviz: (1) In TF, under /laser frame, it complaints that "No transform from [/laser] to frame [/world]" "
alfa_80 gravatar image alfa_80  ( 2011-12-04 03:22:08 -0600 )edit
(2) In Laser Scan, under transforms, it says that "For frame [laser]: No transform to fixed frame [/world]. TF error: [Unable to lookup transform, cache is empty, when looking up transform from frame [/laser] to frame [/world]]"
alfa_80 gravatar image alfa_80  ( 2011-12-04 03:22:37 -0600 )edit