Compute the robot tilt angle using the internal accelerometer

Hi all,

If you have a system where the mounting tilt angle of the robot varies, or is unknown at boot, you can compute it like this:

global a=get_tool_accelerometer_reading()
global x_tgt= get_target_tcp_pose()
global R=p[0,0,0,x_tgt[3],x_tgt[4],x_tgt[5]]
global a_tool=p[a[0],a[1],a[2],0,0,0]
global a_base= pose_trans(R,a_tool)
global g=[a_base[0],a_base[1],a_base[2]]

Then you can set the gravity vector with

set_gravity(g).

For setting gravity at runtime, if the robot is mounted on an external axis, consider also set_base_acceleration()

See script manual for more details set_base_acceleration(a)

compute_gravity_vector.urp (1.2 KB)

3 Likes

That’s cool!

Does the accelerometer have the necessary precision, though? :slight_smile: I would imagine the slightest angle off could cause protective stops due to wrong current limitations.

That is a good point. If the angle is not relatively accurate, you might get issues with protective stops if you also have low force limits, and want to move fast with high payloads.

This method is only an option when it is not possible to just set the mounting angle from PolyScope. For some applications - e.g. mobile UR3’s used in shipyard welding or similar, this could be useful.

Sampling a short sequence of acceleration readings and filtering could improve the quality of the estimate.