Simulated Motor Path Generator

rcp.npath

Path generator objects for simulating low-level motion control.

class rcp.npath.NPath(N=4)[source]

Representation of a set of winch path generators. This keeps the physical calculations separate from the graphics. This reimplements the functionality of Path.h and Path.cpp in the StepperWinch Arduino sketch. The model is based on a second-order simple harmonic oscillator. The model is vectorized using numpy to calculate multiple models simultaneously. It uses single-precision floating point to better simulate the Arduino model.

The command API should be kept compatible with the winch interface class which transmits commands over a serial port to an Arduino-based winch.

increment_reference(axis, offset)[source]

Add a signed offset to one or more reference positions. This has the effect of applying a triangular impulse; the reference trajectory will make a step, then ramp back to the target vector.

The units are dimensionless ‘steps’. If using a microstepping driver, these may be less than a physical motor step.

Parameters
  • axis – either a integer axis number or list of axis numbers

  • offset – either a integer step offset or list of step offsets

increment_target(axis, offset)[source]

Add a signed offset to one or more target positions. The units are dimensionless ‘steps’. If using a microstepping driver, these may be less than a physical motor step.

Parameters
  • axis – either a integer axis number or list of axis numbers

  • offset – either a integer step offset or list of step offsets

positions()[source]

Return a list of the current winch positions.

set_freq_damping(axis, freq, damping)[source]

Set the second order model resonance parameters for one or more path generators. Note that the same parameters are applied to all specified axes, unlike the target setting functions.

Parameters
  • axis – either a integer axis number or list of axis numbers

  • freq – scalar specifying the frequency in Hz

  • damping – scalar specifying the damping ratio, e.g. 1.0 at critical damping.

set_speed(axis, speed)[source]

Set the ramp speed of one or more targets in units/sec. If a speed value is less than or equal to zero, it is treated as unlimited, and the reference position will move in steps instead of ramps.

Parameters
  • axis – either a integer axis number or list of axis numbers

  • speed – either a ramp speed or list of ramp speeds

set_target(axis, position)[source]

Set the target position of one or more axes.

Parameters
  • axis – either a integer axis number or list of axis numbers

  • position – either a integer step position or list of step positions

update_for_interval(interval)[source]

Run the simulator for the given interval, which may include one or more integration steps.