triangula.dynamics: High Level Dynamics¶
This package contains classes used to enforce higher level dynamics such as skid control, waypoint based navigation, route planning and similar.
Per-Wheel Acceleration Limiting¶
The triangula.dynamics.RateLimit
class is a general rate limiter. Constructed with a limit function, it is
called repeatedly, passed a list of new values. It enforces any supplied limits on the allowable rates of change of
these values and returns a modified set with the limits applied. This can be used, for example, in the manual control
task to prevent the requested motor powers changing at too high a rate, providing a simple form of skid control at the
expense of responsiveness.
The limit function takes a previous value with associated timepoint, and a new value and new timepoint, and returns a potentially limited version of the new value. The simple static function generator within this class will enforce fixed rate per second limiting, but other functions could be passed in to provide smarter logic such as always allowing a reduction in the absolute value but limiting increases in magnitude.
-
class
triangula.dynamics.
RateLimit
(limit_function=None)[source]¶ Utility class to provide time-based rate limiting.
-
__init__
(limit_function=None)[source]¶ Create a new rate limit object, this can be used to enforce maximum rates of change in a set of values, these are generally expressed in rate per second, but could use any arbitrary function. For a default application the provided function which can handle rate per second should be sufficient, but the ability to provide a custom function allows for e.g. permitting larger rates when decreasing. This can be used in conjunction with the motor power functions to provide a degree of traction control (we can’t actually detect slipping in wheels, we just don’t have sufficient information), by limiting the maximum requested power rate change over time.
Parameters: limit_function – A function of old_value * old_time * new_value * new_time which will return a potentially limited new value given a requested value, historical value and timepoints for both.
-
static
fixed_rate_limit_function
(rate_per_second)[source]¶ Create and return a new limit function which will lock the maximum delta applied to the specified rate per second.
Parameters: rate_per_second (float) – Largest allowed delta per second Returns: A function which can be used in the triangula.dynamics.RateLimit
constructor and which will enforce a fixed maximum absolute rate of change across successive values such that no value in the supplied vector will vary at a higher rate than provided.
-
limit_and_return
(values)[source]¶ Take a list of values, update the internal state of the RateLimit and return a modified list of values which are restricted by the configured limit function.
Parameters: values (float[]) – Values to attempt to apply Returns: New values to apply, modified by the configured limit function
-
Motion Limiting¶
The triangula.dynamics.MotionLimit
class is an acceleration limiter specialised to handle rate limitation over
instances of triangula.chassis.Motion
. It is configured with maximum allowed linear and angular accelerations,
configured in millimeters per second per second, and radians per second per second respectively.
-
class
triangula.dynamics.
MotionLimit
(linear_acceleration_limit, angular_acceleration_limit)[source]¶ Utility class to limit rate of motion changes, similar to the
triangula.dynamics.RateLimit
but specialised to limit rate of change oftriangula.chassis.Motion
instances. It computes the necessary linear and angular acceleration required to transition from the previously registered Motion to the new one, and scales between the two Motions such that the limits aren’t exceeded. Linear interpolation is used to map between the previous and new motions. This works around the drawback with thetriangula.dynamics.RateLimit
when applied to wheel speeds where the resultant motion will incorporate a degree of rotation even when no rotations are included in either motion.-
__init__
(linear_acceleration_limit, angular_acceleration_limit)[source]¶ Create a new instance configured with the specified limits.
Parameters: - linear_acceleration_limit (float) – Maximum allowed linear acceleration in mm per second per second
- angular_acceleration_limit – Maximum allowed radial acceleration in radians per second per second
-
limit_and_return
(motion)[source]¶ Apply limits to the requested motion based on the current state of the MotionLimit, returning the closest Motion which complies with the specified limits.
Parameters: motion (triangula.chassis.Motion) – The requested triangula.chassis.Motion
,Returns: The modified motion, or the supplied one if it complied with the limits
-