importpybulletaspimportpybullet_dataimporttimeimportpathlib# setupp.connect(p.GUI)p.resetSimulation()# type: ignorep.setGravity(gravX=0,gravY=0,gravZ=-9.8)p.setAdditionalSearchPath(path=pybullet_data.getDataPath())plane=p.loadURDF("plane.urdf")# add current file location and its 'urdf' subfolder to search pathscwd=pathlib.Path(__file__).parent.resolve()cwd=cwd.joinpath("urdf")p.setAdditionalSearchPath(cwd.as_posix())# load URDFrobot=p.loadURDF("rrbot.urdf",basePosition=[0,0,0.5],useFixedBase=True)p.setJointMotorControl2(robot,0,p.VELOCITY_CONTROL,force=0)# free jointp.resetJointState(robot,0,0.2)# small initial angle so gravity can actp.setRealTimeSimulation(True)try:whileTrue:keys=p.getKeyboardEvents()# 27 = ESCif27inkeysandkeys[27]&p.KEY_WAS_TRIGGERED:print("ESC pressed, exiting...")breaktime.sleep(1/240)finally:p.disconnect()