I just realized one side-effect of the Torque_Off(ID=254) command is that if your robot is a humanoid or manipulator arm, your robot would “spectacularly” collapse on itself when it receives the Torque_Off(ID=254) command!
@dood - you had the right hunch, a better procedure would be:
- Set all DXL goal velocities to ZERO, via ID=254. Your robot would “freeze” at this point in time.
- Now, your program would have the “time” to perform a regular FOR LOOP, based on an index i that varies through your particular group of DXL IDs used on your robot and the body of this FOR LOOP should contain at least this statement:
Goal_Position(i) = Present_Position(i)
This statement is critical because the Previous Goal Position commands were still in-play for all DXLs, you only just set their velocities to 0 due to the emergency so they could not go there (but they still wanted to ). So if later in your program, you reset your DXL Goal Velocities to a non-zero value, your robot would then “suddenly” want to move to its Old Goal Positions - you may not want this behavior from your robot. But with the suggested statement, the DXLs would already be at their “prescribed” Goal Positions when non-zero Velocities are used again. Essentially, your robot would restart from its frozen position (unfortunately, if your robot is a humanoid, most likely it may not be able to hold this frozen position for the FOR LOOP to finish).
Or, if you have a set of SAFE Goal Positions that the robot should be in after an emergency, you can use those values instead of Present Positions in the FOR Loop.
Finally, if you happen to be using ROBOTIS Motion Programming, I am assuming that you are familiar with the Special Motion Index values of 0, -1, -2 and -3?
Best of luck in your project!