Exemplo n.º 1
0
    def update(self, x, t=None):
        """
        Update the plots with new data x. Assumes x is a one-dimensional array.
        """
        x = np.ravel([x])

        if not self._init:
            self.init(x.shape[0])

        if not t:
            t = self._t

        assert x.shape[0] == self._data_len
        t = np.array([t]).reshape((1, 1))
        x = x.reshape((self._data_len, 1))
        mean = np.mean(x).reshape((1, 1))

        self._t += 1
        self._ts = np.append(self._ts, t, axis=1)
        self._data = np.append(self._data, x, axis=1)
        self._data_mean = np.append(self._data_mean, mean, axis=1)

        for i in range(self._data_len):
            self._plots[i].set_data(self._ts, self._data[i, :])
        self._plots_mean.set_data(self._ts, self._data_mean[0, :])

        self._ax.set_xlim(self._ts[0, 0]-0.5, max(self._ts[-1, 0], self._min_itr)+0.5)

        y_min, y_max = np.amin(self._data), np.amax(self._data)
        self._ax.set_ylim(buffered_axis_limits(y_min, y_max, buffer_factor=1.1))
        self.draw()
    def update(self, x):
        """
        Update the plots with new data x. Assumes x is a one-dimensional array.
        """
        x = np.ravel([x])

        if not self._init:
            self.init(x.shape[0])

        assert x.shape[0] == self._data_len
        x = x.reshape((1, self._data_len))

        self._t += 1
        self._data = np.append(self._data, x, axis=0)

        t, tw = self._t, self._time_window
        t0, tf = (0, t) if t < tw else (t - tw, t)
        for i in range(self._data_len):
            self._plots[i].set_data(np.arange(t0, tf), self._data[t0:tf, i])

        x_range = (0, tw) if t < tw else (t - tw, t)
        self._ax.set_xlim(x_range)

        y_min, y_max = np.amin(self._data[t0:tf, :]), np.amax(
            self._data[t0:tf, :])
        self._ax.set_ylim(
            buffered_axis_limits(y_min, y_max, buffer_factor=1.25))

        self.draw()
Exemplo n.º 3
0
    def update(self, x, t=None):
        """
        Update the plots with new data x. Assumes x is a one-dimensional array.
        """
        x = np.ravel([x])

        if not self._init:
            self.init(x.shape[0])

        if not t:
            t = self._t

        assert x.shape[0] == self._data_len
        t = np.array([t]).reshape((1, 1))
        x = x.reshape((self._data_len, 1))
        mean = np.mean(x).reshape((1, 1))

        self._t += 1
        self._ts = np.append(self._ts, t, axis=1)
        self._data = np.append(self._data, x, axis=1)
        self._data_mean = np.append(self._data_mean, mean, axis=1)

        for i in range(self._data_len):
            self._plots[i].set_data(self._ts, self._data[i, :])
        self._plots_mean.set_data(self._ts, self._data_mean[0, :])

        self._ax.set_xlim(self._ts[0, 0]-0.5, max(self._ts[-1, 0], self._min_itr)+0.5)

        y_min, y_max = np.amin(self._data), np.amax(self._data)
        self._ax.set_ylim(buffered_axis_limits(y_min, y_max, buffer_factor=1.1))
        self.draw()
Exemplo n.º 4
0
    def update(self, x):
        """
        Update the plots with new data x. Assumes x is a one-dimensional array.
        """
        x = np.ravel([x])

        if not self._init:
            self.init(x.shape[0])

        assert x.shape[0] == self._data_len
        x = x.reshape((1, self._data_len))

        self._t += 1
        self._data = np.append(self._data, x, axis=0)

        t, tw = self._t, self._time_window
        t0, tf = (0, t) if t < tw else (t - tw, t)
        for i in range(self._data_len):
            self._plots[i].set_data(np.arange(t0, tf), self._data[t0:tf, i])

        x_range = (0, tw) if t < tw else (t - tw, t)
        self._ax.set_xlim(x_range)

        y_min, y_max = np.amin(self._data[t0:tf, :]), np.amax(self._data[t0:tf, :])
        self._ax.set_ylim(buffered_axis_limits(y_min, y_max, buffer_factor=1.25))

        self.draw()
Exemplo n.º 5
0
 def _calculate_3d_axis_limits(self, traj_sample_lists, pol_sample_lists):
     """
     Calculate the 3D axis limits shared between trajectory plots,
     based on the minimum and maximum xyz values across all samples.
     """
     all_eept = np.empty((0, 3))
     sample_lists = traj_sample_lists
     if pol_sample_lists:
         sample_lists += traj_sample_lists
     for sample_list in sample_lists:
         for sample in sample_list.get_samples():
             ee_pt = sample.get(END_EFFECTOR_POINTS)
             for i in range(ee_pt.shape[1] / 3):
                 ee_pt_i = ee_pt[:, 3 * i + 0:3 * i + 3]
                 all_eept = np.r_[all_eept, ee_pt_i]
     min_xyz = np.amin(all_eept, axis=0)
     max_xyz = np.amax(all_eept, axis=0)
     xlim = buffered_axis_limits(min_xyz[0], max_xyz[0], buffer_factor=1.25)
     ylim = buffered_axis_limits(min_xyz[1], max_xyz[1], buffer_factor=1.25)
     zlim = buffered_axis_limits(min_xyz[2], max_xyz[2], buffer_factor=1.25)
     return xlim, ylim, zlim
Exemplo n.º 6
0
 def _calculate_3d_axis_limits(self, traj_sample_lists, pol_sample_lists):
     """
     Calculate the 3D axis limits shared between trajectory plots,
     based on the minimum and maximum xyz values across all samples.
     """
     all_eept = np.empty((0, 3))
     sample_lists = traj_sample_lists
     if pol_sample_lists:
         sample_lists += traj_sample_lists
     for sample_list in sample_lists:
         for sample in sample_list.get_samples():
             ee_pt = sample.get(END_EFFECTOR_POINTS)
             for i in range(ee_pt.shape[1]/3):
                 ee_pt_i = ee_pt[:, 3*i+0:3*i+3]
                 all_eept = np.r_[all_eept, ee_pt_i]
     min_xyz = np.amin(all_eept, axis=0)
     max_xyz = np.amax(all_eept, axis=0)
     xlim = buffered_axis_limits(min_xyz[0], max_xyz[0], buffer_factor=1.25)
     ylim = buffered_axis_limits(min_xyz[1], max_xyz[1], buffer_factor=1.25)
     zlim = buffered_axis_limits(min_xyz[2], max_xyz[2], buffer_factor=1.25)
     return xlim, ylim, zlim