|
1 |
| -# Cassie_CFROST |
| 1 | +# Cassie Gait Library Optimization using C-FROST |
| 2 | + |
| 3 | +This repository contains an example using C-FROST to generate a library of walking gaits for Cassie series robot. The code depends on [FROST](https://github.com/ayonga/frost-dev) and [C-FROST](https://github.com/UMich-BipedLab/C-Frost). The Cassie model used in this example can be found [here](https://github.com/UMich-BipedLab/Cassie_Model). These dependant packages are also included as [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) for convenience. |
| 4 | + |
| 5 | +# Download # |
| 6 | + |
| 7 | +To download this example with submodules, run: |
| 8 | + |
| 9 | +``` shell |
| 10 | +cd ~ |
| 11 | +git clone --recursive [email protected]:UMich-BipedLab/Cassie_CFROST.git |
| 12 | +``` |
| 13 | + |
| 14 | +After download, you should set up [FROST](https://github.com/ayonga/frost-dev) and [C-FROST](https://github.com/UMich-BipedLab/C-Frost) accordingly. For more information, see |
| 15 | + * [FROST Installation](https://ayonga.github.io/frost-dev/pages/installation.html) |
| 16 | + * [C-FROST Installation](https://github.com/UMich-BipedLab/C-Frost/blob/master/INSTALLATION.md) |
| 17 | + |
| 18 | + |
| 19 | +# Generate necessary functions # |
| 20 | + |
| 21 | +To run the optimization using C-FROST, first needs to set up the problem in MATLAB using FROST and generate all required functions. In this example, we put functions for system dynamics into a separate directory, and compile them as a static library that can be linked to the main optimization problem. This way, you do not need to re-compile these functions every time after you change the optimization constraints. |
| 22 | + |
| 23 | +## Generate functions for system dynamics ## |
| 24 | + |
| 25 | +First, run [`gen_lib.m`](https://github.com/UMich-BipedLab/Cassie_CFROST/blob/master/Cassie_Example/cassie_dynamics_library/gen_lib.m) script in MATLAB. This process may take a while to finish. By default, we drop the velocity terms ($C(q)\dot{q}$) from the dynamics equation. To include them, set `OMIT_CORIOLIS` to `false` in `gen_lib.m` script, and re-run the script. After successfully run the script in matlab, you should find three new directories, `src`, `include`, and `mex`. |
| 26 | + |
| 27 | +In terminal, run the following to compile the static library: |
| 28 | +``` shell |
| 29 | +cd ~/Cassie_CFROST/Cassie_Example/cassie_dynamics-library |
| 30 | +mkdir build |
| 31 | +cd build |
| 32 | +cmake .. |
| 33 | +make -j4 |
| 34 | +make install |
| 35 | +``` |
| 36 | + |
| 37 | +The last command will move the compiled library `libcassie_dynamics.a` to the `lib` folder. |
| 38 | + |
| 39 | + |
| 40 | +## Generate other functions and optimization configuration files ## |
| 41 | + |
| 42 | +Next, run [`cassie_opt.m`](https://github.com/UMich-BipedLab/Cassie_CFROST/blob/master/Cassie_example/opt_two_step/cassie_opt.m) script in MATLAB to generate other functions and configuration files. This script should create two folders: |
| 43 | + |
| 44 | +* `gen`: export and compile MEX binaries used for FROST in MATLAB (you can run the optimization in MATLAB as before) |
| 45 | +* `periodic`: export all functions and configuration files required for C-FROST. |
| 46 | + |
| 47 | +For detailed process of generating these files, please refer to the comments in the script. |
| 48 | + |
| 49 | +## Compile C-FROST program ## |
| 50 | + |
| 51 | +In terminal |
| 52 | +```shell |
| 53 | +cd ~/Cassie_CFROST/Cassie_Example/opt_two_step/periodic/c_code |
| 54 | +mkdir build |
| 55 | +cd build |
| 56 | +cmake .. |
| 57 | +make -j4 |
| 58 | +make install |
| 59 | +cd .. |
| 60 | +``` |
| 61 | + |
| 62 | +This will compile the C-FROST optimization problem to an executable called `program` in the folder `periodic/c_code`. To run the program, run: |
| 63 | + |
| 64 | +```shell |
| 65 | +./program --initial 'res/init.json' --options '../ipopt.opt' --data 'res/data.json' --bounds 'res/bounds.json' --solution '../local/output/sol.json' |
| 66 | +``` |
| 67 | +The input arguments are: |
| 68 | +* --initial: the JSON file that stores the initial guess of the optimization |
| 69 | +* --options: the option file (with extension `.opt`) for IPOPT |
| 70 | +* --data: the JSON file that describe the problem structure |
| 71 | +* --bounds: the JSON file that stores boundary values of optimization variables and constraints |
| 72 | +* --solution: the output file to export the optimization results (structured data, more information) |
| 73 | +* --output: another output file to export the optimization results (just the vector of solution from IPOPT) |
| 74 | + |
| 75 | +C-FROST will export the optimization results to the specified JSON file. This can be easily imported to MATLAB to further analyze the optimal gait. A simple example of loading this file, see [`analyze_solution.m`](https://github.com/UMich-BipedLab/Cassie_CFROST/blob/master/Cassie_example/opt_two_step/analyze_solution.m). |
| 76 | + |
| 77 | +# Run multiple gait optimization # |
0 commit comments