# 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?

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


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

## Related Questions

### What does the normalized image coordinates imply?

0  Asked on October 3, 2021 by lzx071021

### Cartesian Velocity Control between Two 3D Poses

2  Asked on October 3, 2021 by john-rowlay

### Rapid code pick and place

1  Asked on October 3, 2021 by ramil-aliyev

### How can I get the equations of motion used in webots?

1  Asked on October 3, 2021 by q-than-a

### Handling Inverse Kinematics error on a UR Robot

1  Asked on October 3, 2021 by user24261

### Can I “shape” the sound of words spoken by Pepper with Phonetic transcription?

1  Asked on October 3, 2021 by buhtz

### How can I receive Genicam packets from a device in a docker container?

2  Asked on October 3, 2021 by thinwybk

### SLAM techniques based on contact, odometry and one front camera

1  Asked on October 3, 2021 by firion

### I wanna make a raspberry pi car using an RC car. I would like to know if the servo multiplexer is necessary?

3  Asked on October 3, 2021 by mahir-ahmed-al

### Collaboration of mobile robot and survaillance camera – classic localization (still) needed?

2  Asked on October 3, 2021 by mrsing

### Does increasing robotic arm’s speed cost replayability?

3  Asked on October 3, 2021 by tomrader

### ROS2 and TypeError when publishing custom message to Topic

1  Asked on October 3, 2021 by anthares

### How to calculate the pitch of the quadcopter rotor blade and their efficiency?

1  Asked on October 3, 2021 by praveen-kumar-selvaraj

### Motion model and homogeneous transformation issue on a drone

1  Asked on October 3, 2021 by adiego73

### BLDC Stuttering when attached to Arduino Nano

1  Asked on October 3, 2021 by moazzam-salman

### Constrained Inverse Kinematics velocity calculation via Jacobian

1  Asked on October 3, 2021 by f-t

### What are joint angles of Kinova Jaco in home position?

1  Asked on October 3, 2021 by anton-kim

### Differential Drive Tricycle WMR with active caster wheel

1  Asked on October 3, 2021 by smarzo

### Determining required torque for DC motor

0  Asked on October 3, 2021 by timetraveller

### How to calculate displacement of the end effector by the yaw, pitch, and roll in the spherical joint?

1  Asked on October 3, 2021

### Ask a Question

Get help from others!