Skip to content

Commit 8333ae2

Browse files
authored
Add light keyboard control (#140)
1 parent 7676813 commit 8333ae2

File tree

5 files changed

+308
-9
lines changed

5 files changed

+308
-9
lines changed

embodichain/lab/gym/envs/embodied_env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def preview_sensor_data(
575575
cv2.imshow(window_name, cv2.cvtColor(view, cv2.COLOR_RGB2BGR))
576576
cv2.waitKey(0)
577577
cv2.destroyWindow(window_name)
578-
578+
579579
elif method == "plt":
580580
from matplotlib import pyplot as plt
581581

embodichain/lab/sim/sensors/camera.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ def group_id(self) -> int:
263263
)
264264
return -1
265265

266+
@property
267+
def is_attached(self) -> bool:
268+
"""Check if the camera is attached to a parent entity.
269+
270+
Returns:
271+
bool: True if the camera is attached to a parent entity, False otherwise.
272+
"""
273+
return self.cfg.extrinsics.parent is not None
274+
266275
def update(self, **kwargs) -> None:
267276
"""Update the sensor data.
268277

embodichain/lab/sim/sim_manager.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,14 @@ def get_light(self, uid: str) -> Light | None:
803803
return None
804804
return self._lights[uid]
805805

806+
def get_light_uid_list(self) -> List[str]:
807+
"""Get current light uid list
808+
809+
Returns:
810+
List[str]: list of light uid.
811+
"""
812+
return list(self._lights.keys())
813+
806814
def add_rigid_object(
807815
self,
808816
cfg: RigidObjectCfg,

embodichain/lab/sim/utility/gizmo_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def gizmo_transform_callback(node, translation, rotation, flag):
5151

5252

5353
def run_gizmo_robot_control_loop(
54-
robot: "Robot", control_part: str = "arm", end_link_name: str | None = None
54+
robot: object | str, control_part: str = "arm", end_link_name: str | None = None
5555
):
5656
"""Run a control loop for testing gizmo controls on a robot.
5757
5858
This function implements a control loop that allows users to manipulate a robot
5959
using gizmo controls with keyboard input for additional commands.
6060
6161
Args:
62-
robot (Robot): The robot to control with the gizmo.
62+
robot (Robot | str): The robot to control with the gizmo.
6363
control_part (str, optional): The part of the robot to control. Defaults to "arm".
6464
end_link_name (str | None, optional): The name of the end link for FK calculations. Defaults to None.
6565
@@ -87,6 +87,9 @@ def run_gizmo_robot_control_loop(
8787

8888
sim = SimulationManager.get_instance()
8989

90+
if isinstance(robot, str):
91+
robot = sim.get_robot(uid=robot)
92+
9093
# Enter auto-update mode.
9194
sim.set_manual_update(False)
9295

0 commit comments

Comments
 (0)