einarhaaland / robot-caretaker

Remote emotion control for heterogeneous robots
1 stars 1 forks source link

Make robot.run() completely generic #33

Closed einarhaaland closed 2 years ago

einarhaaland commented 2 years ago

simplest but perhaps worst way is just eval(instruction+"()"), check if python cleans input

maybe match instruction to closest matching function. add getMotions()...

einarhaaland commented 2 years ago

In case I want to use eval:

def eval_expression(input_string):
    code = compile(input_string, "<string>", "eval")
    if code.co_names:
        raise NameError(f"Use of names not allowed")
    return eval(code, {"__builtins__": {}}, {})