Beispiel #1
0
    def get_inputs(self):

        self.log_x_encode_mean = sequence_mean(tf.log(self.y_encode + 1), self.encode_series_len-self.decode_series_len)
        self.log_x_encode = transform(self.y_encode, self.log_x_encode_mean)
        

        self.log_volume_encode_mean = sequence_mean(tf.log(self.volume_encode + 1), self.encode_series_len-self.decode_series_len)
        self.log_volume_encode = transform(self.volume_encode, self.log_volume_encode_mean)

        self.x = tf.expand_dims(self.log_x_encode, 2)


        self.encode_features = tf.concat([
            tf.expand_dims(self.log_volume_encode, 2),

            tf.expand_dims(tf.cast(self.is_today, tf.float32), 2),

            tf.tile(tf.reshape(self.log_volume_encode_mean, (-1, 1, 1)), (1, tf.shape(self.y_encode)[1], 1)),
            tf.tile(tf.reshape(self.log_x_encode_mean, (-1, 1, 1)), (1, tf.shape(self.y_encode)[1], 1)),

        ], axis=2)

        decode_idx = tf.tile(tf.expand_dims(tf.range(self.decode_series_len), 0), (tf.shape(self.y_decode)[0], 1))

        self.decode_features = tf.concat([
            tf.one_hot(decode_idx, self.decode_series_len),
            tf.tile(tf.reshape(self.log_x_encode_mean, (-1, 1, 1)), (1, self.decode_series_len, 1))
        ], axis=2)
Beispiel #2
0
    def get_inputs(self, opens, highs, lows, closes, volumes, positions,
                   order_prices, current_prices, time_since, todays):

        log_x_mean = sequence_mean(tf.log((highs + lows) / 2. + 1),
                                   self.series_length)
        log_x = transform((highs + lows) / 2., log_x_mean)

        log_opens_mean = sequence_mean(tf.log(opens + 1), self.series_length)
        log_opens = transform(opens, log_opens_mean)

        log_highs_mean = sequence_mean(tf.log(highs + 1), self.series_length)
        log_highs = transform(highs, log_highs_mean)

        log_lows_mean = sequence_mean(tf.log(lows + 1), self.series_length)
        log_lows = transform(lows, log_lows_mean)

        log_closes_mean = sequence_mean(tf.log(closes + 1), self.series_length)
        log_closes = transform(closes, log_closes_mean)

        log_volumes_mean = sequence_mean(tf.log(volumes + 1),
                                         self.series_length)
        log_volumes = transform(volumes, log_volumes_mean)

        log_order_pricess = tf.log(order_prices + 1) - log_x_mean

        log_current_prices = tf.log(current_prices + 1) - log_x_mean

        x = tf.expand_dims(log_x, 2)

        features = tf.concat([
            tf.expand_dims(log_opens, 2),
            tf.expand_dims(log_highs, 2),
            tf.expand_dims(log_lows, 2),
            tf.expand_dims(log_closes, 2),
            tf.expand_dims(log_volumes, 2),
            tf.tile(tf.expand_dims(tf.one_hot(positions + 1, 3), 1),
                    (1, tf.shape(opens)[1], 1)),
            tf.tile(tf.expand_dims(tf.one_hot(time_since, 60), 1),
                    (1, tf.shape(opens)[1], 1)),
            tf.expand_dims(tf.cast(todays, tf.float32), 2),
            tf.tile(tf.reshape(log_opens_mean, (-1, 1, 1)),
                    (1, tf.shape(opens)[1], 1)),
            tf.tile(tf.reshape(log_highs_mean, (-1, 1, 1)),
                    (1, tf.shape(opens)[1], 1)),
            tf.tile(tf.reshape(log_lows_mean, (-1, 1, 1)),
                    (1, tf.shape(opens)[1], 1)),
            tf.tile(tf.reshape(log_closes_mean, (-1, 1, 1)),
                    (1, tf.shape(opens)[1], 1)),
            tf.tile(tf.reshape(log_volumes_mean, (-1, 1, 1)),
                    (1, tf.shape(opens)[1], 1)),
            tf.tile(tf.reshape(log_x_mean, (-1, 1, 1)),
                    (1, tf.shape(opens)[1], 1)),
            tf.tile(tf.reshape(log_order_pricess, (-1, 1, 1)),
                    (1, tf.shape(opens)[1], 1)),
            tf.tile(tf.reshape(log_current_prices, (-1, 1, 1)),
                    (1, tf.shape(opens)[1], 1)),
        ],
                             axis=2)

        return tf.concat([x, features], axis=2)
 def get_current_pose(self):
     frame = str(self.frameline.text())
     self.tf_listener.waitForTransform(frame, self.robot_frame_name, rospy.Time(), rospy.Duration(2.))
     p_base = tfu.transform(frame, self.robot_frame_name, self.tf_listener) \
                 * tfu.tf_as_matrix(([0., 0., 0., 1.], tr.quaternion_from_euler(0,0,0)))
     t, r = tfu.matrix_as_tf(p_base)
     x = t[0]
     y = t[1]
     theta = tr.euler_from_quaternion(r)[2]
     print x,y,theta
     
     self.xline.setText(str(x))
     self.yline.setText(str(y))
     self.tline.setText(str(math.degrees(theta)))
    def get_current_pose(self):
        frame = str(self.frameline.text())
        self.tf_listener.waitForTransform(frame, self.robot_frame_name,
                                          rospy.Time(), rospy.Duration(2.))
        p_base = tfu.transform(frame, self.robot_frame_name, self.tf_listener) \
                    * tfu.tf_as_matrix(([0., 0., 0., 1.], tr.quaternion_from_euler(0,0,0)))
        t, r = tfu.matrix_as_tf(p_base)
        x = t[0]
        y = t[1]
        theta = tr.euler_from_quaternion(r)[2]
        print x, y, theta

        self.xline.setText(str(x))
        self.yline.setText(str(y))
        self.tline.setText(str(math.degrees(theta)))
