Пример #1
0
    def onSave(self, parent, data):

        control_file_data = {
            "data": self._controls
        }
        config.write(self._path+self._file, control_file_data, compact=True)

        data['control_file'] = self._file

        self._mod_time.save(data)
Пример #2
0
    def onSave(self, parent, data):
        frame_times = self._time_stamper.times_ms()
        time_file_data = {
            "data": frame_times
        }
        config.write(self._path+self._time_file, time_file_data, compact=True)

        data['{}_datetime'.format(
            self._name)] = ext.pack_datetime(self._time_stamper.initial())
        data['{}_frame_count'.format(self._name)] = len(frame_times)
        data['{}_frame_times'.format(self._name)] = self._time_file
        data['{}_duration'.format(self._name)] = frame_times[-1]
Пример #3
0
def _create_config():
    print "Attempting to create config file ..."
    print "Leave entries empty to set value to default" + term.END

    rconfig = {}

    for value in _config_set:
        rconfig[value] = _enter_attrib(value, _config_set[value][0],
                                       _config_set[value][1])

    au_config.write(_recording_config, rconfig)
    print "Wrote config to '{}'".format(_recording_config)

    return rconfig
Пример #4
0
 def __init__(self, name, translate, load, path):
     self._name = name
     if self._name[-1] != '/':
         self._name += '/'
     self._translate = translate
     self._path = path
     self._node_path = self._path + self._name
     self._config_path = self._node_path + 'meta.json'
     self._config = { }
     if load:
         self._config = config.read(self._config_path)
         if self._config == None:
             print "Error reading: '{}'".format(self._config_path)
     else:
         config.write(self._config_path, self._config)
Пример #5
0
def edit_config():
    result = au_config.read(_recording_config)
    if result == None:
        print "File '{}' not found".format(_recording_config)
        result = _create_config()
    else:
        print "File '{}' found".format(_recording_config)
        edit_result = _edit_config(result)
        if edit_result is not None:
            result = edit_result
            au_config.write(_recording_config,
                            result)  #write again if missing parameters
            print "Updated config at '{}'".format(_recording_config)
        else:
            print "Config not changed: '{}'".format(_recording_config)
    return result
Пример #6
0
def read_or_create_config(output=True):
    result = au_config.read(_recording_config)
    if result == None:
        print "File '{}' not found".format(_recording_config)
        result = _create_config()
    else:
        print "File '{}' found".format(_recording_config)
        check_result = _check_config(result, output)
        if check_result is not None:
            result = check_result
            au_config.write(_recording_config,
                            result)  #write again if missing parameters
            print "Updated config at '{}'".format(_recording_config)
        else:
            print "Config not changed: '{}'".format(_recording_config)
    return result
Пример #7
0
 def save(self):
     config.write(self._config_path, self._config)
Пример #8
0
def main():

    pub = rospy.Publisher('al5d', Float32MultiArray, queue_size=10)
    rospy.init_node('al5d_pub', anonymous=True)

    rate = rospy.Rate(10)

    pc = ps4.PS4Controller()
    created = pc.create()
    if not created:
        print "Error finding PS4 controller"

    read = False
    write = False

    fname = "temp_ald5.json"
    base = "c"
    data = {}
    count = 0
    num = 0
    if read:
        data = config.read(fname)
        num = data['num']

    mindex = 0
    while not rospy.is_shutdown():

        pc.poll()

        if pc.home():
            break

        if read:
            if count == num - 1:
                break
            C = data[base + str(count)]
        else:
            C = [
                -pc.RX(),  # X
                pc.RY(),  # Y
                0,  # Z
                pc.LY(),  # wrist_degree
                pc.LT(),  # wrise_rotate_degree
                pc.RT(),  # open
                0  # reward
            ]
            data[base + str(count)] = C

        # Displacements
        C = [
            pc.RX(),  # BASE
            -pc.RY(),  # SHOULDER
            0,  # ELBOW
            0,  # WRIST
            0,  # WRIST_ROTATE
            0,  # GRIPPER
        ]

        # Trigger mod
        lt = pc.LT() + 1
        rt = pc.RT() + 1

        # Test individuals
        C = [
            pc.RX(),  # good
            -pc.RY(),  # ?
            -pc.LY(),  # ?
            -lt + rt,  # ?
            pc.LX(),  # ?
            (-pc.L1() + pc.R1()),  # ?
        ]

        # Multipliers
        C[0] = 100 * C[0] * C[0] * C[0]
        C[1] = 100 * C[1] * C[1] * C[1]
        C[2] = 100 * C[2] * C[2] * C[2]
        C[3] = 100 * C[3] * C[3] * C[3]
        C[4] = 100 * C[4] * C[4] * C[4]
        C[5] = 100 * C[5] * C[5] * C[5]

        rospy.loginfo(C)

        msg = Float32MultiArray()
        msg.data = C

        pub.publish(msg)

        count = count + 1

        rate.sleep()

    pc.destroy()

    if write:
        data['num'] = count
        print "Writing to: {}".format(fname)
        config.write(fname, data)