Get contact range from contact info. Args: contact (torch.Tensor): contact information (frames, 2). contact_state (bool, optional): contact state. Defaults to True. Returns: list: contact ranges.
(contact: torch.Tensor, contact_state: bool = True)
| 70 | return contact.int() |
| 71 | |
| 72 | def get_range(contact: torch.Tensor, contact_state: bool = True) -> list: |
| 73 | """Get contact range from contact info. |
| 74 | |
| 75 | Args: |
| 76 | contact (torch.Tensor): contact information (frames, 2). |
| 77 | contact_state (bool, optional): contact state. Defaults to True. |
| 78 | |
| 79 | Returns: |
| 80 | list: contact ranges. |
| 81 | """ |
| 82 | contact_state = int(contact_state) |
| 83 | frames = contact.shape[0] |
| 84 | # Get contact range |
| 85 | contact_range = [] |
| 86 | for i in range(contact.shape[1]): |
| 87 | rge = [] |
| 88 | start = -1 |
| 89 | end = -1 |
| 90 | for idx in range(frames): |
| 91 | if contact[idx, i] != contact_state: |
| 92 | continue |
| 93 | if start == -1: |
| 94 | start = idx |
| 95 | end = idx |
| 96 | else: |
| 97 | if idx - end == 1: |
| 98 | end += 1 |
| 99 | else: |
| 100 | rge.append([start, end]) |
| 101 | start = idx |
| 102 | end = idx |
| 103 | if end != -1: |
| 104 | rge.append([start, end]) |
| 105 | contact_range.append(rge) |
| 106 | return contact_range |
| 107 | |
| 108 | def remove_global_translation(joints): |
| 109 | """Remove global translation by subtracting the root joint's position.""" |
no outgoing calls
no test coverage detected