-
Notifications
You must be signed in to change notification settings - Fork 9
Add light keyboard control #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,15 +51,15 @@ def gizmo_transform_callback(node, translation, rotation, flag): | |||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| def run_gizmo_robot_control_loop( | ||||||||||||||
| robot: "Robot", control_part: str = "arm", end_link_name: str | None = None | ||||||||||||||
| robot: object | str, control_part: str = "arm", end_link_name: str | None = None | ||||||||||||||
| ): | ||||||||||||||
| """Run a control loop for testing gizmo controls on a robot. | ||||||||||||||
|
|
||||||||||||||
| This function implements a control loop that allows users to manipulate a robot | ||||||||||||||
| using gizmo controls with keyboard input for additional commands. | ||||||||||||||
|
|
||||||||||||||
| Args: | ||||||||||||||
| robot (Robot): The robot to control with the gizmo. | ||||||||||||||
| robot (Robot | str): The robot to control with the gizmo. | ||||||||||||||
| control_part (str, optional): The part of the robot to control. Defaults to "arm". | ||||||||||||||
| end_link_name (str | None, optional): The name of the end link for FK calculations. Defaults to None. | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -87,6 +87,9 @@ def run_gizmo_robot_control_loop( | |||||||||||||
|
|
||||||||||||||
| sim = SimulationManager.get_instance() | ||||||||||||||
|
|
||||||||||||||
| if isinstance(robot, str): | ||||||||||||||
| robot = sim.get_robot(uid=robot) | ||||||||||||||
|
||||||||||||||
| robot = sim.get_robot(uid=robot) | |
| robot_uid = robot | |
| robot = sim.get_robot(uid=robot_uid) | |
| if robot is None: | |
| log_error(f"Robot with uid '{robot_uid}' not found; aborting gizmo control loop.") | |
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type hint for the 'robot' parameter uses 'object | str' in the function signature, but the docstring specifies 'Robot | str'. For consistency and better type safety, consider using the specific type 'Robot | str' in the function signature. The Robot class is already imported at line 83 inside the function, and could be imported at the module level or used with TYPE_CHECKING (which is already imported at line 24) and forward references like the existing pattern at lines 27-28.