ProcGraph core blocks¶
Package procgraph.components.debug_components¶
Components used for debugging and unit tests.
* | Product of two signals. |
+ | Sum of two signals. |
- | Implements the difference of two signals, taking care of overflows. |
/ | Ratio of two signals. |
constant | Output a numerical constant that never changes. |
gain | A simple example of a gain block. |
identity | This block outputs the inputs, unchanged. |
info | Prints more compact information about the inputs than Block print. |
Print a representation of the input values along with their timestamp. |
Package procgraph_cv¶
Blocks using the OpenCV library.
gradient | Computes the gradient of an image using a Sobel filter. |
smooth | Smooths an image with a Gaussian filter. |
Package procgraph_foo¶
An example package for ProcGraph that shows how to organize your code.
block_example | This is a documented example of the simplest block possible. |
Package procgraph_hdf¶
This is a set of blocks to read and write logs in HDF format.
hdfread | This block reads a log written with Block hdfwrite. |
hdfread_many | This block is a variation on Block hdfread that can concatenate the output of logs stored in multiple HDF files. |
hdfread_many_test | This is a simple test for Block hdfread_many. |
hdfread_test | This is a simple test that reading from HDF files is happening correctly. |
hdfwrite | This block writes the incoming signals to a file in HDF format. |
Package procgraph_images¶
Blocks for basic operations on images.
blend | Blend two or more images. |
border | Adds a block around the input image. |
compose | Compose several images in the same canvas. You should probably use Block grid in many situations. |
crop | Crops an image by the given values |
files_from_dir | This block reads the filenames from a directory according to a given regexp. |
gray2rgb | Converts a H x W grayscale into a H x W x 3 RGB image by replicating the gray channel over R,G,B. |
grid | A block that creates a larger image by arranging them in a grid. |
posneg | Converts a 2D float value to a RGB representation, where red is positive, blue is negative, white is zero. |
posterize | Posterizes the given image with the specified number of levels. |
reshape2d | Reshapes x into (?, width) if x is 1D. If width is not given, it is set to be the sqrt(size). |
rgb2gray | Converts a HxWx3 RGB image into a HxW grayscale image by computing the luminance. |
scale | Provides a RGB representation of the values by interpolating the range [min(value),max(value)] into the colorspace [min_color, max_color]. |
skim_top | Cuts off the top percentile of the array. |
skim_top_and_bottom | Cuts off the top and bottom percentile of the array. |
solid | to write |
Package procgraph_io_misc¶
Miscellaneous functions to be better organized.
as_json | Converts the input into a JSON string. |
pickle | Dumps the input as a pickle file. |
pickle_group | Dumps the input as a pickle file, in the form of a dictionary signal name -> value. |
pickle_load | Dumps the input as a pickle file. |
to_file | Prints the input line by line to a given file. |
Package procgraph_mpl¶
Blocks using Matplotlib to display data.
plot | Plots the inputs using matplotlib. |
Package procgraph_mplayer¶
Blocks for encoding/decoding video based on MPlayer.
mencoder | Encodes a video stream using mencoder. |
mplayer | Decodes a video stream. |
Package procgraph_numpy_ops¶
Various operations wrapping numpy functions.
abs | Wrapper around numpy.absolute. |
arctan | Wrapper around numpy.arctan. |
array | Converts the value to a Numpy array. |
astype | Converts an array using the astype function. |
deg2rad | Converts degrees to radians (wrapper around numpy.radians.) |
dstack | Wrapper around numpy.ma.dstack. |
fliplr | Flips the array left/right (wrapper for numpy.fliplr().) |
flipud | Flips the array up/down (wrapper for numpy.flipud().) |
gradient1d | Computes the gradient of a 1D array. |
hstack | Wrapper around numpy.ma.hstack. |
log | Wrapper around numpy.log. |
max | Maximum over all elements. |
maximum | Limits the numpy array to the given threshold. |
mean | Wrapper around numpy.mean. |
minimum | Limits the numpy array to the given threshold. |
norm | Returns the norm of the vector. |
normalize_Linf | Normalize a vector such that |x|_inf = max(abs(x))= 1. |
outer | Outer product of two vectors. |
rad2deg | Converts radians to degrees (wrapper around numpy.degrees.) |
real | Wrapper around numpy.real. |
select | Selects some of the elements of x. |
sign | Wrapper around numpy.sign. |
smooth1d | Smooth the data using a window with requested size. |
square | Wrapper around numpy.square. |
sum | Sum over all elements. |
take | to write |
vstack | Wrapper around numpy.ma.vstack. |
Package procgraph_pil¶
Blocks for image operations based on the PIL library
imread | Reads an image from a file. |
imwrite | Writes an image to a file. |
resize | Resizes an image. |
text | This block provides text overlays over an image. |
Package procgraph_robotics¶
Some functions specific to robotics applications.
laser_display | Produces a plot of a range-finder scan. |
laser_dot_display | Produces a plot of a range-finder scan variation (derivative). |
organic_scale | A (almost failed!) attempt to scale a signal into [-1,1] according to the history. |
pose2commands | Computes the velocity commands from the odometry data. |
pose2vel_ | Block used by Block pose2commands. |
skim | Cuts off the top and bottom percentile of the array. |
Package procgraph_ros¶
This is a set of blocks to read and write logs in ROS Bag format.
bagread | This block reads a bag file (ROS logging format). |
bagread_test | Test of the bagread block. |
bagwrite | This block writes the incoming signals to a ROS bag file. |
ros2python | Converts a ROS message to a Python object. |
ros_scan2python | to write |
Package procgraph_signals¶
Blocks performing operations with a dynamic nature.
any | Joins the stream of multiple signals onto one output signal. |
async | to write |
derivative | Computes the derivative of a quantity with 3 taps (x[t+1] - x[t-1]). See also Block derivative2. |
derivative2 | Computes the derivative of a quantity with 2 taps (x[t+1] - x[t]). See also Block derivative. |
extract | This block extracts some of the components of a vector. |
forward_difference | Computes x[t+1] - x[t-1] normalized with timestamp. |
fps_data_limit | This block limits the output update to a certain framerate. |
fps_limit | This block limits the output update to a certain realtime framerate. |
fps_print | Prints the fps count for the input signals. |
history | This block collects the history of a quantity, and outputs two signals x and t. See also Block historyt and Block last_n_samples. |
historyt | This block collects the signals samples of a signals, and outputs one signal containing a tuple (t,x). See also Block last_n_samples and Block history. |
join | This block joins multiple signals into one. |
last_n_samples | This block collects the last N samples of a signals, and outputs two signals x and t. See also Block historyt and Block history. |
low_pass | Implements simple low-pass filtering. |
make_tuple | Creates a tuple out of the input signals values. |
sieve | This block decimates the data in time by transmitting only one in n updates. |
slice | Slices a signal by extracting from index start to index end (INCLUSIVE). |
sync | This block synchronizes a set of streams to the first stream (the master). |
two_step_difference | Computes x[t+1] - x[t] normalized with timestamp. |
wait | This block waits a given number of updates before transmitting the output signal. |
Package procgraph_statistics¶
Blocks for common statistical operations.
cov2corr | Compute the correlation matrix from the covariance matrix. If zero_diagonal = True, the diagonal is set to 0 instead of 1. |
covariance | Computes the covariance matrix of the input. |
expectation | Computes the sample expectation of a signal. |
maximum_over_time | Computes the minimum of a signal over time. |
minimum_over_time | Computes the minimum of a signal over time. |
normalize | Removes the mean from a signal. |
soft_variance | Computes the element-wise “soft” variance (exp. of error abs. value) |
variance | Computes the element-wise variance. |
Package procgraph.components.debug_components¶
Components used for debugging and unit tests.
Block *¶
Product of two signals.
Input¶
- x: First signal.
- y: Second signal.
Output¶
- product: Product of the two signals.
Implemented in /src/procgraph/components/debug_components/operations.py.
Block +¶
Sum of two signals.
Input¶
- x: First signal.
- y: Second signal.
Output¶
- sum: Sum of the two signals.
Implemented in /src/procgraph/components/debug_components/operations.py.
Block -¶
Implements the difference of two signals, taking care of overflows.
Because that is rarely the semantics you want to give them.
Configuration¶
- safe (default: None): Whether to use safe promotions. If not specified, we will do it but warn once.
- cases (default: {‘uint16’: ‘int32’, ‘uint8’: ‘int16’, ‘uint32’: ‘int64’}): Promotion rules
Input¶
- x: First signal
- y: Second signal
Output¶
- x_minus_y: Result of x - y
Implemented in /src/procgraph/components/debug_components/operations.py.
Block /¶
Ratio of two signals.
Input¶
- x: First signal.
- y: Second signal.
Output¶
- ratio: First signal divided by the second.
Implemented in /src/procgraph/components/debug_components/operations.py.
Block constant¶
Output a numerical constant that never changes.
Example:
|constant value=42| -> ...
Configuration¶
- value: Constant value to output.
Output¶
- constant: The constant value.
Implemented in /src/procgraph/components/debug_components/constant.py.
Block gain¶
A simple example of a gain block.
Configuration¶
- k: Multiplicative gain
Input¶
- in: Input value
Output¶
- out: Output multiplied by k.
Implemented in /src/procgraph/components/debug_components/gain.py.
Block identity¶
This block outputs the inputs, unchanged.
Input¶
- Input signals. (variable number: n >= 1)
Output¶
- Output signals, equal to input. (variable number)
Implemented in /src/procgraph/components/debug_components/identity.py.
Block info¶
Prints more compact information about the inputs than Block print.
For numpy arrays it prints their shape and dtype instead of their values.
Input¶
- Signals to describe. (variable number: n >= 1)
Implemented in /src/procgraph/components/debug_components/info.py.
Block print¶
Print a representation of the input values along with their timestamp.
Input¶
- Signals to print. (variable number: n >= 1)
Implemented in /src/procgraph/components/debug_components/printc.py.
Package procgraph_cv¶
Blocks using the OpenCV library.
Block gradient¶
Computes the gradient of an image using a Sobel filter.
Configuration¶
- aperture_size (default: 3): Aperture of the Sobel filter (odd). (int,odd,>=1)
Input¶
- grayscale: A field to derive. (HxW array float)
Output¶
- gx: Gradient in the x direction. (array(HxW,float))
- gy: Gradient in the y direction. (array(HxW,float))
Implemented in /src/procgraph_cv/opencv_utils.py.
Block smooth¶
Smooths an image with a Gaussian filter.
Configuration¶
- gaussian_std (default: 5.0): Std-deviation of the Gaussian filter. (float,>0)
Input¶
- grayscale: A field to derive. (HxW array float)
Output¶
- smoothed: The smoothed image. (array(HxW,float))
Implemented in /src/procgraph_cv/opencv_utils.py.
Package procgraph_foo¶
An example package for ProcGraph that shows how to organize your code.
This is the documentation string for the package. Like all docstrings, it consists of a short summary (above) and a longer description (this.)
Block block_example¶
This is a documented example of the simplest block possible.
This docstring will be included in the generated documentation.
Configuration¶
- bias (default: 0): Bias for the accelerator.
Input¶
- baz: Measured baz in the particle accelerator.
Output¶
- baz_compensated: Compensated baz value according to calibration.
Implemented in /src/procgraph_foo/example0_simplest_block.py.
Package procgraph_hdf¶
This is a set of blocks to read and write logs in HDF format.
You need the pytables package to be installed.
Block hdfread¶
This block reads a log written with Block hdfwrite.
Configuration¶
- file: HDF file to read
- signals (default: None): Which signals to output (and in what order). Should be a comma-separated list. If you do not specify it will be all signals (TODO: in the original order).
- quiet (default: False): If true, disables advancements status messages.
Output¶
- The signals read from the log. (signals are defined at runtime)
Implemented in /src/procgraph_hdf/hdfread.py.
Block hdfread_many¶
This block is a variation on Block hdfread that can concatenate the output of logs stored in multiple HDF files.
The files are specified using a wildcard: for example, dir/*.h5.
A difference with Block hdfread is that all signals must be specified explicitly (Block hdfread can guess); the reason is that we want to avoid reading unrelated logs with different signals.
We check that all files specified have all required signals.
The logfiles are read in the order compatible with their timestamp.
Configuration¶
- files: HDF files to read; you can use the wildcard *.
- signals: Which signals to output (and in what order). Should be a comma-separated list.
- quiet (default: False): If true, disables advancements status messages.
Output¶
- The signals read from the logs. (signals are defined at runtime)
Implemented in /src/procgraph_hdf/hdfread_many.py.
Block hdfread_many_test¶
This is a simple test for Block hdfread_many.
Configuration¶
- files: File pattern
- signals: to write
Implemented in /src/procgraph_hdf/models/hdfread_many_test.pg.
Block hdfread_test¶
This is a simple test that reading from HDF files is happening correctly.
Block hdfwrite¶
This block writes the incoming signals to a file in HDF format.
The HDF format is organized as follows:
/ (root)
/procgraph (group with name procgraph)
/procgraph/signal1 (table)
/procgraph/signal2 (table)
...
Each table has the following fields:
time (float64 timestamp) value (the datatype of the signal)
If a signal changes datatype, then an error is thrown.
Configuration¶
- file: HDF file to write
- compress (default: 1): Whether to compress the hdf table.
- complib (default: zlib): Compression library (zlib, bzip2, blosc, lzo).
- complevel (default: 9): Compression level (0-9)
Input¶
- Signals to be written (variable number: n >= 1)
Implemented in /src/procgraph_hdf/hdfwrite.py.
Package procgraph_images¶
Blocks for basic operations on images.
This package contains blocks that perform basic operations on images. The library has no software dependency.
For more complex operations see also Package procgraph_cv and Package procgraph_pil
Example
Convert a RGB image to grayscale, and back to a RGB image::
|input| -> |rgb2gray| -> |gray2rgb| -> |output|
Block blend¶
Blend two or more images.
RGB images are interpreted as having full alpha (opaque). All images must have the same width and height.
Input¶
- images to blend (variable number: n >= 2)
Block border¶
Adds a block around the input image.
Configuration¶
- color (default: [0, 0, 0]): border color (0-1 rgb)
- left (default: 0): pixel length for left border
- right (default: 0): pixel length for right border
- top (default: 0): pixel length for top border
- bottom (default: 0): pixel length for bottom border
Input¶
- rgb: Input image.
Block compose¶
Compose several images in the same canvas. You should probably use Block grid in many situations.
Example configuration:
compose.positions = {y: [0,0], ys: [320,20]}
Configuration¶
- width: Dimension in pixels.
- height: Dimension in pixels.
- positions: A structure giving the position of each signal in the canvas.
Input¶
- Images to compose. (variable number)
Block crop¶
Crops an image by the given values
Configuration¶
- top (default: 0): to write
- right (default: 0): to write
- left (default: 0): to write
- bottom (default: 0): to write
Input¶
- rgb: to write
Block files_from_dir¶
This block reads the filenames from a directory according to a given regexp.
For now the timestamp starts from 0 and it is fixed.
Configuration¶
- dir: Directory containing the image files.
- regexp (default: (w+)_(d+).jpg): Regular expression for images.
- fps (default: 20.0): Fixed frame per second.
Block gray2rgb¶
Converts a H x W grayscale into a H x W x 3 RGB image by replicating the gray channel over R,G,B.
Input¶
- gray: grayscale (array(HxW,uint8),H>0,W>0)
Output¶
- 0: A RGB image in shades of gray. (array(HxWx3,uint8))
Implemented in /src/procgraph_images/filters.py.
Block grid¶
A block that creates a larger image by arranging them in a grid.
Configuration¶
- cols (default: None): Columns in the grid.
- bgcolor (default: [0, 0, 0]): Background color.
Input¶
- Images to arrange in a grid. (variable number: n >= 1)
Block posneg¶
Converts a 2D float value to a RGB representation, where red is positive, blue is negative, white is zero.
Configuration¶
- max_value (default: None): Maximum of absolute value (if None, detect). (float,>0)
- nan_color (default: [0.5, 0.5, 0.5]): Color to give for regions of NaN and Inf. (color)
- skim (default: 0): Fraction to skim (in percent). (float,>0,<100)
Input¶
- value: The field to represent. (array[HxW])
Output¶
- posneg: A RGB image. (array[HxWx3](uint8))
Implemented in /src/procgraph_images/copied_from_reprep.py.
Block posterize¶
Posterizes the given image with the specified number of levels.
Configuration¶
- levels (default: 2): number of levels (int,>=2)
Input¶
- rgb: RGB image (array(HxWx3,uint8),H>0,W>0)
Output¶
- 0: A RGB image with the specified number of levels. (array(HxWx3,uint8))
Implemented in /src/procgraph_images/posterize.py.
Block reshape2d¶
Reshapes x into (?, width) if x is 1D. If width is not given, it is set to be the sqrt(size).
If x is 2D, it is left alone.
Configuration¶
- width (default: None): to write
- fill_value (default: nan): to write
- height (default: None): to write
Input¶
- x: to write
Block rgb2gray¶
Converts a HxWx3 RGB image into a HxW grayscale image by computing the luminance.
Input¶
- rgb: RGB image (array(HxWx3,uint8),H>0,W>0)
Output¶
- 0: A RGB image in shades of gray. (array(HxW,uint8))
Implemented in /src/procgraph_images/filters.py.
Block scale¶
Provides a RGB representation of the values by interpolating the range [min(value),max(value)] into the colorspace [min_color, max_color].
Configuration¶
- max_value (default: None): If specified, everything above is clipped. (float)
- nan_color (default: [1, 0, 0]): Color to give for regions of NaN and Inf. (color)
- min_value (default: None): If specified, everything below is clipped. (float)
- min_color (default: [1, 1, 1]): Color to give to the minimum values. (color)
- max_color (default: [0, 0, 0]): Color to give to the maximum values. (color)
Input¶
- value: The field to represent. (array[HxW],H>0,W>0)
Output¶
- scale: A RGB image. (array[HxWx3](uint8))
Implemented in /src/procgraph_images/copied_from_reprep.py.
Block skim_top¶
Cuts off the top percentile of the array.
Configuration¶
- top_percent: How much to cut off (decimal). (float,>=0,<90)
Input¶
- a: to write
Block skim_top_and_bottom¶
Cuts off the top and bottom percentile of the array.
Configuration¶
- percent: How much to cut off (decimal). (float,>=0,<90)
Input¶
- a: Any numpy array. (array[x])
Output¶
- 0: Skimmed version of a. (array[x])
Implemented in /src/procgraph_images/copied_from_reprep.py.
Package procgraph_io_misc¶
Miscellaneous functions to be better organized.
Block as_json¶
Converts the input into a JSON string.
TODO: add example
Input¶
- Inputs to transcribe as JSON. (variable number)
Block pickle_group¶
Dumps the input as a pickle file, in the form of a dictionary signal name -> value.
Configuration¶
- file: File to write to.
Input¶
- Any number of pickable signals. (variable number)
Implemented in /src/procgraph_io_misc/pickling.py.
Block to_file¶
Prints the input line by line to a given file.
Configuration¶
- file: File to write.
Input¶
- values: Anything you wish to print to file.
Implemented in /src/procgraph_io_misc/to_file.py.
Package procgraph_mpl¶
Blocks using Matplotlib to display data.
Block plot¶
Plots the inputs using matplotlib.
This block accepts an arbitrary number of signals. Each signals is treated independently and plot separately.
Each signal can either be:
- A tuple of length 2. It is interpreted as a tuple (x,y), and we plot x versus y (see also Block make_tuple).
- A list of numbers, or a 1-dimensional numpy array of length N. In this case, it is interpreted as the y values, and we set x = 1:N.
Configuration¶
- width (default: 320): Image dimension
- height (default: 240): Image dimension
- xlabel (default: None): X label for the plot.
- ylabel (default: None): Y label for the plot.
- legend (default: None): List of strings to use as legend handles.
- title (default: None): If None, use the signal name. Set to "" to disable.
- format (default: -): Line format (“-”,”.”,”x-”,etc.)
- symmetric (default: False): An alternative to y_min, y_max. Makes sure the plot is symmetric for y.
- x_min (default: None): If set, force the X axis to have this minimum.
- x_max (default: None): If set, force the X axis to have this maximum.
- y_min (default: None): If set, force the Y axis to have this minimum.
- y_max (default: None): If set, force the Y axis to have this maximum.
- keep (default: False): If True, tries to reuse the figure, without closing. (buggy on some backends)
- transparent (default: False): If true, outputs a RGBA image instead of RGB.
- tight (default: False): Uses “tight” option for creating png.
- fancy_styles (default: []): A list of fancy styles to apply ([‘notopaxis’, ‘dickinsonA’, ‘noxticks’, ‘noyticks’, ‘nobottomaxis’]).
Input¶
- Data to plot. (variable number)
Package procgraph_mplayer¶
Blocks for encoding/decoding video based on MPlayer.
Block mencoder¶
Encodes a video stream using mencoder.
Note that allowed codec and bitrate depend on your version of mencoder.
MP4 output: currently it works by creating a .AVI with mencoder and then converting to MP4 using ffmpeg (MP4 support for mencoder is currently — Feb‘12 — broken).
RGBA videos: not working fully. For now it outputs .AVI with mencoder and encoded using png.
Configuration¶
- file: Output file (AVI/MP4 format)
- fps (default: None): Framerate of resulting movie. If not specified, it will be guessed from data.
- fps_safe (default: 10): If the frame autodetect gives strange results, we use this safe value instead.
- vcodec (default: mpeg4): Codec to use.
- vbitrate (default: 2000000): Bitrate – default is reasonable.
- quiet (default: True): If True, suppress mencoder’s messages
- timestamps (default: True): If True, also writes <file>.timestamps that includes a line with the timestamp for each frame
- crop (default: False): If true, the video will be post-processed and cropped
Input¶
- image: Either a HxWx3 uint8 numpy array representing an RGB image, or a HxW representing grayscale.
Implemented in /src/procgraph_mplayer/mencoder.py.
Package procgraph_numpy_ops¶
Various operations wrapping numpy functions.
Block astype¶
Converts an array using the astype function.
Configuration¶
- dtype: The new dtype. (string)
Input¶
- a: Numpy array (array)
Output¶
- typed: The Numpy array with the new type. (array)
Implemented in /src/procgraph_numpy_ops/filters.py.
Block gradient1d¶
Computes the gradient of a 1D array.
Input¶
- a: Numpy array (array(N),N>3)
Output¶
- typed: The gradient of the array. (array)
Implemented in /src/procgraph_numpy_ops/gradient1d.py.
Block maximum¶
Limits the numpy array to the given threshold.
Configuration¶
- threshold: to write
Input¶
- value: to write
Block mean¶
Wrapper around numpy.mean.
Configuration¶
- dtype (default: None): to write
- axis (default: None): to write
- out (default: None): to write
Input¶
- a: to write
Block minimum¶
Limits the numpy array to the given threshold.
Configuration¶
- threshold: to write
Input¶
- value: Any numpy array.
Block norm¶
Returns the norm of the vector.
Configuration¶
- ord (default: 2): to write
Input¶
- value: to write
Block normalize_Linf¶
Normalize a vector such that |x|_inf = max(abs(x))= 1.
Input¶
- x: Any numpy array.
Block outer¶
Outer product of two vectors.
This is a wrapper around numpy.multiply.outer().
Input¶
- a: First vector.
- b: Second vector.
Output¶
- outer: Outer product of the two vectors.
Implemented in /src/procgraph_numpy_ops/filters.py.
Block select¶
Selects some of the elements of x.
Configuration¶
- every: How many to jump (every=2 takes only the even elements).
Input¶
- x: Numpy array that can be flatly addressed.
Block smooth1d¶
Smooth the data using a window with requested size.
This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the begining and end part of the output signal.
window must be one of ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’. A flat window will produce a moving average smoothing.
example:
t=linspace(-2,2,0.1)
x=sin(t)+randn(len(t))*0.1
y=smooth(x)
see also:
numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve scipy.signal.lfilter
- TODO: the window parameter could be the window itself if an
- array instead of a string
Configuration¶
- window_len (default: 11): the dimension of the smoothing window; an odd integer
- window (default: hanning): the type of window from
Input¶
- x: the input signal
Block take¶
to write
Configuration¶
- indices: to write
- axis (default: 0): to write
Input¶
- a: to write
Package procgraph_pil¶
Blocks for image operations based on the PIL library
Block resize¶
Resizes an image.
You should pass at least one of width or height.
Configuration¶
- width (default: None): Target image width. (int,>0)
- height (default: None): Target image height. (int,>0)
Input¶
- value: The image to resize. (image)
Output¶
- image: The image as a numpy array. (rgb)
Implemented in /src/procgraph_pil/pil_operations.py.
Block text¶
This block provides text overlays over an image.
This block is very powerful, but the configuration is a bit complicated.
You should provide a list of dictionary in the configuration variable texts. Each dictionary in the list describes how and where to write one piece of text.
An example of valid configuration is the following:
text.texts = [{string: "raw image", position: [10,30], halign: left,
color: black, bg: white }]
The meaning of the fields is as follow:
- string
- Text to display. See the section below about keyword expansion.
- position
- Array of two integers giving the position of the text in the image
- color
- Text color. It can be a keyword color or an hexadecimal string (white or #ffffff).
- bg
- background color
- halign
- Horizontal alignment. Choose between left (default), center, right.
- valign
- Vertical alignment. Choose between top (default), middle, center.
- size
- Font size in pixels
- font
- Font family. Must be a ttf file (Arial.ttf)
Expansion: Also we expand macros in the text using format(). The available keywords are:
- frame
- number of frames since the beginning
- time
- seconds since the beginning of the log
- timestamp
- absolute timestamp
Configuration¶
- texts: Text specification (see block description).
Input¶
- rgb: Input image.
Package procgraph_robotics¶
Some functions specific to robotics applications.
Requires: http://github.com/AndreaCensi/geometry
Block laser_display¶
Produces a plot of a range-finder scan.
Example of configuration:
display_sick.groups = [{ indices: [0,179], theta: [-1.57,+1.57],
color: 'r', origin: [0,0,0]}]
Configuration¶
- width (default: 320): Width of the resulting image.
- height (default: 320): Height of the resulting image.
- max_readings (default: 30): Readings are clipped at this threshold (m).
- groups: How to group and draw the readings. (see example)
- title (default: None): By default it displays the signal name. Set the empty string to disable.
- transparent (default: False): Gives transparent RGBA rather than RGB.
Input¶
- readings: The laser readings (array of floats).
Output¶
- image: The laser visualization (rgba).
Implemented in /src/procgraph_robotics/laser_display.py.
Block laser_dot_display¶
Produces a plot of a range-finder scan variation (derivative).
It is a variation of Block laser_display; look there for the documentation.
Configuration¶
- width (default: 320): Width of the resulting image.
- height (default: 320): Height of the resulting image.
- groups: How to group and draw the readings. (see Block laser_display)
- title (default: None): By default it displays the signal name. Set the empty string to disable.
- transparent (default: False): Gives transparent RGBA rather than RGB.
- R0 (default: 1): Radius of the readings circle.
- amp (default: 0.5): Amplitude of the readings crown.
Input¶
- readings_dot: Array of float representing array readings.
Output¶
- image: A fancy visualization of the laser derivative
Implemented in /src/procgraph_robotics/laser_dot_display.py.
Block organic_scale¶
A (almost failed!) attempt to scale a signal into [-1,1] according to the history.
This one is a mess.
Configuration¶
- skim (default: 5): to write
- skim_hist (default: 5): to write
- hist (default: 100): How many steps of history to use.
- tau (default: 0.1): to write
Input¶
- value: to write
Block pose2commands¶
Computes the velocity commands from the odometry data.
Input¶
- pose: Odometry as an array [x,y,theta].
Output¶
- commands: Estimated commands as an array [vx,vy,omega].
- vx: Linear velocity, forward (m/s)
- vy: Linear velocity, side (m/s)
- omega: Angular velocity (rad/s)
Implemented in /src/procgraph_robotics/pose2velocity.py.
Block pose2vel_¶
Block used by Block pose2commands.
Input¶
- q12: Last two poses.
- t12: Last two timestamps.
Output¶
- commands: Estimated commands [vx,vy,omega].
Implemented in /src/procgraph_robotics/pose2velocity.py.
Package procgraph_ros¶
This is a set of blocks to read and write logs in ROS Bag format.
You need the rospy package to be installed.
Block bagread¶
This block reads a bag file (ROS logging format).
Configuration¶
- file: Bag file to read
- topics (default: None): Which signals to output (and in what order). Should be a comma-separated list. If you do not specify it (or if empty) it will be all signals.
Output¶
- The signals read from the log. (signals are defined at runtime)
Implemented in /src/procgraph_ros/bagread.py.
Block bagread_test¶
Test of the bagread block.
Configuration¶
- file: .bag file to read
- topics: topics to read
Implemented in /src/procgraph_ros/models/bagread_test.pg.
Block bagwrite¶
This block writes the incoming signals to a ROS bag file.
By default, the signals are organized as follows:
/ (root)
/procgraph (group with name procgraph)
/procgraph/signal1 (table)
/procgraph/signal2 (table)
...
Note that the input should be ROS messages; no conversion is done.
Configuration¶
- file: Bag file to write
Input¶
- Signals to be written (variable number: n >= 1)
Implemented in /src/procgraph_ros/bagwrite.py.
Package procgraph_signals¶
Blocks performing operations with a dynamic nature.
This library contains blocks that perform operations with time.
Block any¶
Joins the stream of multiple signals onto one output signal.
Input¶
- Signals to be put on the same stream. (variable number: n >= 1)
Block async¶
to write
Input¶
- Signals to (a)synchronize. The first is the master. (variable number: n >= 2)
Block derivative¶
Computes the derivative of a quantity with 3 taps (x[t+1] - x[t-1]). See also Block derivative2.
Input¶
- x: quantity to derive
Block derivative2¶
Computes the derivative of a quantity with 2 taps (x[t+1] - x[t]). See also Block derivative.
Input¶
- x: quantity to derive
Block extract¶
This block extracts some of the components of a vector.
Example: Extracts the first and third component of x.
x -> |extract index=[0,2]| -> x_part
Configuration¶
- index: Index (or indices) to extract.
Input¶
- vector: Any numpy array
Block forward_difference¶
Computes x[t+1] - x[t-1] normalized with timestamp.
You want to attach this to Block last_n_samples.
Input¶
- x123: An array with the last 3 values of x.
- t123: An array with the last 3 values of the timestamp.
Block fps_data_limit¶
This block limits the output update to a certain framerate.
Configuration¶
- fps: Maximum framerate.
Input¶
- Signals to decimate. (variable number: n >= 1)
Output¶
- Decimated signals. (variable number)
Implemented in /src/procgraph_signals/fps_data_limit.py.
Block fps_limit¶
This block limits the output update to a certain realtime framerate.
Note that this uses realtime wall clock time – not the data time! This is mean for real-time applications, such as visualization.
Configuration¶
- fps: Realtime fps limit.
Input¶
- Arbitrary signals. (variable number)
Output¶
- Arbitrary signals with limited framerate. (variable number)
Implemented in /src/procgraph_signals/fps_limit.py.
Block fps_print¶
Prints the fps count for the input signals.
Block history¶
This block collects the history of a quantity, and outputs two signals x and t. See also Block historyt and Block last_n_samples.
Configuration¶
- interval (default: 10): Length of the interval to record.
Input¶
- values: Any signal.
Output¶
- x: Sequence of values.
- t: Sequence of timestamps.
Implemented in /src/procgraph_signals/history.py.
Block historyt¶
This block collects the signals samples of a signals, and outputs one signal containing a tuple (t,x). See also Block last_n_samples and Block history.
If natural is true, it uses the time from the beginning of the log.
Configuration¶
- interval (default: 10): Length of interval (seconds).
- natural (default: True): If true, set 0 to be timestamp of the log beginning. This allows to have prettier graphs
Input¶
- x: Any signal.
Output¶
- history: Tuple (t,x) containing two arrays.
Implemented in /src/procgraph_signals/historyt.py.
Block join¶
This block joins multiple signals into one.
Input¶
- Signals to be joined together. (variable number)
Block last_n_samples¶
This block collects the last N samples of a signals, and outputs two signals x and t. See also Block historyt and Block history.
Configuration¶
- n: Number of samples to retain.
Input¶
- x: Any data
Output¶
- x: Sequence of values.
- t: Sequence of timestamps.
Implemented in /src/procgraph_signals/last_n_samples.py.
Block low_pass¶
Implements simple low-pass filtering.
Formula used:
y[k] = alpha * u[k] + (1-alpha) * y[k-1]
Configuration¶
- alpha: Innovation rate
Input¶
- value: Any numpy array.
Block make_tuple¶
Creates a tuple out of the input signals values.
Often used for plotting two signals as (x,y); see Block plot.
Input¶
- Signals to unite in a tuple. (variable number)
Block sieve¶
This block decimates the data in time by transmitting only one in n updates.
Configuration¶
- n: Decimation level; n = 3 means transmit one in three.
Input¶
- data: Arbitrary input signals.
Block slice¶
Slices a signal by extracting from index start to index end (INCLUSIVE).
Configuration¶
- start: Slice start.
- end: Slice end (inclusive).
Input¶
- signal: Any 1d numpy array
Block sync¶
This block synchronizes a set of streams to the first stream (the master).
The first signal is called the “master” signal. The other (N-1) are slaves.
We guarantee that:
- if the slaves are faster than the master, then we output exactly the same.
Example diagrams:
Master * * * * *
Slave ++++++++++++++++
Master * * * * *
output? v v x v
Slave + + +
output? v v v
Input¶
- Signals to synchronize. The first is the master. (variable number: n >= 2)
Block two_step_difference¶
Computes x[t+1] - x[t] normalized with timestamp.
Input¶
- x12: An array with the last 2 values of x.
- t12: An array with the last 2 values of the timestamp.
Block wait¶
This block waits a given number of updates before transmitting the output signal.
Configuration¶
- n: Number of updates to wait at the beginning.
Input¶
- Arbitrary signals. (variable number)
Output¶
- Copy of the signals, minus the first n updates. (variable number)
Implemented in /src/procgraph_signals/wait.py.
Package procgraph_statistics¶
Blocks for common statistical operations.
Block cov2corr¶
Compute the correlation matrix from the covariance matrix. If zero_diagonal = True, the diagonal is set to 0 instead of 1.
Configuration¶
- zero_diagonal (default: True): Whether to set the (noninformative) diagonal to zero.
Input¶
- covariance: A 2D numpy array.
Output¶
- correlation: The exctracted correlation.
Implemented in /src/procgraph_statistics/cov2corr.py.
Block covariance¶
Computes the covariance matrix of the input.
Configuration¶
- wait (default: 10): Number of sample to have reliable expectation.
Input¶
- x: Unidimensional numpy array.
Output¶
- cov_x: Square matrix representing sample covariance.
Implemented in /src/procgraph_statistics/covariance.py.
Block normalize¶
Removes the mean from a signal.
Configuration¶
- wait (default: 10): Number of sample to have reliable expectation.
Input¶
- x: Unidimensional numpy array.
Block soft_variance¶
Computes the element-wise “soft” variance (exp. of error abs. value)
Configuration¶
- wait (default: 100): Number of samples to wait before declaring the value valid.
Input¶
- x: Any numpy array