How to use the evo.EvoException function in evo

To help you get started, we’ve selected a few evo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MichaelGrupp / evo / evo / main_config.py View on Github external
import colorama
from colorama import Fore, Style
from pygments import highlight, lexers, formatters

from evo import EvoException
from evo.tools import log, user, settings
from evo.tools.settings_template import DEFAULT_SETTINGS_DICT_DOC
from evo.tools.settings_template import DEFAULT_SETTINGS_DICT

logger = logging.getLogger(__name__)

SEP = "-" * 80


class ConfigError(EvoException):
    pass


def log_info_dict_json(data_str, colored=True):
    data_str = json.dumps(data_str, indent=4, sort_keys=True)
    if colored and os.name != "nt":
        data_str = highlight(data_str, lexers.JsonLexer(),
                             formatters.Terminal256Formatter(style="monokai"))
    logger.info(data_str)


def show(config_path, colored=True):
    with open(config_path) as config_file:
        log_info_dict_json(json.load(config_file), colored)
github MichaelGrupp / evo / evo / core / lie_algebra.py View on Github external
import numpy as np
import scipy.spatial.transform as sst
from distutils.version import LooseVersion
from scipy import __version__ as scipy_version

from evo import EvoException
from evo.core import transformations as tr

# scipy.spatial.transform.Rotation.*_matrix() was introduced in 1.4,
# which is not available for Python 2.7.
# Use the legacy direct cosine matrix naming (*_dcm()) if needed.
# TODO: remove this junk once Python 2.7 is finally dead in ROS.
_USE_DCM_NAME = LooseVersion(scipy_version) < LooseVersion("1.4")


class LieAlgebraException(EvoException):
    pass


def hat(v):
    """
    :param v: 3x1 vector
    :return: 3x3 skew symmetric matrix
    """
    # yapf: disable
    return np.array([[0.0, -v[2], v[1]],
                     [v[2], 0.0, -v[0]],
                     [-v[1], v[0], 0.0]])
    # yapf: enable


def vee(m):
github MichaelGrupp / evo / evo / core / sync.py View on Github external
You should have received a copy of the GNU General Public License
along with evo.  If not, see .
"""

import copy
import logging

import numpy as np

from evo import EvoException
from evo.core.trajectory import PoseTrajectory3D

logger = logging.getLogger(__name__)


class SyncException(EvoException):
    pass


def matching_time_indices(stamps_1, stamps_2, max_diff=0.01, offset_2=0.0):
    """
    Searches for the best matching timestamps of two lists of timestamps
    and returns the list indices of the best matches.
    :param stamps_1: first vector of timestamps (numpy array)
    :param stamps_2: second vector of timestamps (numpy array)
    :param max_diff: max. allowed absolute time difference
    :param offset_2: optional time offset to be applied to stamps_2
    :return: list of indices of the matching timestamps in stamps_1
    """
    matching_indices = []
    stamps_2 = copy.deepcopy(stamps_2)
    stamps_2 += offset_2
github MichaelGrupp / evo / evo / entry_points.py View on Github external
import argparse
import logging
import sys

import six

import argcomplete
from evo import EvoException, NullHandler

logger = logging.getLogger(__name__)

if six.PY2:
    KNOWN_EXCEPTIONS = EvoException
else:
    KNOWN_EXCEPTIONS = (EvoException, FileNotFoundError)
"""
the actual entry points:
to save time for argcomplete (tab bash completion),
only do required imports in respective module when creating parser
(no expensive global imports)
"""


def ape():
    from evo import main_ape
    parser = main_ape.parser()
    argcomplete.autocomplete(parser)
    launch(main_ape, parser)


def rpe():
github MichaelGrupp / evo / evo / core / trajectory.py View on Github external
"""

import copy
import logging

import numpy as np

from evo import EvoException
import evo.core.transformations as tr
import evo.core.geometry as geometry
from evo.core import lie_algebra as lie

logger = logging.getLogger(__name__)


class TrajectoryException(EvoException):
    pass


