Example #1
0
                                              n=5,
                                              radius_factor=0.50)
                        graphs.hold(False)

                        # update m_channels
                        update_m_channels(env, ex, m_center, ranges[idx])

                min_y, min_idx = 0, -1
                for i, (x, y) in enumerate(s_vectors):
                    if y < min_y:
                        min_y = y
                        min_idx = i

                # making graphs
                graphs.spread(env.s_channels,
                              s_vectors=s_vectors,
                              e_radius=1.5,
                              e_alpha=0.25,
                              plot_height=250,
                              plot_width=800,
                              y_range=[-1, 0.05],
                              x_range=[-0.2, 0.1],
                              title='{}::{}'.format(ex_name, env_name))
                graphs.hold(True)
                graphs.posture_signals(env,
                                       [explorations[min_idx][0]['m_signal']],
                                       alpha=0.75,
                                       radius_factor=0.35)

    graphs.show()
Example #2
0
s_vectors0 = []
for explo in explorations[:MB]:
    feedback = env0.execute(explo[0]['m_signal'])
    s_vectors0.append(
        explorers.tools.to_vector(feedback['s_signal'], env0.s_channels))

graphs.spread(env.s_channels,
              s_vectors=s_vectors0[:MB],
              e_radius=3.0,
              e_alpha=1.0,
              e_color='#DF6464',
              title='first arm - reused effects')
for e in explorations[:MB]:
    graphs.hold(True)
    graphs.posture_signals(env0, [e[0]['m_signal']],
                           alpha=ARM_ALPHA,
                           radius_factor=0.75)
graphs.hold(True)
graphs.spread(env.s_channels,
              s_vectors=s_vectors0[:MB],
              grid=False,
              e_radius=3.0,
              e_alpha=1.0,
              e_color='#DF6464')
graphs.hold(False)

# Graph Reuse
for t in [MB, 200, 400, N]:

    # alpha  = 1.0 if t != N else 0.5
    graphs.bokeh_spread(env.s_channels,
Example #3
0
# Splitting the trials
s_vectors_pos, s_vectors_neg = [], []
for explo, s_vector in zip(explorations, s_vectors):
    if explo[0]['m_signal']['j0'] > 0:
        s_vectors_pos.append(s_vector)
    else:
        s_vectors_neg.append(s_vector)


graphs.output_file('c0_fig4_kin2_decomp.html')

# Positive Graph
graphs.spread(env.s_channels, s_vectors=s_vectors_pos,
              e_radius=1.0, e_alpha=0.5,
              title='{}::{} [positive]'.format(env_name, ex_name))
graphs.hold(True)
graphs.posture_signals(env, [{'j0': i, 'j1':-150+2*i} for i in range(150, -1, -10)],
                       color='#333333', alpha=0.5, swap_xy=True)
graphs.hold(False)

# Negative Graph
graphs.spread(env.s_channels, s_vectors=s_vectors_neg,
              e_radius=1.0, e_alpha=0.5,
              title='{}::{} [negative]'.format(env_name, ex_name))
graphs.hold(True)
graphs.posture_signals(env, [{'j0': -i, 'j1':-150+2*i} for i in range(0, 151, 10)],
                       color='#333333', alpha=0.5, swap_xy=True)
graphs.hold(False)

graphs.show()
Example #4
0
        # running the exploration
        explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N)

        # making graphs
        for t in milestones:
            idxs = []
            for x_ in range(10):
                idxs.append(
                    find_rightmost(s_vectors[:t], -x_ / 10.0,
                                   -(x_ - 1) / 10.0))
            idxs.append(find_rightmost(s_vectors[:t], -0.960, -0.940))
            idxs.append(find_rightmost(s_vectors[:t], -0.940, -0.920))
            idxs.append(find_rightmost(s_vectors[:t], -0.920, -0.900))
            idxs.append(find_rightmost(s_vectors[:t], -0.900, -0.850))

            graphs.spread(env.s_channels,
                          s_vectors=s_vectors[:t],
                          e_radius=1.4,
                          e_alpha=0.5,
                          title='{}::{}::{}'.format(ex_name, env_name, t))

            for idx in idxs:
                graphs.hold(True)
                graphs.posture_signals(env, [explorations[idx][0]['m_signal']],
                                       color='#666666',
                                       alpha=0.50,
                                       radius_factor=0.6)

graphs.show()
Example #5
0
# 'Self-Exploration of Sensorimotor Spaces in Robots' by Fabien C. Y. Benureau
# Licensed under the Open Science License (see http://fabien.benureau.com/openscience.html)

import environments

import dotdot
import envs
import graphs

# instanciating the environment
env_cfg = envs.catalog['kin7_150']._deepcopy()
env = environments.Environment.create(env_cfg)

