This project allows provenance tracking for generic objects and their attribute structure by implementing a generic wrapper type. It targets use cases for Robot Operating System (ROS), however it can also work standalone. More information about this project and library can be found in my Bachelor’s Thesis.
- Wrapper for Tracking Generic Objects
- Support Nested Attributes and Classes
- Provenance Tree Generation
- Tree Inversion and Evaluation
- Operator Chaining
- Data Serialization
- Source Location Tracking
- Node Monitoring for Wrapped Messages
You can calculate the required input value for a given output value of some pure functions of which the order of the operations does not depend on the input value.
# simple example function
def blackbox_simple(x):
return (x + 7) / 2
# complex example function of unknown behavior
def blackbox_complex(x):
from random import Random
rng = Random(1337)
while rng.random() < 0.9:
choice = rng.randint(0, 8)
val = rng.random() * 10
if choice == 0:
x = x + val
elif choice == 1:
x = x - val
elif choice == 2:
x = x * (val + 1)
elif choice == 3:
x = x / (val + 1)
elif choice == 4:
x += val
elif choice == 5:
x -= val
elif choice == 6:
x *= (val + 1)
elif choice == 7:
x /= (val + 1)
elif choice == 8:
x = x ** 0.75
return x
# load rosslt library
from rosslt import Tracked
# reversing simple blackbox
param = blackbox_simple(Tracked(0.0)).get_expression().reverse()(42.0)
print(f"blackbox_simple({param}) = {blackbox_simple(param)}")
# reversing complex blackbox
param = blackbox_complex(Tracked(0.0)).get_expression().reverse()(42.0)
print(f"blackbox_complex({param}) = {blackbox_complex(param)}")
# output:
# blackbox_simple(77.0) = 42.0
# blackbox_complex(13.231650832969262) = 42.0
We calculated the result by taking track of the operations in a provenance tree, reversed the expression and evaluated the reversed expression using the target value. The result is the parameter value that leads to the target value.