diff --git a/pyrcareworld/pyrcareworld/envs/dressing_env.py b/pyrcareworld/pyrcareworld/envs/dressing_env.py index 50e78163..d6dae2f0 100644 --- a/pyrcareworld/pyrcareworld/envs/dressing_env.py +++ b/pyrcareworld/pyrcareworld/envs/dressing_env.py @@ -3,13 +3,33 @@ from pyrcareworld.envs.base_env import RCareWorld from pathlib import Path - _TEMPLATE_PATH = Path(__file__).parents[3] / "template" _DEFAULT_EXECUTABLE_PATH = _TEMPLATE_PATH / "Dressing" / "DressingPlayer.x86_64" - class DressingEnv(RCareWorld): """Dressing environment for the PhyRC competition.""" + # Environment-specific unity attribute IDs. + _robot_id: int = 315893 + _gripper_id: int = 3158930 + _camera_id: int = 654321 + _cloth_id: int = 782563 + def __init__(self, executable_file=str(_DEFAULT_EXECUTABLE_PATH), *args, **kwargs): super().__init__(executable_file=executable_file, *args, **kwargs) + + def get_robot(self): + """Access the robot.""" + return self.GetAttr(self._robot_id) + + def get_gripper(self): + """Access the gripper.""" + return self.GetAttr(self._gripper_id) + + def get_camera(self): + """Access the camera.""" + return self.GetAttr(self._camera_id) + + def get_cloth(self): + """Access the cloth.""" + return self.GetAttr(self._cloth_id) \ No newline at end of file diff --git a/template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp-firstpass.dll b/template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp-firstpass.dll index dcafa0b7..506d7bf0 100644 Binary files a/template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp-firstpass.dll and b/template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp-firstpass.dll differ diff --git a/template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp.dll b/template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp.dll index 56faa9f1..87b49cf5 100644 Binary files a/template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp.dll and b/template/Bathing/BathingPlayer_Data/Managed/Assembly-CSharp.dll differ diff --git a/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.EditMode.dll b/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.EditMode.dll index dba222bc..23839ef5 100644 Binary files a/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.EditMode.dll and b/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.EditMode.dll differ diff --git a/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.Extend.dll b/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.Extend.dll index 7df7545c..c7250a66 100644 Binary files a/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.Extend.dll and b/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.Extend.dll differ diff --git a/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.dll b/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.dll index bc7853ec..3d38169d 100644 Binary files a/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.dll and b/template/Bathing/BathingPlayer_Data/Managed/RFUniverse.dll differ diff --git a/template/Bathing/BathingPlayer_Data/StreamingAssets/aa/StandaloneLinux64/catalog_2024.09.07.06.36.40.hash b/template/Bathing/BathingPlayer_Data/StreamingAssets/aa/StandaloneLinux64/catalog_2024.09.13.19.42.00.hash similarity index 100% rename from template/Bathing/BathingPlayer_Data/StreamingAssets/aa/StandaloneLinux64/catalog_2024.09.07.06.36.40.hash rename to template/Bathing/BathingPlayer_Data/StreamingAssets/aa/StandaloneLinux64/catalog_2024.09.13.19.42.00.hash diff --git a/template/Bathing/BathingPlayer_Data/StreamingAssets/aa/StandaloneLinux64/catalog_2024.09.07.06.36.40.json b/template/Bathing/BathingPlayer_Data/StreamingAssets/aa/StandaloneLinux64/catalog_2024.09.13.19.42.00.json similarity index 100% rename from template/Bathing/BathingPlayer_Data/StreamingAssets/aa/StandaloneLinux64/catalog_2024.09.07.06.36.40.json rename to template/Bathing/BathingPlayer_Data/StreamingAssets/aa/StandaloneLinux64/catalog_2024.09.13.19.42.00.json diff --git a/template/Bathing/BathingPlayer_Data/StreamingAssets/aa/settings.json b/template/Bathing/BathingPlayer_Data/StreamingAssets/aa/settings.json index 1b97d107..80f07ead 100644 --- a/template/Bathing/BathingPlayer_Data/StreamingAssets/aa/settings.json +++ b/template/Bathing/BathingPlayer_Data/StreamingAssets/aa/settings.json @@ -1 +1 @@ -{"m_buildTarget":"StandaloneLinux64","m_SettingsHash":"7ad7f27bc56e49a4067c0ba16533d8f2","m_CatalogLocations":[{"m_Keys":["AddressablesMainContentCatalogRemoteHash"],"m_InternalId":"{UnityEngine.AddressableAssets.Addressables.RuntimePath}/StandaloneLinux64/catalog_2024.09.07.06.36.40.hash","m_Provider":"UnityEngine.ResourceManagement.ResourceProviders.TextDataProvider","m_Dependencies":[],"m_ResourceType":{"m_AssemblyName":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","m_ClassName":"System.String"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]},{"m_Keys":["AddressablesMainContentCatalogCacheHash"],"m_InternalId":"{UnityEngine.Application.persistentDataPath}/com.unity.addressables/catalog_2024.09.07.06.36.40.hash","m_Provider":"UnityEngine.ResourceManagement.ResourceProviders.TextDataProvider","m_Dependencies":[],"m_ResourceType":{"m_AssemblyName":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","m_ClassName":"System.String"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]},{"m_Keys":["AddressablesMainContentCatalog"],"m_InternalId":"{UnityEngine.AddressableAssets.Addressables.RuntimePath}/catalog.json","m_Provider":"UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider","m_Dependencies":["AddressablesMainContentCatalogRemoteHash","AddressablesMainContentCatalogCacheHash"],"m_ResourceType":{"m_AssemblyName":"Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","m_ClassName":"UnityEngine.AddressableAssets.ResourceLocators.ContentCatalogData"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]}],"m_ProfileEvents":false,"m_LogResourceManagerExceptions":true,"m_ExtraInitializationData":[],"m_DisableCatalogUpdateOnStart":false,"m_IsLocalCatalogInBundle":false,"m_CertificateHandlerType":{"m_AssemblyName":"","m_ClassName":""},"m_AddressablesVersion":"1.21.21","m_maxConcurrentWebRequests":500,"m_CatalogRequestsTimeout":0} \ No newline at end of file +{"m_buildTarget":"StandaloneLinux64","m_SettingsHash":"2d7c4bd96b721a504d36174c978ba6fb","m_CatalogLocations":[{"m_Keys":["AddressablesMainContentCatalogRemoteHash"],"m_InternalId":"{UnityEngine.AddressableAssets.Addressables.RuntimePath}/StandaloneLinux64/catalog_2024.09.13.19.42.00.hash","m_Provider":"UnityEngine.ResourceManagement.ResourceProviders.TextDataProvider","m_Dependencies":[],"m_ResourceType":{"m_AssemblyName":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","m_ClassName":"System.String"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]},{"m_Keys":["AddressablesMainContentCatalogCacheHash"],"m_InternalId":"{UnityEngine.Application.persistentDataPath}/com.unity.addressables/catalog_2024.09.13.19.42.00.hash","m_Provider":"UnityEngine.ResourceManagement.ResourceProviders.TextDataProvider","m_Dependencies":[],"m_ResourceType":{"m_AssemblyName":"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","m_ClassName":"System.String"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]},{"m_Keys":["AddressablesMainContentCatalog"],"m_InternalId":"{UnityEngine.AddressableAssets.Addressables.RuntimePath}/catalog.json","m_Provider":"UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider","m_Dependencies":["AddressablesMainContentCatalogRemoteHash","AddressablesMainContentCatalogCacheHash"],"m_ResourceType":{"m_AssemblyName":"Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null","m_ClassName":"UnityEngine.AddressableAssets.ResourceLocators.ContentCatalogData"},"SerializedData":[7,76,85,110,105,116,121,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,114,44,32,86,101,114,115,105,111,110,61,48,46,48,46,48,46,48,44,32,67,117,108,116,117,114,101,61,110,101,117,116,114,97,108,44,32,80,117,98,108,105,99,75,101,121,84,111,107,101,110,61,110,117,108,108,75,85,110,105,116,121,69,110,103,105,110,101,46,82,101,115,111,117,114,99,101,77,97,110,97,103,101,109,101,110,116,46,82,101,115,111,117,114,99,101,80,114,111,118,105,100,101,114,115,46,80,114,111,118,105,100,101,114,76,111,97,100,82,101,113,117,101,115,116,79,112,116,105,111,110,115,50,0,0,0,123,0,34,0,109,0,95,0,73,0,103,0,110,0,111,0,114,0,101,0,70,0,97,0,105,0,108,0,117,0,114,0,101,0,115,0,34,0,58,0,116,0,114,0,117,0,101,0,125,0]}],"m_ProfileEvents":false,"m_LogResourceManagerExceptions":true,"m_ExtraInitializationData":[],"m_DisableCatalogUpdateOnStart":false,"m_IsLocalCatalogInBundle":false,"m_CertificateHandlerType":{"m_AssemblyName":"","m_ClassName":""},"m_AddressablesVersion":"1.21.21","m_maxConcurrentWebRequests":500,"m_CatalogRequestsTimeout":0} \ No newline at end of file diff --git a/template/Bathing/BathingPlayer_Data/boot.config b/template/Bathing/BathingPlayer_Data/boot.config index 1f9f9103..f8d48ab4 100644 --- a/template/Bathing/BathingPlayer_Data/boot.config +++ b/template/Bathing/BathingPlayer_Data/boot.config @@ -1,14 +1,14 @@ player-connection-mode=Listen -player-connection-guid=2757552504 +player-connection-guid=3553645385 player-connection-debug=0 player-connection-project-name=BathingPlayer player-connection-ip=192.168.194.8 player-connection-ip=192.168.80.1 player-connection-ip=192.168.230.1 -player-connection-ip=192.168.160.1 +player-connection-ip=172.24.32.1 player-connection-ip=192.168.0.181 wait-for-native-debugger=0 hdr-display-enabled=0 gc-max-time-slice=3 force-d3d11-bitblt-model= -build-guid=02e9a24fb7284158b5043ebfe3d02b8a +build-guid=b23937a029ab44bba43305b5ce353d48 diff --git a/template/Bathing/BathingPlayer_Data/globalgamemanagers b/template/Bathing/BathingPlayer_Data/globalgamemanagers index 5a0df7f7..c30f9162 100644 Binary files a/template/Bathing/BathingPlayer_Data/globalgamemanagers and b/template/Bathing/BathingPlayer_Data/globalgamemanagers differ diff --git a/template/Bathing/BathingPlayer_Data/resources.assets b/template/Bathing/BathingPlayer_Data/resources.assets index 0c0af773..c9562d07 100644 Binary files a/template/Bathing/BathingPlayer_Data/resources.assets and b/template/Bathing/BathingPlayer_Data/resources.assets differ diff --git a/template/test_bathing.py b/template/test_bathing.py index 13802cde..f3eaae8f 100644 --- a/template/test_bathing.py +++ b/template/test_bathing.py @@ -35,7 +35,7 @@ def _main(use_graphics=False): env.step(300) gripper.GripperClose() - env.step() + env.step(300) # Obtain sponge data and simulate a step sponge = env.get_sponge() @@ -43,12 +43,12 @@ def _main(use_graphics=False): print(sponge.data) # Camera operations: Attach a camera to the robot's hand - camera_hand = env.GetAttr(654321) - camera_hand.SetTransform(position=gripper.data['position'], rotation=[0, 0, 0]) - camera_hand.SetParent(2215820) - camera_hand.GetRGB(512, 512) + camera = env.get_camera() + camera.SetTransform(position=gripper.data['position'], rotation=[0, 0, 0]) + camera.SetParent(2215820) + camera.GetRGB(512, 512) env.step() - rgb = np.frombuffer(camera_hand.data["rgb"], dtype=np.uint8) + rgb = np.frombuffer(camera.data["rgb"], dtype=np.uint8) rgb = cv2.imdecode(rgb, cv2.IMREAD_COLOR) cv2.imwrite("rgb_hand.png", rgb) diff --git a/template/test_dressing.py b/template/test_dressing.py index d1ee5182..03c8f887 100644 --- a/template/test_dressing.py +++ b/template/test_dressing.py @@ -25,32 +25,28 @@ def _main(use_graphics=False): env = DressingEnv(graphics=use_graphics) print(env.attrs) - kinova_id = 315893 - robot = env.GetAttr(kinova_id) + robot = env.get_robot() env.step() # Get the gripper attribute and open the gripper - gripper = env.GetAttr(3158930) + gripper = env.get_gripper() gripper.GripperOpen() env.step(300) gripper.GripperClose() env.step(300) - # Get the cloth attribute and perform a simulation step - cloth = env.GetAttr(782563) + cloth = env.get_cloth() + print(cloth.data) + + # Camera operations: Attach a camera to the robot's hand + camera = env.get_camera() + camera.SetTransform(position=gripper.data['position'], rotation=[-90, 90, -90]) + camera.SetParent(3158930) + camera.GetRGB(512, 512) env.step() - # print(cloth.data) - - # Set the camera as a child of the robot's hand - # you can also load new cameras and set them as children of other objects in the scene - camera_hand = env.GetAttr(654321) - camera_hand.SetTransform(position=gripper.data['position'], rotation=[-90, 90, -90]) - camera_hand.SetParent(3158930) - camera_hand.GetRGB(512, 512) - env.step() - rgb = np.frombuffer(camera_hand.data["rgb"], dtype=np.uint8) + rgb = np.frombuffer(camera.data["rgb"], dtype=np.uint8) env.step() # Random positions and rotation