diff --git a/evo/__init__.py b/evo/__init__.py index 42789ac..6fb6d5a 100644 --- a/evo/__init__.py +++ b/evo/__init__.py @@ -8,7 +8,7 @@ PACKAGE_BASE_PATH = Path(__file__).absolute().parent -__version__ = "v1.30.3" +__version__ = "v1.30.4" class EvoException(Exception): diff --git a/evo/core/filters.py b/evo/core/filters.py index 0db1bda..6eca8ce 100644 --- a/evo/core/filters.py +++ b/evo/core/filters.py @@ -47,10 +47,10 @@ def filter_pairs_by_index(poses: typing.Sequence[np.ndarray], delta: int, :return: list of index tuples of the filtered pairs """ if all_pairs: - ids = np.arange(len(poses)) + ids = np.arange(len(poses), dtype=int) id_pairs = [(i, i + delta) for i in ids if i + delta < len(poses)] else: - ids = np.arange(0, len(poses), delta) + ids = np.arange(0, len(poses), delta, dtype=int) id_pairs = [(i, j) for i, j in zip(ids, ids[1:])] return id_pairs diff --git a/evo/core/trajectory.py b/evo/core/trajectory.py index 9c279f0..5927298 100644 --- a/evo/core/trajectory.py +++ b/evo/core/trajectory.py @@ -172,7 +172,7 @@ def transform(self, t: np.ndarray, right_mul: bool = False, self._poses_se3 = [np.dot(p, t) for p in self.poses_se3] elif right_mul and propagate: # Transform each pose and propagate resulting drift to the next. - ids = np.arange(0, self.num_poses, 1) + ids = np.arange(0, self.num_poses, 1, dtype=int) rel_poses = [ lie.relative_se3(self.poses_se3[i], self.poses_se3[j]).dot(t) for i, j in zip(ids, ids[1:]) diff --git a/evo/main_res.py b/evo/main_res.py index 4f8ca86..6d41c74 100644 --- a/evo/main_res.py +++ b/evo/main_res.py @@ -188,10 +188,10 @@ def run(args: argparse.Namespace) -> None: # handle NaNs from concat() above error_df.interpolate(method="index", limit_area="inside").plot( ax=fig_raw.gca(), colormap=colormap, style=linestyles, - title=first_title, alpha=SETTINGS.plot_trajectory_alpha) + title=first_title, alpha=SETTINGS.plot_trajectory_alpha, + legend=SETTINGS.plot_show_legend) plt.xlabel(index_label) plt.ylabel(metric_label) - plt.legend(frameon=True) plot_collection.add_figure("raw", fig_raw) # statistics plot @@ -200,9 +200,9 @@ def run(args: argparse.Namespace) -> None: include = df.loc["stats"].index.isin(SETTINGS.plot_statistics) if any(include): df.loc["stats"][include].plot(kind="barh", ax=fig_stats.gca(), - colormap=colormap, stacked=False) + colormap=colormap, stacked=False, + legend=SETTINGS.plot_show_legend) plt.xlabel(metric_label) - plt.legend(frameon=True) plot_collection.add_figure("stats", fig_stats) # grid of distribution plots diff --git a/evo/main_traj.py b/evo/main_traj.py index 9f06458..60ff3c4 100755 --- a/evo/main_traj.py +++ b/evo/main_traj.py @@ -363,7 +363,8 @@ def run(args): style=SETTINGS.plot_reference_linestyle, color=SETTINGS.plot_reference_color, alpha=SETTINGS.plot_reference_alpha, - label=short_traj_name) + label=short_traj_name, + start_timestamp=start_time) except trajectory.TrajectoryException as error: logger.error( f"Can't plot speeds of {short_traj_name}: {error}") @@ -416,7 +417,8 @@ def run(args): style=SETTINGS.plot_trajectory_linestyle, color=color, alpha=SETTINGS.plot_trajectory_alpha, - label=short_traj_name) + label=short_traj_name, + start_timestamp=start_time) except trajectory.TrajectoryException as error: logger.error( f"Can't plot speeds of {short_traj_name}: {error}") diff --git a/evo/tools/plot.py b/evo/tools/plot.py index c780175..0dec9a2 100644 --- a/evo/tools/plot.py +++ b/evo/tools/plot.py @@ -490,8 +490,9 @@ def traj_colormap(ax: Axes, traj: trajectory.PosePath3D, array: ListOrArray, "{0:0.3f}".format(max_map) ]) if title: - ax.legend(frameon=True) ax.set_title(title) + if SETTINGS.plot_show_legend: + ax.legend(frameon=True) if plot_start_end_markers: add_start_end_markers(ax, plot_mode, traj, start_color=colors[0], end_color=colors[-1]) @@ -652,7 +653,8 @@ def traj_rpy(axarr: np.ndarray, traj: trajectory.PosePath3D, style: str = '-', def speeds(ax: Axes, traj: trajectory.PoseTrajectory3D, style: str = '-', - color="black", label: str = "", alpha: float = 1.): + color="black", label: str = "", alpha: float = 1., + start_timestamp: typing.Optional[float] = None): """ Plots the speed between poses of a trajectory. Note that a speed value is shown at the timestamp of the newer pose. @@ -662,10 +664,16 @@ def speeds(ax: Axes, traj: trajectory.PoseTrajectory3D, style: str = '-', :param color: matplotlib color :param label: label (for legend) :param alpha: alpha value for transparency + :param start_timestamp: optional start time of the reference + (for x-axis alignment) """ if not isinstance(traj, trajectory.PoseTrajectory3D): raise PlotException("speeds can only be plotted with trajectories") - ax.plot(traj.timestamps[1:], traj.speeds, style, color=color, alpha=alpha, + if start_timestamp: + timestamps = traj.timestamps - start_timestamp + else: + timestamps = traj.timestamps + ax.plot(timestamps[1:], traj.speeds, style, color=color, alpha=alpha, label=label) ax.set_xlabel("$t$ (s)") ax.set_ylabel("$v$ (m/s)") @@ -780,7 +788,8 @@ def error_array(ax: Axes, err_array: ListOrArray, plt.ylabel(ylabel if ylabel else name) plt.xlabel(xlabel) plt.title(title) - plt.legend(frameon=True) + if SETTINGS.plot_show_legend: + plt.legend(frameon=True) def ros_map( diff --git a/evo/tools/settings_template.py b/evo/tools/settings_template.py index db4ebc2..95438b9 100644 --- a/evo/tools/settings_template.py +++ b/evo/tools/settings_template.py @@ -85,7 +85,7 @@ def get_default_plot_backend() -> str: "Can also be set to 'none'.") ), "plot_figsize": ( - [6, 6], + [10, 10], "The default size of one (sub)plot figure (width, height)." ), "plot_fontfamily": (