qgallouedec / panda-gym

Set of robotic environments based on PyBullet physics engine and gymnasium.
MIT License
506 stars 109 forks source link

Why 'panda_joint8' is disappear in JOINT_INDICES = [0, 1, 2, 3, 4, 5, 6, 9, 10] #12

Closed learningxiaobai closed 2 years ago

learningxiaobai commented 2 years ago

1.hello,Why 'panda_joint8'(joint_indices=7) is disappeared in JOINT_INDICES = [0, 1, 2, 3, 4, 5, 6, 9, 10]? 2.I have a .sdf file robot,how can i change your code to input my robot? Thanks a lot!

qgallouedec commented 2 years ago

Actually, two joints are missing from JOINT_INDICES: 7 and 8. These joints are actually fixed: they are dummy joints that fix two links that are supposed to remain motionless relative to each other. If you are familiar with URDF, here are the lines in question. Fixed joint between panda_link7 and panda_link7 Fixed joint between panda_link8 and panda_hand

learningxiaobai commented 2 years ago

Actually, two joints are missing from JOINT_INDICES: 7 and 8. These joints are actually fixed: they are dummy joints that fix two links that are supposed to remain motionless relative to each other. If you are familiar with URDF, here are the lines in question. Fixed joint between panda_link7 and panda_link7 Fixed joint between panda_link8 and panda_hand

thanks,I got it.

qgallouedec commented 2 years ago

For you second question, here is a base of code that you can use.

class MyRobot(PyBulletRobot):

    """Base class for robot env.
    Args:
        sim (Any): The simulation engine.
        body_name (str): The name of the robot within the simulation.
        ee_link (int): Link index of the end-effector
        file_name (str): Path of the urdf file.
        base_position (x, y, z): Position of the base of the robot.
    """
    JOINT_INDICES = # joints indices in your URDF file, eg, [0, 1, 2, 3, 4]
    JOINT_FORCES = # joint forces, in Nm , eg, [87, 87, 87, 87, 32]

    def __init__(self, sim, body_name, base_position):
        file_name = "my_sdf_file_name"
        super().__init__(self, sim, body_name, file_name, base_position)

    def set_action(self, action):
        """Perform the action."""
        # Some code using self.control_joints(target_angles)

    def get_obs(self):
        """Return the observation associated to the robot."""
        # build the obs vector, using for example
        # self.sim.get_joint_angle(self.body_name, joint_idx) or self.sim.get_link_position(self.body_name, self.body_name, link_idx)
        return obs

    def reset(self):
        """Reset the robot."""
        # Code executed when robot is reset.
        # If you want to return to the neutral position for examples : self.set_joint_values(neutral_joint_values)

I cannot guaranty that it would work with an SDF file, but if you manage to convert your SDF into URDF, it could work.