flexivrobotics / flexiv_rdk

RDK (robotic development kit) for Flexiv robots. Supports C++ and Python. Compatible with Linux, macOS, and Windows.
Apache License 2.0
58 stars 18 forks source link

[BUG] Termination condition for Contact Primitive #65

Closed yellownebula10 closed 1 month ago

yellownebula10 commented 1 month ago

Version information

Describe the bug When polling primitive states to determine that the contact primitive has terminated, if the termination condition is set to 'terminated' == '1' as specified by the primitives documentation, the condition is never met.

Steps to reproduce

  1. Send contact primitive to robot with default parameters
  2. Add a while loop polling current primitive states, checking for 'terminated' == '1'
  3. See error

Expected behavior The primitive state 'terminated' should be set to '1'. However, when I print the primitive states as the primitive executes, I notice that ‘terminated’ remains at ‘0’ while ‘primitiveName’ switches to ‘Hold’ from ‘Contact’ and ‘reachedTarget’ is set equal to ‘1’.

Screenshots

Screenshot 2024-06-07 at 5 16 58 PM
kaibiao-flexiv commented 1 month ago

Hi @yellownebula10 ,

In our system, some primitives have a self-termination condition, which means that when the termination condition is met, the primitive will automatically terminate. The Contact primitives you mentioned are among those primitives that can self-terminate. (This is because after contact is made, the robot should not be staying within Contact primitive state)

So the reason that you were not able to reach the 'terminated' == '1'' condition is because at the time you query, the primitive has already met the self-termination condition and has already exited, and the primitive states are no longer available as that primitive is no longer running.

To identify which primitives will terminate by itself: If you spot the primitive's default transition condition is [terminated == 1], then this means it is one of the self-terminated primitives Flexiv Primitives default transition condition image

To check if such primitives are terminated or not, you can use the isBusy() method, below is an example code snippet: image

yellownebula10 commented 1 month ago

Thank you @kaibiao-flexiv !