class PosePath3D(object):
    """
    just a path, no temporal information
    also: base class for real trajectory
    """

    def __init__(self, positions_xyz=None, orientations_quat_wxyz=None,
                 poses_se3=None, meta=None):
        """
        :param positions_xyz: nx3 list of x,y,z positions
        :param orientations_quat_wxyz: nx4 list of quaternions (w,x,y,z format)
        :param poses_se3: list of SE(3) poses
        :param meta: optional metadata
github MichaelGrupp / evo / evo / tools / settings.py View on Github external
from colorama import Fore

from evo import EvoException

logger = logging.getLogger(__name__)

PACKAGE_BASE_PATH = os.path.abspath(__file__ + "/../../")
PACKAGE_VERSION = open(os.path.join(PACKAGE_BASE_PATH, "version")).read()
USER_ASSETS_PATH = os.path.join(os.path.expanduser('~'), ".evo")
USER_ASSETS_VERSION_PATH = os.path.join(USER_ASSETS_PATH, "assets_version")
DEFAULT_PATH = os.path.join(USER_ASSETS_PATH, "settings.json")
GLOBAL_LOGFILE_PATH = os.path.join(USER_ASSETS_PATH, "evo.log")


class SettingsException(EvoException):
    pass


class SettingsContainer(dict):
    def __init__(self, data, lock=True):
        super(SettingsContainer, self).__init__()
        for k, v in data.items():
            setattr(self, k, v)
        setattr(self, "__locked__", lock)

    @classmethod
    def from_json_file(cls, settings_path):
        with open(settings_path) as settings_file:
            data = json.load(settings_file)
        return SettingsContainer(data)
github MichaelGrupp / evo / evo / tools / file_interface.py View on Github external
from evo import EvoException
import evo.core.lie_algebra as lie
import evo.core.transformations as tr
from evo.core import result
from evo.core.trajectory import PosePath3D, PoseTrajectory3D
from evo.tools import user

logger = logging.getLogger(__name__)

SUPPORTED_ROS_MSGS = {
    "geometry_msgs/PoseStamped", "geometry_msgs/PoseWithCovarianceStamped",
    "geometry_msgs/TransformStamped", "nav_msgs/Odometry"
}


class FileInterfaceException(EvoException):
    pass


def has_utf8_bom(file_path):
    """
    Checks if the given file starts with a UTF8 BOM
    wikipedia.org/wiki/Byte_order_mark
    """
    size_bytes = os.path.getsize(file_path)
    if size_bytes < 3:
        return False
    with open(file_path, 'rb') as f:
        return not int(binascii.hexlify(f.read(3)), 16) ^ 0xEFBBBF


def csv_read_matrix(file_path, delim=',', comment_str="#"):
github MichaelGrupp / evo / evo / core / filters.py View on Github external
You should have received a copy of the GNU General Public License
along with evo.  If not, see .
"""

import logging

import numpy as np

from evo import EvoException
from evo.core import geometry, trajectory
from evo.core import lie_algebra as lie

logger = logging.getLogger(__name__)


class FilterException(EvoException):
    pass


def filter_pairs_by_index(poses, delta, all_pairs=False):
    """
    filters pairs in a list of SE(3) poses by their index distance
    :param poses: list of SE(3) poses
    :param delta: the index distance used for filtering
    :param all_pairs: use all pairs instead of consecutive pairs
    :return: list of index tuples of the filtered pairs
    """
    if all_pairs:
        ids = range(len(poses))
        id_pairs = [(i, i + delta) for i in ids if i + delta < len(poses)]
    else:
        ids = np.arange(0, len(poses), delta)
github MichaelGrupp / evo / evo / core / metrics.py View on Github external
import numpy as np

from evo import EvoException
from evo.core import filters
from evo.core.result import Result
from evo.core import lie_algebra as lie

if sys.version_info[0] >= 3 and sys.version_info[1] >= 4:
    ABC = abc.ABC
else:
    ABC = abc.ABCMeta('ABC', (), {})

logger = logging.getLogger(__name__)


class MetricsException(EvoException):
    pass


class StatisticsType(Enum):
    rmse = "rmse"
    mean = "mean"
    median = "median"
    std = "std"
    min = "min"
    max = "max"
    sse = "sse"


class PoseRelation(Enum):
    full_transformation = "full transformation"
    translation_part = "translation part"
github MichaelGrupp / evo / evo / core / result.py View on Github external
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with evo.  If not, see .
"""

import copy
import logging

import numpy as np
from evo import EvoException

logger = logging.getLogger(__name__)


class ResultException(EvoException):
    pass


class Result(object):
    def __init__(self):
        self.info = {}
        self.stats = {}
        self.np_arrays = {}
        self.trajectories = {}

    def __str__(self):
        return self.pretty_str(stats=True)

    def __eq__(self, other):
        if not isinstance(other, Result):
            return False