The example contains just a simple command interpreter for setting, getting, and persisting variables. It is meant as a demo that could be extended with more commands and more complex functionality to use in for instance ROS2.
Uses a command lookup system (COMMANDS
dictionary) to map user input to the appropriate functions and execute them. The user interacts with the program through a basic REPL (Read-Eval-Print Loop) in the command_loop()
.
help
: Print information about commandsset <var_name> <value>
: Set a variable with a given name to a specific value.get <var_name>
: Retrieve and print the value of a variable.save <path>
: Save the current state of variables to a JSON file.load <path>
: Load the variables' state from a previously saved JSON file.
>> set x 10
>> get x
10
>> save example.json
>> set x 100
>> get x
100
>> load example.json
>> get x
10