roshask-0.2.1: Haskell support for the ROS robotics framework.

Safe HaskellNone
LanguageHaskell2010

Ros.Topic.Stamped

Description

Functions for fusing Topics based on TimeStamp fields of the underlying messages. This module shadows some of the functionality of the Ros.TopicUtil module. The difference is that the functions exported by this module use time stamps to correlate two Topics.

The correlation uses a bracketing pair of values from one Topic to pick a correspondance for each value from the other Topic. This bracketing approach induces some latency. The most common use case is calling the bothNew function with a Topic that produces very quickly (faster than the minimum required update rate), and another Topic that imposes a rate limit.

Synopsis

Documentation

everyNew :: (HasHeader a, HasHeader b) => Topic IO a -> Topic IO b -> IO (Topic IO (a, b)) Source

Returns a Topic that produces a new pair for every value produced by either of the component Topics. The value of the other element of the pair will be the element from the other Topic with the nearest time stamp. The resulting Topic will produce a new value at the rate of the faster component Topic.

interpolate :: (HasHeader a, HasHeader b) => (a -> a -> Double -> a) -> Topic IO a -> Topic IO b -> Topic IO (a, b) Source

The application interpolate f t1 t2 produces a new Topic that pairs every element of t2 with an interpolation of two temporally bracketing values from t1. The interpolation is effected with the supplied function, f, that is given the two values to interpolate and the linear ratio to find between them. This ratio is determined by the time stamp of the intervening element of t2.

batch :: Double -> Topic IO a -> Topic IO [a] Source

Batch Topic values that arrive within the given time window (expressed in seconds). When a value arrives, the window opens and all values received within that window are returned in a list, then the next value is awaited before opening the window again. Intended usage is to gather approximately simultaneous events into batches. Note that the times used to batch messages are arrival times rather than time stamps. This is what lets us close the window, rather than having to admit any message that ever arrives with a compatible time stamp.