ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

laserscan to cloud display "live"

asked 2017-02-06 08:48:45 -0500

Ben gravatar image

updated 2017-02-06 08:50:05 -0500

Hello everybody!

I got a littlebit stucked in my progress. I manged to build a node, which converts my laserscan data "/hokuyo_laser_link" to a pointcloud2 topic "cloud". When i record data and play it back - the node works perfect and i can see my /cloud in RVIZ.

But when I start the node during a "live" test, nothing happens: thats my progress:

  1. connect via ssh to my kobuki bringup ros on the kobuki
  2. second terminal: export ROS_MASTER_URI=http://kobukiIP export ROS_IP=http:://kobukiIP rosrun rviz rviz (everthing works fine)

  3. second terminal: export ROS_MASTER_URI=http://kobukiIP export ROS_IP=http:://kobukiIP ./pointcloud2

  4. In RVIZ: Poincloud2 -> status /cloud topic ok but i cant see anything

here is my node:

#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl_ros/point_cloud.h>
#include <boost/foreach.hpp>
#include <pcl/io/pcd_io.h>
#include <tf/transform_listener.h>
#include <laser_geometry/laser_geometry.h>

 ros::Publisher pub;

class My_Filter {
     public:
        My_Filter();
        void scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan);
     private:
        ros::NodeHandle node_;
        laser_geometry::LaserProjection projector_;
        tf::TransformListener tfListener_;

        ros::Publisher point_cloud_publisher_;
        ros::Subscriber scan_sub_;
         };

My_Filter::My_Filter(){
        scan_sub_ = node_.subscribe<sensor_msgs::LaserScan> ("/scan", 100, &My_Filter::scanCallback, this);
        point_cloud_publisher_ = node_.advertise<sensor_msgs::PointCloud2> ("/cloud", 100, false);
       tfListener_.setExtrapolationLimit(ros::Duration(0));
}

void My_Filter::scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan){
    sensor_msgs::PointCloud2 cloud;
std::cout << " ich bin drin" << std::endl;
    projector_.transformLaserScanToPointCloud("/hokuyo_laser_link", *scan, cloud, tfListener_);
    point_cloud_publisher_.publish(cloud);
}



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

    My_Filter filter;

    ros::spin();

    return 0;
}

Has anyone an idea?

Thank you all in advance!

Cheers!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-02-06 10:27:35 -0500

Ben gravatar image

updated 2017-02-07 11:52:06 -0500

ahendrix gravatar image

Ok, got it: you dont have to do

export ROS_IP=KobukiIP

before starting the node.

edit flag offensive delete link more

Comments

That would never work, as ROS_IP is supposed to only contain an ip address, not a URI.

gvdhoorn gravatar image gvdhoorn  ( 2017-02-06 11:37:23 -0500 )edit

Despite having different names, ROS_IP and ROS_HOSTNAME are treated identically.

ahendrix gravatar image ahendrix  ( 2017-02-06 16:36:35 -0500 )edit

But http://.. is still not a valid hostname ;)

gvdhoorn gravatar image gvdhoorn  ( 2017-02-07 02:16:52 -0500 )edit

Yeah, you are total right. I just use this to describe it here in the thread (i dont want to post my real adress)

Ben gravatar image Ben  ( 2017-02-07 02:52:57 -0500 )edit

So in your real configuration, you did not use ROS_IP=http://..?

gvdhoorn gravatar image gvdhoorn  ( 2017-02-07 03:41:24 -0500 )edit

No, in my setup,i was not able to start RVIZ until i export the ROS_IP=ipofmyremotecomputer I followed this tutorial: www.umiacs.umd.edu/~cteo/umd-erratic-ros-data/README-rvis-remote

Ben gravatar image Ben  ( 2017-02-07 05:49:51 -0500 )edit

I specifically asked whether you added the http:// prefix to the IP, but I think we got that cleared up.

In any case: ROS_IP and ROS_HOSTNAME should not include the http:// prefix.

gvdhoorn gravatar image gvdhoorn  ( 2017-02-07 07:51:21 -0500 )edit

@gvdhoorn: ah, yes. The http:// prefix is inappropriate here.

ahendrix gravatar image ahendrix  ( 2017-02-07 11:51:57 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-06 08:48:45 -0500

Seen: 329 times

Last updated: Feb 07 '17