Skip to main content

sorotraj

Generate trajectories for soft robots from yaml files (accompanies the Ctrl-P project)

Installation

Install the release version

This package is on pypi, so anyone can install it with pip: pip install sorotraj

Install the most-recent development version

  1. Clone the package from the github repo
  2. Navigate into the main folder
  3. pip install .

Usage

Minimal Example

import sorotraj

file_to_use = 'traj_setup/setpoint_traj_demo'

build = sorotraj.TrajBuilder()
build.load_traj_def(file_to_use)
traj = build.get_trajectory()
interp = sorotraj.Interpolator(traj)
actuation_fn = interp.get_interp_function(
                num_reps=1,
                speed_factor=2.0,
                invert_direction=False,
                as_array=False)
print(actuation_fn(2.155))

Check out the examples folder for more detailed usage examples

How to Set Up Trajectories:

Trajectories are made of three parts:

  1. main: used in a looping trajectory
  2. prefix: happens once before the main part
  3. suffix: happens once after the main part

Here's an example of what that might look like defined in a yaml file:

config:
    setpoints:
        # [time, finger1, finger2, n/c, n/c]
        main:
            - [0.0,   10, 12, 14,  16]
            - [1.0,    20, 0, 0,  0]
            - [2.0,   0, 20, 0,  0]
            - [3.0,     0, 0, 20, 0]
            - [4.0,     0, 0, 0, 20]
            - [5.0,    10, 12, 14, 16]

        prefix:
            - [0.000,   0, 0, 0,  0]
            - [1.0,    10, 12, 14,  16]

        suffix:
            - [2.000,   10, 12, 14,  16]
            - [3.0,  0, 0, 0,  0]

There are currently three types of ways to generate the main part of a trajectory:

  1. direct: You enter waypoints directly
    • Define waypoints as a list of lists of the form: [time in sec], [a_1], [a_2], ..., [a_n]
  2. interp: Interpolate between waypoints
    • Define waypoints as a list of lists of the form: [time in sec], [a_1], [a_2], ..., [a_n]
    • Set a few more parameters:
      • interp_type: (string) The type of interpolation to use. right now types include: 'linear', 'cubic', and 'none'
      • subsample_num: (int) The total number of subsamples over the whole trajectory
  3. waveform: Generate waveforms (very basic, still just in-phase waveforms across all channels)
    • Set up the waveform:
      • waveform_type: (string) Types include: square-sampled, square, sin, cos-up, cos-down, triangle, sawtooth-f, and sawtooth-r
      • waveform_freq: (float) Frequency in Hertz
      • waveform_max: (float) A list of the maximum values for the waveform, in the form: [20, 0, 15, 5]
      • waveform_min: (float) A list of the minimum values for the waveform, in the form: [0, 20, 0, 15]
    • Set a few more parameters:
      • subsample_num: (int) The total number of subsamples over the whole trajectory
      • num_cycles: (int) The number of cycles of the waveform
      • channels: (bool) Flags to turn channels on and off. A list of the form: [1,1,0,0]

How to use the Interpolator

interp = sorotraj.Interpolator(trajectory)
  • trajectory: A trajectory object generated by sorotraj.TrajBuilder
actuation_fn = interp.get_interp_function(
                num_reps=1,
                speed_factor=1.0,
                invert_direction=False,
                as_list=False)
  • num_reps: (int, default=1) Number of times to repeat the main looping trajectory
    • Must be positive, nonzero
  • speed_factor: (float, default=1.0) A speed multiplier that is applied to the main loop (but not the prefix or suffix)
    • Must be positive, nonzero
  • invert_direction: (bool, default=False) Negate the whole trajectory (useful if actuators have different directionalities)
    • (bool): Negate all channels
    • (list of bools): Choose which channels to negate
  • as_list: (bool, default=False) get the interpolation function as a list of 1D functions (one for each channel) rather than a single 2D interpolation

Download files

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

Source Distribution

sorotraj-0.7.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sorotraj-0.7-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file sorotraj-0.7.tar.gz.

File metadata

  • Download URL: sorotraj-0.7.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for sorotraj-0.7.tar.gz
Algorithm Hash digest
SHA256 82b80ae42b195941ebed937552e198cac62b9fe8bd1094f677eff0a885e19a78
MD5 a0e3a40228cadeb4ae19eb0590486b17
BLAKE2b-256 145fc1eab1e5822b36ab4b7dc59a184721e886c9a71f6701e3502647e4550a77

See more details on using hashes here.

File details

Details for the file sorotraj-0.7-py3-none-any.whl.

File metadata

  • Download URL: sorotraj-0.7-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for sorotraj-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 843ebc85b8ac977781d9f2f41e6a0e80d6d43fae58903e6fa88e017a89f7ae3d
MD5 195f796d1152f4be7dc9480ac906e2d2
BLAKE2b-256 d7b199844487a615d901219065f57a5af5f0cdcabe244a3b185882bb5bbf999c

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.8

2 files

1.2.7

2 files

1.2.6

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.0.1

2 files

1.0.0

2 files

0.14

2 files

0.13

2 files

0.11

1 file

0.10

1 file

0.9

2 files

0.8

2 files

This release

0.7 This release

2 files

0.6

2 files

0.5

2 files

0.4

2 files

0.3

2 files

0.2

2 files

0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page