Gravity compensation in robotics is a control technique used to counteract the effect of gravity on a robot's joints or end-effector, so that the robot can hold a desired position or move more naturally and efficiently—as if the weight of the robot or its payload is "cancelled out." or "unweighted."
It can hold the desired position just like servo motor.
But unlike servo motor that cannot move with force, it can move the position while support the weight that feel like nothing on it.
I understand what you mean.
But gravity compensation actually counter the torque that produced by the torque made by weight which is using below equation.
Torque = length from the center of motor * weight * gravity acceleration (9.8 or 10m/s^2)
I know you are saying about Universal Gravitation but I'm using Gravity that use F = mg.