Keyboard client for object and robot control
| 104 | |
| 105 | |
| 106 | class ObjectKeyboardClient: |
| 107 | """Keyboard client for object and robot control""" |
| 108 | |
| 109 | def __init__( |
| 110 | self, |
| 111 | entity_names: list[str], |
| 112 | entity_types: list[str], |
| 113 | entity_joints: dict[str, list[str]], |
| 114 | width: int = 550, |
| 115 | height: int = 650, |
| 116 | title: str = "Object/Robot Control", |
| 117 | ): |
| 118 | pygame.init() |
| 119 | self.screen = pygame.display.set_mode((width, height)) |
| 120 | pygame.display.set_caption(title) |
| 121 | self.clock = pygame.time.Clock() |
| 122 | self.font = pygame.font.Font(None, 28) |
| 123 | self.small_font = pygame.font.Font(None, 22) |
| 124 | |
| 125 | self.entity_names = entity_names |
| 126 | self.entity_types = entity_types |
| 127 | self.entity_joints = entity_joints |
| 128 | self.selected_idx = 0 |
| 129 | |
| 130 | # Joint control mode |
| 131 | self.joint_mode = False |
| 132 | self.selected_joint_idx = 0 |
| 133 | |
| 134 | self.instructions = [ |
| 135 | "=== Object/Robot Control ===", |
| 136 | "", |
| 137 | " Movement:", |
| 138 | " UP - Move +X", |
| 139 | " DOWN - Move -X", |
| 140 | " LEFT - Move +Y", |
| 141 | " RIGHT - Move -Y", |
| 142 | " e - Move +Z", |
| 143 | " d - Move -Z", |
| 144 | "", |
| 145 | " Rotation:", |
| 146 | " q - Roll +", |
| 147 | " w - Roll -", |
| 148 | " a - Pitch +", |
| 149 | " s - Pitch -", |
| 150 | " z - Yaw +", |
| 151 | " x - Yaw -", |
| 152 | "", |
| 153 | " Joint Control:", |
| 154 | " UP - Increase angle", |
| 155 | " DOWN - Decrease angle", |
| 156 | " LEFT - Previous joint", |
| 157 | " RIGHT - Next joint", |
| 158 | "", |
| 159 | " Control:", |
| 160 | " TAB - Switch entity", |
| 161 | " j - Toggle joint mode", |
| 162 | " c - Save poses", |
| 163 | " ESC - Quit", |