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

Vibrating point cloud in rviz.

asked 2019-11-20 09:47:03 -0600

asbird gravatar image

updated 2019-11-21 01:57:27 -0600

image description

So as you can see on the code I'm creating two subscribing nodes:

  1. Subscribing from laser scanner
  2. Subscribing /tf which is result of transformation /odom -> /robot

In this code I'm using tf2_sensor_msgs to transform point_cloud (which is just /mybot/laser/scan transformed into point_cloud) with do_transform_cloud()using /tf and publish it to topic /laserPointCloud.

My problem is that when I'm publishing it to RVIZ i can see some kind of vibrations of the subscribed point_cloud. I was thinking that it may be because frequency of publishing /mybot/laser/scan is 40Hz and of the /tf 30 but I've made two separate scripts to publish pointcloud at 30Hz (to be the same as /tf using rate.sleep()) and it didn't help (the vibrations appeared like in the given code).

Ubuntu:18.04 LTS / ROS: Melodic

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-11-22 03:15:11 -0600

tfoote gravatar image

Oh, well that's your problem. You shouldn't be subscribing to the '/tf' topic directly. You should be using alistener and a buffer so that the library does all the math for you.

http://wiki.ros.org/tf2/Tutorials/Wri...

Then use the 'transform' method from the BufferInterface http://docs.ros.org/melodic/api/tf2_r...

edit flag offensive delete link more
0

answered 2019-11-20 15:34:22 -0600

asbird gravatar image

updated 2019-11-22 03:02:07 -0600

The problem was that both /gazebo and /robot_state_publisher were publishing /tf and my callback for /tf subscribing node looked like this

def transformCallback(self, msg):
    self.transform = msg.transforms[0]
    self.compute_new_pcl()

This is how looks /tf from /gazebo

transforms: 
  - 
    header: 
      seq: 0
      stamp: 
        secs: 1842
        nsecs: 696000000
      frame_id: "odom"
    child_frame_id: "chassis"
    transform: 
      translation: 
        x: 0.150801946695
        y: -0.766858491599
        z: 0.100001299784
      rotation: 
        x: 2.87981408951e-06
        y: -3.24224228361e-06
        z: 0.691690448705
        w: 0.722194103515

/robot_state_publisher publishes also other transformations like from the chassis to the wheel and that's the reason that it has fixed values which caused vibrations. When you subscribe a topic from python a node which has 2 publishers, once it loads from /gazebo and other time from /robot_state_publisher so I've updated /tf callback a little bit

    if (msg.transforms[0].header.frame_id == 'odom' and 
        msg.transforms[0].child_frame_id=='chassis'):
        self.transform = msg.transforms[0]
        self.compute_new_pcl()

The bigger vibrations are now smaller than earlier but still it is showing some noise and displacement.I thinkdo_transform_cloud(self.point_cloud, self.transform) makes this kind of noise or maybe the need of two values from two subscribed nodes ?

image description Blue is laser scan and red is transformed point cloud.

edit flag offensive delete link more

Comments

What did you change that makes you think rviz was "causing" the vibrations?

tfoote gravatar image tfoote  ( 2019-11-20 15:36:36 -0600 )edit

I needed to extract laser_scan in order to transform it into the other frame so i can apply an algorithm in python to this data. The point cloud which I'm displaying (vibrating one) after applying transformation is in /odom frame. Then I'm subscribing transformed point_cloud2 with rviz with fixed frame /odom and it jumps so i assume that it tries to transform transformed frame and it vibrates ?

asbird gravatar image asbird  ( 2019-11-21 01:23:16 -0600 )edit

That's not a good assumption if it's already in the desired frame it won't apply a transform. At first glance this looks like noise in your system. Do you have highly accurate odometry? You should work to find what causes the noise and then slowly isolate the noisy signal to figure out where it's coming from.

tfoote gravatar image tfoote  ( 2019-11-21 04:34:07 -0600 )edit

I've figured out that when i echo the /tf without rviz turned on it shows how x, y, z and rotation changes but when i turn on the rviz echo /tf outputs 0,0,0 etc

asbird gravatar image asbird  ( 2019-11-21 05:23:11 -0600 )edit
1

That sounds like you might have multiple data sources publishing tf data that's close but not quite the same.

tfoote gravatar image tfoote  ( 2019-11-21 05:27:49 -0600 )edit

Yes, now I can see that /gazebo and /robot_state_publisher nodes are publishing /tf .

asbird gravatar image asbird  ( 2019-11-21 05:36:51 -0600 )edit

That's not inherently a problem. /tf is designed to have multiple sources. You need to see if there are conflicts.

If you want to have more help you'll want to be able to provide more details or how to reproduce your issue.

tfoote gravatar image tfoote  ( 2019-11-21 17:40:07 -0600 )edit

@tfoote I've edited my answer

asbird gravatar image asbird  ( 2019-11-22 02:24:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-11-20 09:47:03 -0600

Seen: 717 times

Last updated: Nov 22 '19