to.set_default_dtype(to.double) # Check if RcsPySim, Bullet, and Vortex are available try: import rcsenv from pyrado.environments.rcspysim.ball_on_plate import BallOnPlate2DSim, BallOnPlate5DSim from pyrado.environments.rcspysim.box_lifting import BoxLiftingPosMPsSim from pyrado.environments.rcspysim.box_shelving import BoxShelvingVelMPsSim, BoxShelvingPosMPsSim from pyrado.environments.rcspysim.mp_blending import MPBlendingSim from pyrado.environments.rcspysim.planar_3_link import Planar3LinkIKSim, Planar3LinkTASim from pyrado.environments.rcspysim.planar_insert import PlanarInsertTASim, PlanarInsertIKSim from pyrado.environments.rcspysim.quanser_qube import QQubeRcsSim from pyrado.environments.rcspysim.target_tracking import TargetTrackingSim m_needs_vortex = pytest.mark.skipif( not rcsenv.supportsPhysicsEngine('Vortex'), reason='Vortex physics engine is not supported in this setup.' ) m_needs_bullet = pytest.mark.skipif( not rcsenv.supportsPhysicsEngine('Bullet'), reason='Bullet physics engine is not supported in this setup.' ) m_needs_rcs = pytest.mark.skipif(False, reason='rcsenv can be imported.') m_needs_libtorch = pytest.mark.skipif( 'torch' not in rcsenv.ControlPolicy.types, reason='Requires RcsPySim compiled locally with libtorch!' ) except (ImportError, ModuleNotFoundError): m_needs_vortex = pytest.mark.skip m_needs_bullet = pytest.mark.skip
return env, policy if __name__ == '__main__': # Initialize fig, axs = plt.subplots(3, figsize=(8, 12), sharex='col', tight_layout=True) # Try to run several possible cases for pe in ['Bullet', 'Vortex']: print_cbt(f'Running with {pe} physics engine', 'c', bright=True) if rcsenv.supportsPhysicsEngine(pe): env, policy = create_setup(pe, dt=0.01, max_steps=1000, max_dist_force=0.) # Simulate pyrado.set_seed(1) ro = rollout(env, policy, render_mode=RenderMode(video=True)) # Render plots axs[0].plot(ro.observations[:, 0], label=pe) axs[1].plot(ro.observations[:, 1], label=pe) axs[2].plot(ro.observations[:, 2], label=pe) axs[0].legend() axs[1].legend()
# Check if RcsPySim, Bullet, and Vortex are available try: import rcsenv from pyrado.environments.rcspysim.ball_in_tube import BallInTubePosIKActivationSim, BallInTubeVelDSSim from pyrado.environments.rcspysim.ball_on_plate import BallOnPlate2DSim, BallOnPlate5DSim from pyrado.environments.rcspysim.box_lifting import BoxLiftingPosDSSim, BoxLiftingVelDSSim from pyrado.environments.rcspysim.box_shelving import BoxShelvingPosDSSim, BoxShelvingVelDSSim from pyrado.environments.rcspysim.mp_blending import MPBlendingSim from pyrado.environments.rcspysim.planar_3_link import Planar3LinkIKActivationSim, Planar3LinkTASim from pyrado.environments.rcspysim.planar_insert import PlanarInsertIKActivationSim, PlanarInsertTASim from pyrado.environments.rcspysim.quanser_qube import QQubeRcsSim m_needs_vortex = pytest.mark.skipif( not rcsenv.supportsPhysicsEngine("Vortex"), reason="Vortex physics engine is not supported in this setup." ) m_needs_bullet = pytest.mark.skipif( not rcsenv.supportsPhysicsEngine("Bullet"), reason="Bullet physics engine is not supported in this setup." ) m_needs_rcs = pytest.mark.skipif(False, reason="rcsenv can be imported.") m_needs_libtorch = pytest.mark.skipif( "torch" not in rcsenv.ControlPolicy.types, reason="Requires RcsPySim compiled locally with libtorch!" ) except (ImportError, ModuleNotFoundError): m_needs_vortex = pytest.mark.skip m_needs_bullet = pytest.mark.skip m_needs_rcs = pytest.mark.skip m_needs_libtorch = pytest.mark.skip