GaitBuilder Tutorial ==================== **Author**: Clark Haynes **Date**: December 3, 2004 *This document is coded in Markdown syntax, and can be converted into a webpage using the Perl script available at * GaitBuilder is a collection of Matlab scripts that facilitate the generation of custom gait RC files to be used with the RiSE control software. Gaits in RiSE consist of periodic piecewise linear profiles for the crank (in beta coordinates) and wing degrees of freedom for each leg. This tutorial walks through the development of a RiSE gait using the GaitBuilder tools, from beginning to end. How To Get Started ------------------ GaitBuilder is located within the RiSE tree, and it can be added to your Matlab path with the command: addpath([getenv('RISE_TOPDIR') 'Tools/Matlab/GaitBuilder']) The individual functions are well document, so you can simply type `help GBfunction` to retrieve help and use intructions. Making Gait Sections ------------------------------- The first concept to learn is the difference between absolute and relative positions. The function `GBsection` is the basic building function for piecing-together gaits, but you must know when to use absolute and relative positions. Consider the two commands: GBsection([t,c,w]', 1) GBsection([t,c,w]') The first argument is a column vector, with individual positions in time, crank, and wing, in that order. The second argument states whether the positions are absolute or relative. In the first example, the `1` states that the positions are absolute, meaning that the leg, at time t, will be positioned at (c,w) in crank/wing coordinates. In the next line, the second argument is ommitted and defaults to 0, thus it is a relative position. In this example, the leg should move by (c,w) distances over time t. Piecing-Together Gaits ----------------------- `GBsection` returns a special struct which must be stored in memory. To piece a gait together, you simply concatenate them together using `GBconcat`: s1 = GBsection([t1,c1,w1]') s2 = GBsection([t2,c2,w2]') s12 = GBconcat(s1,s2) While `s1` and `s2` are each single-node sections of a gait, `s12` is a two node section. To make things even easier, you can continue to concatenate sections that have already been concatenated: s3 = GBsection[t3,c3,w3]') s13 = GBconcat(s12,s3); You should continue to add sections, both absolute and relative, and concatenate them together, until you have a full profile for a gait. Compiling Profiles ------------------ After you have a fully concatenated list of gait sections, you call `GBcompile` to convert them into a single gait profile, to be used with CustomGait. This function does the work of converting all positions to absolute positions and dealing with wrap-around in both leg positions and in time. `GBcompile` autocomputes the period of the profile as the total time of all sections in the gait. To compile a list of sections into a profile, call: profile = GBcompile(s); You can optionally provide a name for the leg profile as a second argument, and it will end up in the outputted .rc file. Spaces are not allows within profile names. profile = GBcompile(s,"front_right_leg"); Writing Profiles to File ------------------------ Once you have a complete set of profiles for all six legs, you output them to a .rc file to be read in by the RiSE control software. Assuming that you have six different profiles, they can be assigned to legs 1 through 6 (in that order) by calling: GBexport('new_gait.rc', 'New Gait', ... p1, p2, p3, p4, p5, p6); The first string is the name of the outputted file. The second is the name of the gait, as will be displayed on the RiSE GUI when used. The next six parameters are the profiles for each leg. You can repeat profiles in the argument list if needed, and you can also provide less than six profiles, in which case they will be repeated until profiles are defined for all legs. For instance, to write a tripod-like gait, in which legs 1,3,5 and legs 2,4,6 act as a group, you would execute: GBexport('new_gait.rc', 'New Gait', ... p1, p2); Turning Profiles ---------------- When you write a gait out to a file, you must also include turning profiles which are used when the operator tries to steer the robot. There are many different ways to feasibly turn the RiSE robot, but one method which worked well in early tests was to vary only the duty factor of the legs while in stance. You can slightly modify your leg sections, generate new profiles, then supply up to six profiles each to successive calls of `GBexportturn`. GBexportturn('new_gait.rc', 'left', ... lp1, lp2, lp3, lp4, lp5, lp6); GBexportturn('new_gait.rc', 'right', ... rp1, rp2, rp3, rp4, rp5, rp6); You must precede these calls by a call to `GBexport`, as they append to an already created file, whereas `GBexport` starts a new file. Profiles will be repeated as shown previously. Full Example ------------ Advanced Concepts ----------------- **Sections with both relative and absolute positions**: It's possible to create a section that is both absolute and relative at once, Instead of supplying just a `1` or `0` as the second argument to GBsection, supply a vector, matching the vector for position, but choosing which items to make absolute. GBsection([t,c,q]',[1,0,0]') The section produced will be absolute in time, but relative in crank and wing positions. **Overriding default gains**: GaitBuilder currently defaults to using Kp and Kd gains of 20 and 1, respectively, for both crank and wing joints. You can, however, override those values with your own, by adding a couple parameters to the compiled gait profile. The following example sets Kp and Kd to 30 and 1.5. profile.p_gain = [30 0; 0 30]; profile.d_gain = [1.5 0; 0 1.5]; **Manually setting stop flags**: CustomGait has a setting for stop flags which tell which nodes the gait can be stopped at. By default GaitBuilder will allow stopping at nodes produced by absolute positions, and not at relative positions. If you want to override that setting, you simply supply a third parameter to `GBsection`. GBsection([t,c,w]',1); % by default, allows stops GBsection([t,c,w]',0); % by default, does not allow stops GBsection([t,c,w]',1,0); % by setting, does not allow stops GBsection([t,c,w]',0,1); % by setting, allows stops **Allowing some legs to not move**: It's possible to only have some of your legs move, by not supplying leg profiles for them in a call to `GBexport` or `GBexportturn`. Instead, supply a string, 'freeze', in their place: __FIXME__ : code me! GBexport('new_gait.rc', 'New Gait', p1, 'freeze', p3, p4, 'freeze', p6); Code like this could be used to make a quadrapedal gait where the middle legs are inactive. ChangeLog --------- 2004-12-08 Clark Haynes * stop flags changing is now coded, no more "fixme" 2004-12-05 Clark Haynes * Wrote sections on compiling and exporting gaits 2004-12-03 Clark Haynes * Wrote a majority of the document