# Calculating the distance of a point from point cloud data

Robotics Asked by paul-shuvo on January 2, 2022

I’m getting the x,y,z values for three points as follows:

x : -0.357200 y: -0.205010 z: 0.940000

x : -0.310266 y: -0.200437 z: 0.961000

x : -0.299289 y: -0.140374 z: 0.927000

and the point cloud :

Why are some of the values negative?

Does z: 0.961000 mean it is 0.961 meter away towards the z axis?

Also, how is the center of these x,y,z axes computed?

## 2 Answers

The XYZ readings from the camera are in the reference frame of the camera. @FooBar is correct about the X/Y values: they are planar about the center of the camera, just like the OpenGL viewing window. I don't know the maximum range of the point-cloud data, but my suspicion is that the maximum z value is 1. (This could change, however, depending if you have a multi-camera setup, but I don't have the experimental dtaa to prove one way or the other, and that is outside the scope of the original question.)

RViz is built on OpenGL (though the robotics frames are not necessarily following the same standard, just that they share many similar design choices), so I suggest you look up the documentation for versions 4.X. Here is a great explanation of OpenGL coordinate frames, not that you needed to go into that much detail, but it helped me a lot.

Back to ROS: If you want to get the coordinates in the world frame rather than the local camera frame, there are 2 things you need.

1. The location of the camera w.r.t. world frame
2. The Point cloud data

You can then create a new frame transform object with no rotation offset from the camera (Unit quaternion with 0 rotations). You can then take your camera frame and the newly computed frame and then extract the frame transform

For clarity:

1. World frame
2. Camera frame
3. Point frame

Since I don't know what language you are using, I refer will refer you to these links regarding frame transforms.

https://wiki.ros.org/tf
https://wiki.ros.org/tf/Overview/Transformations
https://docs.ros.org/kinetic/api/tf/html/c++/index.html
https://answers.ros.org/question/210572/what-is-a-frame/


Answered by robotsfoundme on January 2, 2022

These values are relative to the camera. Z is always positive as the camera can't see what is behind. X and Y can be positive or negative depending on if an object is left/right or higher/lower than the camera's viewing direction.

Answered by FooTheBar on January 2, 2022

## Add your own answers!

### Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP