Moteus performance analysis tool - CLI mode
I’ve previously written about the moteus performance analysis tool and how it can be used to evaluate different motor control systems for performance purposes. The tool described there is entirely a web based application that requires clicking around in the HTML interface in order to configure an analysis.
Now, there is newly added feature in the main moteus git repository that provides a command line interface (CLI) to the analysis kernel! This capability lets you run sweeps through various parameters or motor configurations much more easily than before, or even wrap the analysis in an optimization loop without resorting to browser based automation techniques.
Usage
With a clean checkout, you can run a single analysis using a command like the following:
$ ./utils/mpat.py --analysis max_torque --controller moteus-x1 \
--motor mj5208 --voltage 36 --velocity 10 --json
The resulting output will look like:
{
"torque": 0.3438918397726916,
"velocity": 10,
"controller_temp": 64.90160585766452,
"motor_temp": 79.99534823101246,
"supply_power": 38.62037545024755,
"supply_current": 1.0727882069513208,
"phase_current": 12.595556541072078,
"d_current": 0,
"q_current": 12.595556541072078,
"copper_loss": 11.184687142843725,
"iron_loss": 0.9022025782579168,
"controller_loss": 4.926124179958583,
"fan_power": 0,
"mechanical_power": 21.607361549187324,
"efficiency": 55.948087757517705,
"time": null,
"peak_supply_power": null,
"peak_velocity": null
}
The --json flag emits the entire operating point for the requested analysis. Without it, the --output flag flag can be used to select which field will be emitted:
$ ./utils/mpat.py --analysis max_torque --controller moteus-x1 \
--motor mj5208 --voltage 36 --velocity 10 --output torque
0.34 Nm
Implementation
The mpat CLI tool operates in two phases. The python wrapper first executes a script that extracts the core analysis portion out of mpat.html, then second links it with a minimal javascript CLI harness. This means that mpat.html is still self contained and only requires a single file to operate with no build step required, but the CLI tool also still uses the most recent version as present in the working tree. It is perhaps a bit convoluted, but it is an homage to my desire to both have the web version be the canonical version and have the web version require only a single file to operate.
Requirements
A working node installation is required, on Ubuntu you can get a usable one with:
sudo apt install nodejs
The version in Ubuntu is not particularly new, but mpat does not require any dependencies and not much from node, so basically any version will work.