Behavior Control
This control is developed by:
AvatarDJ Sures
Created
Updated
Help Index

Filters

How To Download and Use This Control

  1. Make sure you have the latest version of EZ-Builder installed.
  2. Select Download This Control button below to download the file.
  3. Double click the downloaded file to open it.
  4. The installer will automatically add this control to EZ-Builder.
Download This Control

This plugin will register new EZ-Script commands that can be used to dampen and filter values. For instance, if you are receiving data from a sensor to move servos, these filters will smooth the output to prevent the servo from being jerky.

There are currently two filters that can be used. In order to allow multiple instances of each filter, the commands have an ID. This means you can have multiple instances of the same filter and each instance can have an unique ID.

User-inserted image


Mean Filter Examples
Here is a short code that demonstrates the output of the mean filter if the values went from 100 to 1.

Code:



# Initialize the filter with ID "test" and a dampen size of 4
MeanFilterInit("test", 4)

# Add the first value, which will be 100
print(MeanFilterAdd("test", 100))

# Add a bunch of 1's and print the output so you can see what the dampening looks like
print(MeanFilterAdd("test", 1))
print(MeanFilterAdd("test", 1))
print(MeanFilterAdd("test", 1))
print(MeanFilterAdd("test", 1))
print(MeanFilterAdd("test", 1))
print(MeanFilterAdd("test", 1))


Output:
User-inserted image


Complimentary Filter
This code demonstrates the complimentary filter with an ID of "banana" and a dampen of 50%

Code:


# Init the filter with a dampening percentage of 50%
ComplimentaryFilterInit("banana", 50)

# The first value we will add is 100
print( ComplimentaryFilterAdd("banana", 100))

# Add and print a bunch of 1's so you can see how the dampening works
print( ComplimentaryFilterAdd("banana", 1))
print( ComplimentaryFilterAdd("banana", 1))
print( ComplimentaryFilterAdd("banana", 1))
print( ComplimentaryFilterAdd("banana", 1))
print( ComplimentaryFilterAdd("banana", 1))
print( ComplimentaryFilterAdd("banana", 1))
print( ComplimentaryFilterAdd("banana", 1))
print( ComplimentaryFilterAdd("banana", 1))
print( ComplimentaryFilterAdd("banana", 1))


Output:
User-inserted image