-
Notifications
You must be signed in to change notification settings - Fork 11
bowl and microwave env #24
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
Open
LeonLiu4
wants to merge
10
commits into
yun-long:main
Choose a base branch
from
LeonLiu4:bowl-environment-only
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0310dae
bowl and microwave env
LeonLiu4 42d5e8a
Add HangLifebuoyEnv with generic teleop wrapper
LeonLiu4 26fbc52
sweep table
LeonLiu4 11e7b7e
broom
LeonLiu4 9c8ba63
mend
LeonLiu4 bf74810
changed configuration and obs from tensor to dict
LeonLiu4 662cfa7
pyright fixes
LeonLiu4 3a88122
changed apply action if else logic and num envs hardcode
LeonLiu4 39cd96c
pyright fix
LeonLiu4 b076bf5
rbg image in observation
LeonLiu4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Teleop script for Hang Lifebuoy environment. | ||
| """ | ||
|
|
||
| import genesis as gs | ||
| import torch | ||
| from gs_agent.wrappers.teleop_wrapper import KeyboardWrapper | ||
| from gs_env.sim.envs.config.registry import EnvArgsRegistry | ||
| from gs_env.sim.envs.manipulation.hang_lifebuoy_env import HangLifebuoyEnv | ||
|
|
||
|
|
||
| def main() -> None: | ||
| """Run teleop for hang lifebuoy task.""" | ||
| print("Initializing Hang Lifebuoy Teleop System...") | ||
|
|
||
| # Initialize Genesis | ||
| gs.init( | ||
| seed=0, | ||
| precision="32", | ||
| logging_level="info", | ||
| backend=gs.cpu, | ||
| ) | ||
|
|
||
| # Create teleop wrapper first (without environment) | ||
| print("Creating teleop wrapper...") | ||
| teleop_wrapper = KeyboardWrapper( | ||
| env=None, | ||
| device=torch.device("cpu"), | ||
| movement_speed=0.01, # Position movement speed | ||
| rotation_speed=0.05, # Rotation speed | ||
| trajectory_filename_prefix="hang_lifebuoy_", | ||
| ) | ||
|
|
||
| # Start teleop wrapper (keyboard listener) FIRST, before creating Genesis scene | ||
| teleop_wrapper.start() | ||
|
|
||
| # Create task environment AFTER teleop wrapper is running | ||
| env = HangLifebuoyEnv( | ||
| args=EnvArgsRegistry["hang_lifebuoy_default"], | ||
| device=torch.device("cpu"), | ||
| ) | ||
| teleop_wrapper.set_environment(env) | ||
|
|
||
| print("\n" + "=" * 50) | ||
| print("Hang Lifebuoy TELEOP SYSTEM READY") | ||
| print("=" * 50) | ||
| print("📝 TRAJECTORY RECORDING INSTRUCTIONS:") | ||
| print(" 1. Press 'r' to start recording (anytime)") | ||
| print(" 2. Move robot with arrow keys, n/m, space") | ||
| print(" 3. Press 'r' again to stop recording and save") | ||
| print(" 💡 Recording works from any state now!") | ||
| print("=" * 50) | ||
|
|
||
| # Run the main control loop in the main thread (Genesis viewer requires this) | ||
| try: | ||
| step_count = 0 | ||
| while teleop_wrapper.running: | ||
| # Step the teleop wrapper (this processes input and steps environment) | ||
| teleop_wrapper.step(torch.tensor([])) | ||
| step_count += 1 | ||
|
|
||
| # Check for quit command | ||
| if ( | ||
| hasattr(teleop_wrapper, "last_command") | ||
| and teleop_wrapper.last_command | ||
| and hasattr(teleop_wrapper.last_command, "quit_teleop") | ||
| and teleop_wrapper.last_command.quit_teleop | ||
| ): | ||
| print("Quit command received, exiting...") | ||
| break | ||
|
|
||
| # Safety check - exit after 1 hour of running | ||
| if step_count > 180000: # 1 hour at 50Hz | ||
| print("Maximum runtime reached, exiting...") | ||
| break | ||
|
|
||
| except KeyboardInterrupt: | ||
| print("\n👋 Teleop interrupted by user") | ||
|
|
||
| finally: | ||
| # Cleanup | ||
| teleop_wrapper.stop() | ||
| print("✅ Teleop session ended") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Teleop script for Put Bowl Inside Microwave environment. | ||
| """ | ||
|
|
||
| import genesis as gs | ||
| import torch | ||
| from gs_agent.wrappers.teleop_wrapper import KeyboardWrapper | ||
| from gs_env.sim.envs.config.registry import EnvArgsRegistry | ||
| from gs_env.sim.envs.manipulation.put_bowl_inside_microwave_env import PutBowlInsideMicrowaveEnv | ||
|
|
||
|
|
||
| def main() -> None: | ||
| """Run teleop for put bowl inside microwave task.""" | ||
| print("Initializing Put Bowl Inside Microwave Teleop System...") | ||
|
|
||
| # Initialize Genesis | ||
| gs.init( | ||
| seed=0, | ||
| precision="32", | ||
| logging_level="info", | ||
| backend=gs.cpu, # type: ignore | ||
| ) | ||
|
|
||
| # Create teleop wrapper first (without environment) | ||
| print("Creating teleop wrapper...") | ||
| teleop_wrapper = KeyboardWrapper( | ||
| env=None, | ||
| device=torch.device("cpu"), | ||
| movement_speed=0.01, # Position movement speed | ||
| rotation_speed=0.05, # Rotation speed | ||
| trajectory_filename_prefix="put_bowl_microwave_", | ||
| ) | ||
|
|
||
| # Start teleop wrapper (keyboard listener) FIRST, before creating Genesis scene | ||
| teleop_wrapper.start() # type: ignore | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also here. |
||
|
|
||
| # Create task environment AFTER teleop wrapper is running | ||
| env = PutBowlInsideMicrowaveEnv( | ||
| args=EnvArgsRegistry["put_bowl_inside_microwave_default"], | ||
| device=torch.device("cpu"), | ||
| ) | ||
| teleop_wrapper.set_environment(env) | ||
|
|
||
| print("\n" + "=" * 50) | ||
| print("Put Bowl Inside Microwave TELEOP SYSTEM READY") | ||
| print("=" * 50) | ||
| print("📝 TRAJECTORY RECORDING INSTRUCTIONS:") | ||
| print(" 1. Press 'r' to start recording (anytime)") | ||
| print(" 2. Move robot with arrow keys, n/m, space") | ||
| print(" 3. Press 'r' again to stop recording and save") | ||
| print(" 💡 Recording works from any state now!") | ||
| print("=" * 50) | ||
|
|
||
| # Run the main control loop in the main thread (Genesis viewer requires this) | ||
| try: | ||
| step_count = 0 | ||
| while teleop_wrapper.running: | ||
| # Step the teleop wrapper (this processes input and steps environment) | ||
| teleop_wrapper.step(torch.tensor([])) | ||
| step_count += 1 | ||
|
|
||
| # Check for quit command | ||
| if ( | ||
| hasattr(teleop_wrapper, "last_command") | ||
| and teleop_wrapper.last_command | ||
| and hasattr(teleop_wrapper.last_command, "quit_teleop") | ||
| and teleop_wrapper.last_command.quit_teleop | ||
| ): | ||
| print("Quit command received, exiting...") | ||
| break | ||
|
|
||
| # Safety check - exit after 1 hour of running | ||
| if step_count > 180000: # 1 hour at 50Hz | ||
| print("Maximum runtime reached, exiting...") | ||
| break | ||
|
|
||
| except KeyboardInterrupt: | ||
| print("\n👋 Teleop interrupted by user") | ||
|
|
||
| finally: | ||
| # Cleanup | ||
| teleop_wrapper.stop() | ||
| print("✅ Teleop session ended") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Teleop script for Sweep Table environment. | ||
| """ | ||
|
|
||
| import genesis as gs | ||
| import torch | ||
| from gs_agent.wrappers.teleop_wrapper import KeyboardWrapper | ||
| from gs_env.sim.envs.config.registry import EnvArgsRegistry | ||
| from gs_env.sim.envs.manipulation.sweep_table_env import SweepTableEnv | ||
|
|
||
|
|
||
| def main() -> None: | ||
| """Run teleop for sweep table task.""" | ||
| print("Initializing Sweep Table Teleop System...") | ||
|
|
||
| # Initialize Genesis | ||
| gs.init( | ||
| seed=0, | ||
| precision="32", | ||
| logging_level="info", | ||
| backend=gs.cpu, | ||
| ) | ||
|
|
||
| # Create teleop wrapper first (without environment) | ||
| print("Creating teleop wrapper...") | ||
| teleop_wrapper = KeyboardWrapper( | ||
| env=None, | ||
| device=torch.device("cpu"), | ||
| movement_speed=0.01, # Position movement speed | ||
| rotation_speed=0.05, # Rotation speed | ||
| trajectory_filename_prefix="sweep_table_", | ||
| ) | ||
|
|
||
| # Start teleop wrapper (keyboard listener) FIRST, before creating Genesis scene | ||
| teleop_wrapper.start() | ||
|
|
||
| # Create task environment AFTER teleop wrapper is running | ||
| env = SweepTableEnv( | ||
| args=EnvArgsRegistry["sweep_table_default"], | ||
| device=torch.device("cpu"), | ||
| ) | ||
| teleop_wrapper.set_environment(env) | ||
|
|
||
| print("\n" + "=" * 50) | ||
| print("Sweep Table TELEOP SYSTEM READY") | ||
| print("=" * 50) | ||
| print("📝 TRAJECTORY RECORDING INSTRUCTIONS:") | ||
| print(" 1. Press 'r' to start recording (anytime)") | ||
| print(" 2. Move robot with arrow keys, n/m, space") | ||
| print(" 3. Press 'r' again to stop recording and save") | ||
| print(" 💡 Recording works from any state now!") | ||
| print("=" * 50) | ||
|
|
||
| # Run the main control loop in the main thread (Genesis viewer requires this) | ||
| try: | ||
| step_count = 0 | ||
| while teleop_wrapper.running: | ||
| # Step the teleop wrapper (this processes input and steps environment) | ||
| teleop_wrapper.step(torch.tensor([])) | ||
| step_count += 1 | ||
|
|
||
| # Check for quit command | ||
| if ( | ||
| hasattr(teleop_wrapper, "last_command") | ||
| and teleop_wrapper.last_command | ||
| and hasattr(teleop_wrapper.last_command, "quit_teleop") | ||
| and teleop_wrapper.last_command.quit_teleop | ||
| ): | ||
| print("Quit command received, exiting...") | ||
| break | ||
|
|
||
| # Safety check - exit after 1 hour of running | ||
| if step_count > 180000: # 1 hour at 50Hz | ||
| print("Maximum runtime reached, exiting...") | ||
| break | ||
|
|
||
| except KeyboardInterrupt: | ||
| print("\n👋 Teleop interrupted by user") | ||
|
|
||
| finally: | ||
| # Cleanup | ||
| teleop_wrapper.stop() | ||
| print("✅ Teleop session ended") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
same