Skip to main content

Data, types, pipes, manipulation for embodied learning.

Project description

mbodied-data

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install embdata

Classes

Coordinate

Classes for representing geometric data in cartesian and polar coordinates.

Pose

  • (x, y, z, roll, pitch, and yaw) in some reference frame.
  • Contains .numpy(), .dict(), .dataset() methods from Sample class we all know and love.

Example:

    >>> import math
    >>> pose_3d = Pose3D(x=1, y=2, theta=math.pi/2)
    >>> pose_3d.to("cm")
    Pose3D(x=100.0, y=200.0, theta=1.5707963267948966)

    >>> pose_3d.to("deg")
    Pose3D(x=1.0, y=2.0, theta=90.0)

    >>> class BoundedPose6D(Pose6D):
    ...     x: float = CoordinateField(bounds=(0, 5))

    >>> pose_6d = BoundedPose6D(x=10, y=2, z=3, roll=0, pitch=0, yaw=0)
    Traceback (most recent call last):
    ...
    ValueError: x value 10 is not within bounds (0, 5)

Episode

The Episode class provides a list-like interface for a sequence of observations, actions, and/or other data points. It is designed to streamline exploratory data analysis and manipulation of time series data. Episodes can be easily concatenated, iterated over, and manipulated similar to lists.

class Episode(Sample):
    """A list-like interface for a sequence of observations, actions, and/or other.

    Meant to streamline exploratory data analysis and manipulation of time series data.

    Just append to an episode like you would a list and you're ready to start training models.

    To iterate over the steps in an episode, use the `iter` method.

Example:

    >>> episode = Episode(steps=[TimeStep(), TimeStep(), TimeStep()])
    >>> for step in episode.iter():
    ...     print(step)

To concatenate two episodes, use the + operator.

Example:

    >>> episode1 = Episode(steps=[TimeStep(), TimeStep()])
    >>> episode2 = Episode(steps=[TimeStep(), TimeStep()])
    >>> combined_episode = episode1 + episode2
    >>> len(combined_episode)
    4 
 def from_list(cls, steps: List[Dict|Sample], observation_key:str, action_key: str, supervision_key:str = None) -> 'Episode':
        """Create an episode from a list of dictionaries.

        Args:
            steps (List[Dict|Sample]): The list of dictionaries representing the steps.
            action_key (str): The key for the action in each dictionary.
            observation_key (str): The key for the observation in each dictionary.
            supervision_key (str, optional): The key for the supervision in each dictionary. Defaults to None.

        Returns:
            'Episode': The created episode.

Example:

    >>> steps = [
    ...     {"observation": Image((224,224)), "action": Sample(1), "supervision": 0},
    ...     {"observation": Image((224,224)), "action": Sample(1), "supervision": 1},
    ...     {"observation": Image((224,224)), "action": Sample(100), "supervision": 0},
    ...     {"observation": Image((224,224)), "action": Sample(300), "supervision": 1},
    ... ]
    >>> episode = Episode.from_list(steps, "observation", "action", "supervision")
    >>> episode
    Episode(
        Stats(
            mean=[100.5]
            variance=[19867.0]
            skewness=[0.821]
            kurtosis=[-0.996]
            min=[1]
            max=[300]
            lower_quartile=[1.0]
            median=[50.5]
            upper_quartile=[150.0]
            non_zero_count=[4]
            zero_count=[0])
    )

Exploratory data analysis for common minmax and standardization normalization methods.

Example

    >>> steps = [
    ...     {"observation": Image((224,224)), "action": 1, "supervision": 0},
    ...     {"observation": Image((224,224)), "action": 1, "supervision": 1},
    ...     {"observation": Image((224,224)), "action": 100, "supervision": 0},
    ...     {"observation": Image((224,224)), "action": 300, "supervision": 1},
    ]
    >>> episode = Episode.from_list(steps, "observation", "action", "supervision")
    >>> episode.trajectory().transform("minmax")
    Episode(
        Stats(
            mean=[0.335]
            variance=[0.198]
            skewness=[0.821]
            kurtosis=[-0.996]
            min=[0.0]
            max=[1.0]
            lower_quartile=[0.0]
            median=[0.168]
            upper_quartile=[0.503]
            non_zero_count=[4]
            zero_count=[0])
    )
    >>> episode.trajectory().transform("standard")
    Episode(
        Stats(
            mean=[0.335]
            variance=[0.198]
            skewness=[0.821]
            kurtosis=[-0.996]
            min=[-1.0]
            max=[1.0]
            lower_quartile=[-1.0]
            median=[0.0]
            upper_quartile=[1.0]
            non_zero_count=[4]
            zero_count=[0])
    )
    >>> episode.trajectory().transform("unstandard", mean=0.335, std=0.198)
    Episode(
        Stats(
            mean=[100.5]
            variance=[19867.0]
            skewness=[0.821]
            kurtosis=[-0.996]
            min=[1]
            max=[300]
            lower_quartile=[1.0]
            median=[50.5]
            upper_quartile=[150.0]
            non_zero_count=[4]
            zero_count=[0])
    )
    >>> episode.trajectory().frequencies().show()  # .save("path/to/save.png") also works.
    >>> episode.trajectory().plot().show()

Upsample and downsample the trajectory to a target frequency.

  • Uses bicupic and rotation spline interpolation to upsample and downsample the trajectory to a target frequency.
    >>> episode.trajectory().resample(target_hz=10).plot().show() # .save("path/to/save.png") also works.

Make actions relative or absolute

  • Make actions relative or absolute to the previous action.
    >>> relative_actions = episode.trajectory("action").make_relative()
    >>>  absolute_again = episode.trajectory().make_absolute(initial_state=relative_actions[0])
    assert np.allclose(episode.trajectory("action"), absolute_again)

Applications

What are the grasping positions in the world frame?

    >>> initial_state = episode.trajectory('state').flatten(to='end_effector_pose')[0]
    >>> episode.trajectory('action').make_absolute(initial_state=initial_state).filter(lambda x: x.grasp == 1)

License

embdata is distributed under the terms of the apache-2.0 license.

Design Decisions

  • Grasp value is [-1, 1] so that the default value is 0.
  • Motion rather than Action to distinguish from non-physical actions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

embdata-0.0.2.tar.gz (91.7 kB view details)

Uploaded Source

Built Distribution

embdata-0.0.2-py3-none-any.whl (99.6 kB view details)

Uploaded Python 3

File details

Details for the file embdata-0.0.2.tar.gz.

File metadata

  • Download URL: embdata-0.0.2.tar.gz
  • Upload date:
  • Size: 91.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for embdata-0.0.2.tar.gz
Algorithm Hash digest
SHA256 335c36c7241e0ab08b6241ba118be3237df001c6c358389eeaaa1dd3fc5a3362
MD5 62df389af95bacb47c6eba28ae973c21
BLAKE2b-256 2463c02ff0d5aab7d75cf033c7e2c1bd1f5e6bcd5871be9b48f54a60543465a5

See more details on using hashes here.

File details

Details for the file embdata-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: embdata-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 99.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for embdata-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db5dae5183b2c75977285faa5a82c5ac84405956beb9f4669323252ca3d11632
MD5 3344cfbba9586cdef36c550f17b355a0
BLAKE2b-256 9a612c2df6f73b7491040a2804054fa195c3a34861040c70dc10848da1ebe6ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page