code reduction for training and eval
reward and everything else changed again wont be the last time
This commit is contained in:
@@ -82,11 +82,40 @@ class SimManager:
|
||||
def step(self):
|
||||
p.stepSimulation(physicsClientId=self.physics_client)
|
||||
|
||||
def set_rendering(self, enabled: bool) -> None:
|
||||
"""Toggles PyBullet 3D rendering to speed up simulation."""
|
||||
if self.physics_client is not None and p.isConnected(self.physics_client):
|
||||
p.configureDebugVisualizer(
|
||||
p.COV_ENABLE_RENDERING,
|
||||
1 if enabled else 0,
|
||||
physicsClientId=self.physics_client
|
||||
)
|
||||
|
||||
def disconnect(self):
|
||||
if self.physics_client is not None and p.isConnected(self.physics_client):
|
||||
p.disconnect(self.physics_client)
|
||||
self.physics_client = None
|
||||
|
||||
def get_contact_points(
|
||||
self,
|
||||
bodyA: int = -1,
|
||||
bodyB: int = -1,
|
||||
linkIndexA: int = -1,
|
||||
linkIndexB: int = -1,
|
||||
):
|
||||
"""Wrapper around pybullet.getContactPoints bound to this simulation client."""
|
||||
kwargs = {"physicsClientId": self.physics_client}
|
||||
if bodyA != -1:
|
||||
kwargs["bodyA"] = bodyA
|
||||
if bodyB != -1:
|
||||
kwargs["bodyB"] = bodyB
|
||||
if linkIndexA != -1:
|
||||
kwargs["linkIndexA"] = linkIndexA
|
||||
if linkIndexB != -1:
|
||||
kwargs["linkIndexB"] = linkIndexB
|
||||
|
||||
return p.getContactPoints(**kwargs)
|
||||
|
||||
# --- ROBOT GETTERS AND SETTERS ---
|
||||
|
||||
def reset_robot_base(
|
||||
@@ -124,6 +153,17 @@ class SimManager:
|
||||
roll, pitch, yaw = p.getEulerFromQuaternion(orn)
|
||||
return float(roll), float(pitch), float(yaw)
|
||||
|
||||
def get_foot_link_indices(self, body_id: int) -> list[int]:
|
||||
"""Inspects URDF joint structure to extract link IDs for leg tips and tibias."""
|
||||
foot_indices = []
|
||||
num_joints = p.getNumJoints(body_id, physicsClientId=self.physics_client)
|
||||
for j_idx in range(num_joints):
|
||||
info = p.getJointInfo(body_id, j_idx, physicsClientId=self.physics_client)
|
||||
link_name = info[12].decode("utf-8")
|
||||
if "tip" in link_name or "tibia" in link_name:
|
||||
foot_indices.append(j_idx)
|
||||
return foot_indices
|
||||
|
||||
def get_robot_pose_and_rpy(self, body_id: int) -> Tuple[List[float], Tuple[float, float, float]]:
|
||||
"""Returns base position and (roll, pitch, yaw) tuple in radians."""
|
||||
pos, orn = p.getBasePositionAndOrientation(body_id, physicsClientId=self.physics_client)
|
||||
|
||||
Reference in New Issue
Block a user