Exemplo n.º 1
0
def read_data(data_dir, shape_keys):
    if isinstance(shape_keys, basestring):
        shape_keys = [shape_keys]
    motors = get_motors('head.yaml')
    motor_dict = {motor['name']: motor for motor in motors}
    ff_df, signal_df = pd.DataFrame(), pd.DataFrame()
    for shape_key in shape_keys:
        ff_file = '{}/ff_data_{}.csv'.format(data_dir, shape_key)
        signal_file = '{}/signal_data_{}.csv'.format(data_dir, shape_key)
        tmp_ff_df = pd.read_csv(ff_file, names=blend_shape_names)
        ff_df = pd.concat([ff_df, tmp_ff_df], ignore_index=True)
        tmp_signal_df = pd.read_csv(signal_file, names=SHKEY_DEPS[shape_key])
        remainder_names = motor_dict.keys()[:]
        for name in SHKEY_DEPS[shape_key]:
            remainder_names.remove(name)
        init_values = [motor_dict[name]['init'] for name in remainder_names]
        complementary_signal_df = pd.DataFrame(
            [init_values]*len(tmp_signal_df), columns=remainder_names)
        tmp_signal_df = pd.concat(
            [tmp_signal_df, complementary_signal_df], axis=1)
        signal_df = pd.concat([signal_df, tmp_signal_df], ignore_index=True)

    return ff_df, signal_df
Exemplo n.º 2
0
def read_data(data_dir, shape_keys):
    if isinstance(shape_keys, basestring):
        shape_keys = [shape_keys]
    motors = get_motors('head.yaml')
    motor_dict = {motor['name']: motor for motor in motors}
    ff_df, signal_df = pd.DataFrame(), pd.DataFrame()
    for shape_key in shape_keys:
        ff_file = '{}/ff_data_{}.csv'.format(data_dir, shape_key)
        signal_file = '{}/signal_data_{}.csv'.format(data_dir, shape_key)
        tmp_ff_df = pd.read_csv(ff_file, names=blend_shape_names)
        ff_df = pd.concat([ff_df, tmp_ff_df], ignore_index=True)
        tmp_signal_df = pd.read_csv(signal_file, names=SHKEY_DEPS[shape_key])
        remainder_names = motor_dict.keys()[:]
        for name in SHKEY_DEPS[shape_key]:
            remainder_names.remove(name)
        init_values = [motor_dict[name]['init'] for name in remainder_names]
        complementary_signal_df = pd.DataFrame([init_values] *
                                               len(tmp_signal_df),
                                               columns=remainder_names)
        tmp_signal_df = pd.concat([tmp_signal_df, complementary_signal_df],
                                  axis=1)
        signal_df = pd.concat([signal_df, tmp_signal_df], ignore_index=True)

    return ff_df, signal_df
Exemplo n.º 3
0
import pandas as pd
from fit import get_motors, init_position, set_servos
import time
from pololu.motors import Maestro

def set_position(motors, pos_series):
    active_motors = pos_series.index.tolist()
    for motor in motors:
        if motor['name'] in active_motors:
            pos = pos_series[motor['name']]
            if not np.isnan(pos):
                motor['pos'] = pos
                print "set {} to {}".format(motor['name'], pos)

if __name__ == '__main__':
    signal_file = 'signal.csv'
    signal_df = pd.read_csv(signal_file)
    motors = get_motors('head.yaml')
    init_position(motors)

    DEVICE = '/dev/ttyACM0'
    controller = None
    if os.path.exists(DEVICE):
        controller = Maestro(DEVICE)

    for index, row in signal_df.iterrows():
        set_position(motors, row)
        if controller:
            set_servos(controller, motors)
        time.sleep(0.5)
Exemplo n.º 4
0
import time
from pololu.motors import Maestro


def set_position(motors, pos_series):
    active_motors = pos_series.index.tolist()
    for motor in motors:
        if motor['name'] in active_motors:
            pos = pos_series[motor['name']]
            if not np.isnan(pos):
                motor['pos'] = pos
                print "set {} to {}".format(motor['name'], pos)


if __name__ == '__main__':
    signal_file = 'signal.csv'
    signal_df = pd.read_csv(signal_file)
    motors = get_motors('head.yaml')
    init_position(motors)

    DEVICE = '/dev/ttyACM0'
    controller = None
    if os.path.exists(DEVICE):
        controller = Maestro(DEVICE)

    for index, row in signal_df.iterrows():
        set_position(motors, row)
        if controller:
            set_servos(controller, motors)
        time.sleep(0.5)