Beispiel #5
0
 def pose_cartesian(self, frame='base_link'):
     gripper_tool_frame = self.arm + '_gripper_tool_frame'
     return tfu.transform(frame, gripper_tool_frame, self.tf_listener)
Beispiel #6
0
 def _turn_by(self, delta_ang, block=True):
     current_ang_odom = tr.euler_from_matrix(tfu.transform('base_footprint',\
                             'odom_combined', self.tflistener)[0:3, 0:3], 'sxyz')[2]
     self.turn_to(current_ang_odom + delta_ang, block)
Beispiel #7
0
 def get_pose(self):
     p_base = tfu.transform('map', 'base_footprint', self.tflistener) \
             * tfu.tf_as_matrix(([0., 0., 0., 1.], tr.quaternion_from_euler(0,0,0)))
     return tfu.matrix_as_tf(p_base)
Beispiel #8
0
    def get_inputs(self):

        self.log_x_encode_mean = sequence_mean(
            tf.log((self.high_encode + self.low_encode) / 2. + 1),
            self.series_length)
        self.log_x_encode = transform(
            (self.high_encode + self.low_encode) / 2., self.log_x_encode_mean)

        self.log_open_encode_mean = sequence_mean(tf.log(self.open_encode + 1),
                                                  self.series_length)
        self.log_open_encode = transform(self.open_encode,
                                         self.log_open_encode_mean)

        self.log_high_encode_mean = sequence_mean(tf.log(self.high_encode + 1),
                                                  self.series_length)
        self.log_high_encode = transform(self.high_encode,
                                         self.log_high_encode_mean)

        self.log_low_encode_mean = sequence_mean(tf.log(self.low_encode + 1),
                                                 self.series_length)
        self.log_low_encode = transform(self.low_encode,
                                        self.log_low_encode_mean)

        self.log_close_encode_mean = sequence_mean(
            tf.log(self.close_encode + 1), self.series_length)
        self.log_close_encode = transform(self.close_encode,
                                          self.log_close_encode_mean)

        self.log_volume_encode_mean = sequence_mean(
            tf.log(self.volume_encode + 1), self.series_length)
        self.log_volume_encode = transform(self.volume_encode,
                                           self.log_volume_encode_mean)

        self.position = tf.placeholder(tf.int32, [None])

        self.log_order_price = tf.log(self.order_price +
                                      1) - self.log_x_encode_mean

        self.log_est_current_price = tf.log(self.est_current_price +
                                            1) - self.log_x_encode_mean

        self.x = tf.expand_dims(self.log_x_encode, 2)

        self.features = tf.concat(
            [
                tf.expand_dims(self.log_open_encode, 2),
                tf.expand_dims(self.log_high_encode, 2),
                tf.expand_dims(self.log_low_encode, 2),
                tf.expand_dims(self.log_close_encode, 2),
                tf.expand_dims(self.log_volume_encode, 2),
                tf.tile(tf.expand_dims(tf.one_hot(self.position + 1, 3), 1),
                        (1, tf.shape(self.open_encode)[1], 1)),
                tf.tile(
                    tf.expand_dims(tf.one_hot(self.time_since_open, 60), 1),
                    (1, tf.shape(self.open_encode)[1], 1)),

                #tf.expand_dims(tf.cast(self.is_today, tf.float32), 2),
                tf.tile(tf.reshape(self.log_open_encode_mean, (-1, 1, 1)),
                        (1, tf.shape(self.open_encode)[1], 1)),
                tf.tile(tf.reshape(self.log_high_encode_mean, (-1, 1, 1)),
                        (1, tf.shape(self.open_encode)[1], 1)),
                tf.tile(tf.reshape(self.log_low_encode_mean, (-1, 1, 1)),
                        (1, tf.shape(self.open_encode)[1], 1)),
                tf.tile(tf.reshape(self.log_close_encode_mean, (-1, 1, 1)),
                        (1, tf.shape(self.open_encode)[1], 1)),
                tf.tile(tf.reshape(self.log_volume_encode_mean, (-1, 1, 1)),
                        (1, tf.shape(self.open_encode)[1], 1)),
                tf.tile(tf.reshape(self.log_x_encode_mean, (-1, 1, 1)),
                        (1, tf.shape(self.open_encode)[1], 1)),
                tf.tile(tf.reshape(self.log_order_price, (-1, 1, 1)),
                        (1, tf.shape(self.open_encode)[1], 1)),
                tf.tile(tf.reshape(self.log_est_current_price, (-1, 1, 1)),
                        (1, tf.shape(self.open_encode)[1], 1)),
            ],
            axis=2)

        self.x = tf.concat([self.x, self.features], axis=2)
 def _turn_by(self, delta_ang, block=True):
     current_ang_odom = tr.euler_from_matrix(tfu.transform('base_footprint',\
                             'odom_combined', self.tflistener)[0:3, 0:3], 'sxyz')[2]
     self.turn_to(current_ang_odom + delta_ang, block)
Beispiel #10
0
 def get_pose(self):
     p_base = tfu.transform('map', 'base_footprint', self.tflistener) \
             * tfu.tf_as_matrix(([0., 0., 0., 1.], tr.quaternion_from_euler(0,0,0)))
     return tfu.matrix_as_tf(p_base)
Beispiel #11
0
 def pose_cartesian(self, frame='base_link'):
     gripper_tool_frame = self.arm + '_gripper_tool_frame'
     return tfu.transform(frame, gripper_tool_frame, self.tf_listener)