Programming disabled function

What would be the legality of the robot slowly retracting its arm while disabled (but on)? Would this be deemed unsafe?

If it is in software, absolutely a safety violation. I can’t comment on whether or not you CAN do it in software (I’m a hardware guy), but the point of having a disabled robot is that it does not move, and is therefore safe to approach. Robots are disabled when they do something wrong that could break themselves, something else or hurt someone, so under no circumstances do you want a robot that still moves when you disable it, especially under power.

From a mechanical side, there are robots that might move after being disabled due to backdriving motors or pneumatics pressure releases. While not ideal, this can be slightly more safe than software if the devices do not have a lot of energy while moving.

That being said, I would implore you to look into other solutions. Under any circumstance, the best and safest scenario is the robot which doesn’t move at all when disabled.

It is impossible to do in software.

You shouldn’t worry about it moving. Depending on how your code is written, it might be beneficial to you to write the outputs even while disabled, so you can probe the logic and see what it is doing. That said, when exiting disabled, reset all controllers so it will not move after being enabled, until an input is given.

If it moves while disabled, that is mechanical backdrive.