<jupyter_start><jupyter_text>Examples> Examples of the PCT library in use.<jupyter_code># hide
import sys
sys.path.append("..")
import gym 
import os
os = os.name<jupyter_output><empty_output><jupyter_text>AcrobotThe goal is for the end effector to be one link length above the horizontal.The observations of the Acrobat system are the sin and cos values of the two joint angles and also the angular velocities of the two joints.That is, 0 - cos of the angle of link 11 - sin of the angle of link 12 - cos of the angle of link 23 - sin of the angle of link 24 - velocity of link 15 - velocity of link 2An angle of 0 for the first link means it is pointing downwards.An angle of 0 for the second link means it is in line with the first link (I think).So, the starting position of pointing downwards has both angles as 0. Therefore, the initial state is [1, 0, 1, 0, 0, 0]The ideal goal state, then, would be, [-1,0, 1, 0, 0, 0], which is pointing upwards.<jupyter_code>from pct.hierarchy import PCTHierarchy
from pct.functions import OpenAIGym
#env = gym.make("Acrobot-v1")
acrobot_hierarchy = PCTHierarchy(rows=1, cols=1, name="acrobot_hierarchy")
acrobot = OpenAIGym("Acrobot-v1", name="Acrobot-v1", render=False)
link = acrobot_hierarchy.get_output_function()
print(link.get_config())
acrobot.add_link(link)
acrobot_hierarchy.add_preprocessor(acrobot)
acrobot_hierarchy.summary()
acrobot_hierarchy()
"""
env = gym.make("Acrobot-v1")
env.reset()
obs = env.step(1)
"""
"""
env.reset()
alt=3

for i in range(10):
    alt+=1
    for j in range(alt):
        obs = env.step(1)
        if os=="nt":
            env.render()
        print(f'{obs[0][0]:0.2f} {obs[0][1]:0.2f} {obs[0][2]:0.2f} {obs[0][3]:0.2f} {obs[0][4]:0.2f} {obs[0][5]:0.2f}')
    for k in range(alt):
        obs = env.step(-1)
        if os=="nt":
            env.render()
        print(f'{obs[0][0]:0.2f} {obs[0][1]:0.2f} {obs[0][2]:0.2f} {obs[0][3]:0.2f} {obs[0][4]:0.2f} {obs[0][5]:0.2f}')
"""
acrobot.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14598903836571997, 'fraction_numerical': 0.04384653712007972, 'mean_word_length': 4.188630490956072, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '605510', 'license': 'Apache-2.0', 'n_tokens_mistral': 789, 'n_tokens_neox': 754, 'n_words': 229, 'path': 'oldnbs/00_examples_acrobot.ipynb', 'repo_name': 'perceptualrobots/pct', 'size': '2007'}