# OR TECHNICAL UNIVERSITY OF DARMSTADT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """ Test the functionality of Pyrado using the Quanser Ball balancer setup. """ from pyrado.domain_randomization.utils import print_domain_params from pyrado.environments.pysim.quanser_ball_balancer import QBallBalancerSim from pyrado.policies.feed_forward.dummy import IdlePolicy from pyrado.sampling.rollout import rollout from pyrado.utils.data_types import RenderMode if __name__ == "__main__": # Set up environment env = QBallBalancerSim(dt=1 / 500.0, max_steps=10000) env.reset(domain_param=dict(offset_th_x=50.0 / 180 * 3.141592)) print_domain_params(env.domain_param) # Set up policy policy = IdlePolicy(env.spec) # Simulate ro = rollout(env, policy, render_mode=RenderMode(text=True), stop_on_done=True)
env = MiniGolfJointCtrlSim(dt=dt) else: raise pyrado.ValueErr( given=env_name, eq_constraint= f"{QBallBalancerSim.name},{QCartPoleSwingUpSim.name},{QQubeSwingUpSim.name}, " f"wam-bic, wam-jsc, mg-ik, or mg-jnt", ) for idx_r, rollout in enumerate(rollouts): print_cbt(f"Replaying rollout {idx_r + 1} of {len(rollouts)}", "c") done = False env.reset(domain_param=domain_param) while not done: # Simulate like in rollout() for step in rollout: # Display step by step like rollout() t_start = time.time() env.state = step.state if not isinstance(env, SimPyEnv): # Use reset() to hammer the current state into MuJoCo / Rcs at evey step env.reset(init_state=step.state) do_sleep = True if pyrado.mujoco_loaded: from pyrado.environments.mujoco.base import MujocoSimEnv