sorotraj
Generate trajectories for soft robots from yaml files (accompanies the Ctrl-P project and SoMo simulation framework)
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
- Clone the package from the github repo
- Navigate into the main folder
pip install .
Usage
Minimal Example
import sorotraj
file_to_use = 'traj_setup/setpoint_traj_demo.yaml'
traj = sorotraj.TrajBuilder()
traj.load_traj_def(file_to_use)
trajectory = traj.get_trajectory()
interp = sorotraj.Interpolator(trajectory)
actuation_fn = interp.get_interp_function(
num_reps=1,
speed_factor=2.0,
invert_direction=False)
print(actuation_fn(2.155))
Check out the examples folder for more detailed usage examples
Set Up Trajectories:
Trajectories are made of three parts:
- main: used in a looping trajectory
- prefix: happens once before the main part
- 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:
- direct: You enter waypoints directly
- Define waypoints as a list of lists of the form:
[time in sec], [a_1], [a_2], ..., [a_n]
- Define waypoints as a list of lists of the form:
- 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
- interp_type: (
- Define waypoints as a list of lists of the form:
- 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]
- waveform_type: (
- 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]
- subsample_num: (
- Set up the waveform:
Convert Trajectories Line-by-Line
Check out the build_convert_trajectories.py example.
- Set up a conversion function
- Inputs: one original trajectory line (
list) - Outputs: one new trajectory line (
list)
- Inputs: one original trajectory line (
- Load the trajectory like normal
traj.load_traj_def(file_to_use)
- Convert the trajectory by passing the conversion function
traj.convert_traj(conversion_function)
- This conversion overwrites the original trajectory. Now you can save it like normal
traj.save_traj(file_to_save)
- Convert the trajectory definition by passing the conversion function
traj.convert_definition(conversion_function)
- This conversion overwrites the original trajectory definition and reguilds the trajectory. Now you can save the definition like normal
traj.save_definition(file_to_save)
Build an interpolator
interp = sorotraj.Interpolator(trajectory)
- trajectory: A trajectory object generated by
sorotraj.TrajBuilder
actuation_fn, final_time = interp.get_traj_function(
num_reps=1,
speed_factor=1.0,
invert_direction=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 ints): Choose which channels to negate with a list of channel indices
- (
cycle_fn = interp.get_cycle_function(
num_reps=1,
speed_factor=1.0,
invert_direction=False)
- Same inputs as
get_interp_function(), but returns a cycle function (returns the current cycle as a function of time) - cycle_fn takes these values:
- -2 = Prefix
- -1 = Suffix
- 0-N = Main loop index
Metadata
Release files for sorotraj 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sorotraj-1.3.2.tar.gz | 15.8 kB | Without provenance | Details for sorotraj-1.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sorotraj-1.3.2-py3-none-any.whl | Python 3 | none | any | Details for sorotraj-1.3.2-py3-none-any.whl |
Total release size: 29.9 kB
Release files / sorotraj-1.3.2.tar.gz
| Download URL | sorotraj-1.3.2.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0c0b44799c673464cbc5bac4189d0fb7eb95ddad5f1676dab7fffc284551f62
|
|
BLAKE2b-256 checksum How to use checksums |
a95957ac5a4a08311cfc9be9b747be4427a11a11e1df18632e0bd9405609b10c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/62.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.10
|
Release files / sorotraj-1.3.2-py3-none-any.whl
| Download URL | sorotraj-1.3.2-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13cc5f0b4831337d31364b98c71c079dad13de0bf9411da3773c3b33dbcc397c
|
|
BLAKE2b-256 checksum How to use checksums |
6ac46edf025f6ae97b092949a66a91349808339a2997a678bd25aff78efa7489
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/62.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.10
|
Security for sorotraj 1.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.