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

RVIZ: Display own pointcloud

asked 2016-08-24 07:04:26 -0500

JanB gravatar image

updated 2016-08-25 05:43:30 -0500

I try to build my own point cloud with a gaussian distribution. The visualization with rviz doesn't work.

Here is how I create the pointcloud

int sizeOfCloud = 1000;
keypoints.points.resize(sizeOfCloud);
getRandomPointCloud(keypoints, 100, 100, sizeOfCloud);

keypoints.header.frame_id = "base_link";
keypoints.header.stamp = ros::Time::now();
keypoints_publisher.publish(keypoints);

and here is the function getRandomPointCloud:

void getRandomPointCloud(sensor_msgs::PointCloud& pc, int centerX, int centerY, int& sizeOfCloud) {
    std::random_device rd;
    std::mt19937 gen(rd());
    std::normal_distribution<> distX(centerX, 10);
    std::normal_distribution<> distY(centerY, 10);


    for (int i = 0; i < pc.points.size(); i++) {
        double xValue = distX(gen);
        double yValue = distY(gen);
        std::cout << std::round(xValue) << std::endl;
        pc.points[i].x = std::round(xValue);
        pc.points[i].y = std::round(yValue);
    }
    std::cout << "done" << std::endl;
}

As I said, it can't be displayed in rviz. I do select by topic, select the proper topic and then there is nothing on the screen. Topic is correct and if I set the grid to base_link then everything with the topic is okay. Maybe I have to set a special attribute in rviz or I don't build my pointcloud correctly.

Edit: My Publisher:

ros::Publisher keypoints_publisher;
keypoints_publisher = nh.advertise<sensor_msgs::PointCloud>("/keypoints", 1000);

Edit2:

Here is a screenshot of rviz. Maybe this shows my problem better

Screenshot RVIZ

edit retag flag offensive close merge delete

Comments

How is your keypoints_publisher defined?

Shay gravatar image Shay  ( 2016-08-24 08:11:55 -0500 )edit

I've edited it in my question. Sorry for forgetting this piece of code.

JanB gravatar image JanB  ( 2016-08-24 09:25:29 -0500 )edit

What is your fixed frame, the first line of Displays window.

Shay gravatar image Shay  ( 2016-08-25 08:18:59 -0500 )edit

I've writen base_link in Fixed Frame

JanB gravatar image JanB  ( 2016-08-25 09:01:04 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-24 21:23:14 -0500

Shay gravatar image
  1. Do rostopic echo /keypoints and see if the messages are right.

  2. Add a PointCloud in RViz, select that /keypoints topic, see if the status is OK.

  3. Choose base_link as the fixed frame, see if everything is all right. If you want odom or map to be the fixed frame, you need to make sure your tf odom->base_link or map->odom->base_link is provided.

edit flag offensive delete link more

Comments

1

These debugging steps are a great place to start. Without seeing the whole program it's hard to know, but perhaps you're publishing a single point cloud immediately after calling advertise() ? Since the peer-to-peer connections take time to set up, it's recommended to (re)publish topics periodically

Morgan gravatar image Morgan  ( 2016-08-24 21:29:50 -0500 )edit

Thank you, step 1 and 2 is already done and successful. Step 3 is a little bit confusing to me. I don't know how to solve this base_link fixed frame. I edited my initial post to show a screen shot from my rviz.

JanB gravatar image JanB  ( 2016-08-25 05:45:03 -0500 )edit

@Morgan has a good point, are you just publishing the cloud once? If so, you should try publishing it periodically, like once every second until you get things working.

Airuno2L gravatar image Airuno2L  ( 2016-08-25 06:45:34 -0500 )edit

thank you. I do publish it for a static period. And the published cloud can be seen with "rostopic echo /keypoints"

JanB gravatar image JanB  ( 2016-08-25 07:34:17 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-08-24 07:04:26 -0500

Seen: 1,025 times

Last updated: Aug 25 '16