# defining postures
m_vectors = [
    (132.654, -108.829, -100.829, 12.724, 133.011, -76.348, -118.995),
    (-19.163, 69.503, 44.059, -88.545, -36.027, 76.281, 8.720),
    (138.239, 39.661, -84.211, 15.735, -33.844, 104.375, 26.110),
    (19.678, -95.130, 96.038, -7.118, 56.496, 10.632, 111.627),
    (135.685, 70.589, -69.667, -7.244, 149.627, -42.752, -54.894),
]
m_signals = [
    environments.tools.to_signal(m_vector, env.m_channels)
    for m_vector in m_vectors
]

# making graphs
graphs.output_file('c0_fig1_kin7_example.html')
graphs.posture_signals(env, m_signals, color='#666666', alpha=0.5)
graphs.show()
Example #6
0
        # making graphs
        milestones = [0, 100, 200, 500, 1000, 2000, 5000, N]
        for t in milestones[1:]:
            alpha = 0.5 if t == 100 else 0.25

            graphs.spread(ex.s_channels,
                          s_vectors=s_vectors[:t],
                          s_goals=(),
                          e_radius=2.0,
                          e_alpha=alpha,
                          x_range=(-1.05, 1.05),
                          y_range=(-1.05, 1.05),
                          title='demo:{}, t={}'.format(env_name, t))
            graphs.hold(True)
            graphs.posture_signals(env,
                                   dataset['m_signals'],
                                   radius_factor=0.35,
                                   alpha=0.75)
            graphs.hold(True)
            graphs.spread(ex.s_channels,
                          s_vectors=s_vectors[:1],
                          s_goals=(),
                          e_radius=2.0,
                          e_alpha=.0,
                          e_color='#DF6464')
            graphs.hold(True)
            graphs.posture_random(env,
                                  explorations[milestones[milestones.index(t) -
                                                          1]:],
                                  n=10,
                                  alpha=0.75,
                                  radius_factor=0.35)
Example #7
0
graphs.output_file('c0_fig6_kin2_gb.html'.format(int(N/1000)))


random.seed(0)

# instanciating the environment
env_cfg = envs.catalog[env_name]._deepcopy()
env = environments.Environment.create(env_cfg)

# instanciating the explorer
ex_cfg = exs.catalog[ex_name]._deepcopy()
ex_cfg.m_channels = env.m_channels
ex_cfg.s_channels = env.s_channels

ex = explorers.Explorer.create(ex_cfg)

# running the Exploration
explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N)

# making graphs
graphs.spread(env.s_channels, s_vectors=s_vectors,
              e_radius=1.0, e_alpha=0.25,
              title='{}::{}'.format(ex_name, env_name))
graphs.hold(True)

m_vectors = [(150, 103), (135, 110), (  0, -45), ( 15, -50)]
m_signals = [environments.tools.to_signal(m_vector, env.m_channels) for m_vector in m_vectors]
graphs.posture_signals(env, m_signals, color='#333333', alpha=1.0)

graphs.show()
Example #8
0
import dotdot
import envs
import graphs

# instanciating the environment
env_cfg = envs.catalog['kin2_150']._deepcopy()
env = environments.Environment.create(env_cfg)

# making graphs
graphs.output_file('c0_fig1_kin2_ranges.html')
for a in range(-150, 150, 10):
    graphs.posture_signals(env, [{
        'j0': 0,
        'j1': a
    }],
                           color='#333333',
                           alpha=a * 0.0005 + 0.3,
                           title='joint ranges')
    graphs.hold(True)

for a in range(0, 151, 15):
    graphs.posture_signals(env, [{
        'j0': a,
        'j1': 150
    }],
                           color='#666666',
                           alpha=0.5)
    graphs.hold(True)

graphs.show()
Example #9
0
selected = [m_signals[i] for i in [0, 1, 2, 3, 5, 9]]

# spreading their first joints to avoid superpositions
m_signals[0]['j{}'.format(DIM - 1)] = 100.0
m_signals[1]['j{}'.format(DIM - 1)] = -150.0
m_signals[2]['j{}'.format(DIM - 1)] = -30.0
m_signals[3]['j{}'.format(DIM - 1)] = 50.0
m_signals[5]['j{}'.format(DIM - 1)] = -50.0
m_signals[9]['j{}'.format(DIM - 1)] = 20.0

# making graphs
graphs.output_file('c5_fig5_1_examples.html')
for kin_env, color in zip([env, env2], ['#666666', '#E84A5F']):
    graphs.posture_signals(kin_env,
                           m_signals,
                           color=color,
                           alpha=0.1,
                           radius_factor=0.5)
    graphs.hold(True)
for kin_env, color in zip([env, env2], ['#666666', '#E84A5F']):
    graphs.posture_signals(kin_env,
                           selected,
                           color=color,
                           alpha=0.75,
                           radius_factor=0.5)
    graphs.hold(True)
graphs.hold(False)

graphs.posture_signals(env, [{'j{}'.format(i): 0
                              for i in range(20)}],
                       color='#666666',