def test_load_URDF(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.loadURDF( body_name="panda", fileName="franka_panda/panda.urdf", basePosition=[0.0, 0.0, 0.0], useFixedBase=True, ) pybullet.close()
def test_inverse_kinematics(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.loadURDF( body_name="panda", fileName="franka_panda/panda.urdf", basePosition=[0.0, 0.0, 0.0], useFixedBase=True, ) joint_angles = pybullet.inverse_kinematics("panda", 6, [0.4, 0.5, 0.6], [0.707, -0.02, 0.02, 0.707]) assert np.allclose( joint_angles, [1.000, 1.223, -1.113, -0.021, -0.917, 0.666, -0.499, 0.0, 0.0], atol=1e-3) pybullet.close()
def __init__(self, render: bool = False, reward_type: str = "sparse", control_type: str = "ee") -> None: sim = PyBullet(render=render) robot = Panda(sim, block_gripper=False, base_position=np.array([-0.6, 0.0, 0.0]), control_type=control_type) task = PickAndPlace(sim, reward_type=reward_type) super().__init__(robot, task)
def test_construct(): from panda_gym.pybullet import PyBullet pybullet = PyBullet()
def test_create_table(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.create_table(0.5, 0.6, 0.4) pybullet.close()
def test_create_plane(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.create_plane(0.5) pybullet.close()
def test_dt(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() assert pybullet.dt == 0.04 pybullet.close()
def test_place_visalizer(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.place_visualizer([0.1, 0.2, 0.3], 5.0, 0.3, 0.4)
def test_step(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.step() pybullet.close()
def test_get_joint_angle(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.loadURDF( body_name="panda", fileName="franka_panda/panda.urdf", basePosition=[0.0, 0.0, 0.0], useFixedBase=True, ) pybullet.control_joints("panda", [5], [0.3], [5.0]) pybullet.step() joint_angle = pybullet.get_joint_angle("panda", 5) assert np.allclose(joint_angle, 0.063, atol=1e-3) pybullet.close()
def test_get_link_angular_velocity(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.loadURDF( body_name="panda", fileName="franka_panda/panda.urdf", basePosition=[0.0, 0.0, 0.0], useFixedBase=True, ) pybullet.control_joints("panda", [5], [0.3], [5.0]) pybullet.step() link_angular_velocity = pybullet.get_link_angular_velocity("panda", 5) assert np.allclose(link_angular_velocity, [0.000, -2.969, 0.000], atol=1e-3) pybullet.close()
def test_get_link_orientation(): from panda_gym.pybullet import PyBullet pybullet = PyBullet() pybullet.loadURDF( body_name="panda", fileName="franka_panda/panda.urdf", basePosition=[0.0, 0.0, 0.0], useFixedBase=True, ) pybullet.control_joints("panda", [5], [0.3], [5.0]) pybullet.step() link_orientation = pybullet.get_link_orientation("panda", 5) assert np.allclose(link_orientation, [0.707, -0.02, 0.02, 0.707], atol=1e-3) pybullet.close()