Wiki source code of BRAT Biped Autonomous Tutorial

Last modified by Eric Nantel on 2026/04/06 12:54

Hide last authors
Eric Nantel 24.1 1 {{html wiki="false" clean="false"}}
2 <style>
3 .asm { font-family: Verdana, Helvetica, sans-serif; font-size: 14px; max-width: 960px; }
4 .asm-step { background: #fff; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 1.5rem; overflow: hidden; }
5 .asm-step-header { background: #F5A800; display: flex; align-items: stretch; justify-content: space-between; }
6 .asm-step-name { padding: 0.6rem 1rem; font-weight: bold; font-size: 15px; color: #2C1A00; }
7 .asm-step-num { background: #1a1a1a; color: white; padding: 0.6rem 1.1rem; font-weight: bold; font-size: 15px; display: flex; align-items: center; white-space: nowrap; }
8 .asm-step-body { display: flex; flex-wrap: wrap; gap: 1.25rem; padding: 1rem; align-items: flex-start; }
9 .asm-step-text { flex: 1 1 250px; font-size: 13px; line-height: 1.6; }
10 .asm-step-figure { flex: 0 1 280px; text-align: center; }
11 .asm-step-figure img { max-width: 100%; height: auto; border: 1px solid #ccc; border-radius: 4px; }
12 .asm-step-figure span { display: block; font-size: 12px; color: #666; margin-top: 0.3rem; }
13 .asm-figures { display: flex; flex-wrap: wrap; gap: 0.75rem; }
14 .asm-fullwidth { padding: 1rem; border-top: 1px solid #eee; font-size: 13px; overflow-x: auto; }
15 .ref-table { border-collapse: collapse; font-size: 12px; }
16 .ref-table th { background: #ccc; border: 1px solid #aaa; padding: 0.3rem 0.6rem; text-align: center; }
17 .ref-table td { border: 1px solid #ddd; padding: 0.3rem 0.6rem; text-align: center; }
18 .ref-table tr:nth-child(odd) td { background: #f9f9f9; }
19 .ref-table tr:nth-child(even) td { background: #fff; }
20 .asm-warning { color: #c00; font-weight: bold; }
21 .asm h1 { font-size: 18px; margin-bottom: 0.25rem; }
22 </style>
23
24 <div class="asm">
25
26 <!-- Header -->
27 <div style="padding: 0.5rem 0 1rem 0; display:flex; flex-wrap:wrap; gap:1.5rem; align-items:flex-start;">
28 <div style="flex:1 1 300px;">
29 <h1 class="asm">Biped BRAT Autonomous Tutorial</h1>
30 <p><b>Updated December 20, 2011</b></p>
31 <p><span class="asm-warning">Safety first!</span> Wear eye protection and never touch a powered robot!</p>
32 <p><b>Hardware required:</b> Bot Board II, BASIC Atom Pro 28, Sharp GP2D12 sensor, Buffered 2-Axis Accelerometer (DE-11).</p>
33 <p><b>Software &amp; downloads:</b></p>
34 <ul style="padding-left:1.2rem; margin-top:0.25rem; line-height:1.8;">
35 <li>BASIC Micro Studio</li>
36 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/bratosf3.zip">BRAT Servo Offset Finder Program v3</a></li>
37 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/abrat1.zip">Autonomous Walk Code</a></li>
38 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/abrat2.zip">Autonomous GP2D12 Code</a> — Videos: <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/avoid01.mpg">Avoiding obstacle</a> · <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/break01.mpg">Taking a break</a> · <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/walkaway.mpg">Proximity beeps</a></li>
39 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/abrat3.zip">Autonomous 1-Axis Accelerometer Code</a> — Video: <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/getup01.mpg">Getting up front and back</a></li>
40 <li><a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/abrat4.zip">Autonomous 2-Axis Accelerometer Code</a> — Video: <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/getup02.mpg">Getting up front and side</a></li>
Eric Nantel 20.1 41 </ul>
Eric Nantel 24.1 42 </div>
43 <div style="text-align:center; flex:0 1 280px;">
44 <img src="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/brat00.jpg" style="max-width:100%; border:1px solid #ccc; border-radius:4px;">
45 <p style="font-size:12px; color:#666; margin-top:0.3rem;"><b>Biped BRAT.</b></p>
46 </div>
47 </div>
48
49 <!-- Step 1 -->
50 <div class="asm-step">
51 <div class="asm-step-header">
52 <div class="asm-step-name">Autonomous — Verify Servo Channel Connections</div>
53 <div class="asm-step-num">Step 1 / 10</div>
54 </div>
55 <div class="asm-step-body">
56 <div class="asm-step-text">
57 <p>Make sure your servos are plugged into the appropriate channels per Table 1. Note: P9 is used by the speaker and cannot be used for a servo.</p>
58 </div>
59 <div class="asm-step-figure" style="flex: 0 1 auto;">
60 <table class="ref-table" style="width:auto;">
61 <tr><th>Bot Board I/O</th><th>Connection</th></tr>
62 <tr><td>P4</td><td>Left Ankle</td></tr>
63 <tr><td>P5</td><td>Left Knee</td></tr>
64 <tr><td>P6</td><td>Left Hip</td></tr>
65 <tr><td>P7</td><td>Right Ankle</td></tr>
66 <tr><td>P8</td><td>Right Knee</td></tr>
67 <tr><td>P10</td><td>Right Hip</td></tr>
68 </table>
69 <span style="margin-top:0.4rem;">Table 1.</span>
70 </div>
71 </div>
72 </div>
73
74 <!-- Step 2 -->
75 <div class="asm-step">
76 <div class="asm-step-header">
77 <div class="asm-step-name">Autonomous — Configure Bot Board II Jumpers</div>
78 <div class="asm-step-num">Step 2 / 10</div>
79 </div>
80 <div class="asm-step-body">
81 <div class="asm-step-text">
82 <p>Set the Bot Board II jumpers per Table 2. The VS to AX0 jumper enables the program to monitor servo battery voltage — when the battery is low the robot can beep a warning. Refer to Figure 2 for the jumper layout.</p>
83 </div>
84 <div class="asm-step-figure" style="flex: 0 1 auto;">
85 <table class="ref-table" style="width:auto; margin-bottom:0.5rem;">
86 <tr><th colspan="2">Bot Board II Jumper Settings (Table 2)</th></tr>
87 <tr><td>Enable</td><td>A, B, and C buttons</td></tr>
88 <tr><td>5V</td><td>I/O Group 0–3</td></tr>
89 <tr><td>VS</td><td>I/O Groups 4–7 and 8–11</td></tr>
90 <tr><td>Enable</td><td>SPKEN (Speaker Enable)</td></tr>
91 <tr><td>Enable</td><td>VS (Servo Voltage) to AX0 (P16)</td></tr>
92 </table>
93 <span>Table 2.</span>
94 </div>
95 </div>
96 <div class="asm-fullwidth">
97 <p style="font-weight:bold; margin-bottom:0.4rem;">Figure 2 — Jumper diagram</p>
98 <img src="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/autobrat.gif" style="max-width:100%; border:1px solid #ccc; border-radius:4px;">
99 </div>
100 </div>
101
102 <!-- Step 3 -->
103 <div class="asm-step">
104 <div class="asm-step-header">
105 <div class="asm-step-name">Autonomous — Find Servo Offsets</div>
106 <div class="asm-step-num">Step 3 / 10</div>
107 </div>
108 <div class="asm-step-body">
109 <div class="asm-step-text">
110 <p>Download and install BASIC Micro Studio. Download the <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/bratosf3.zip">BRAT Servo Offset Finder Program v3</a>, load it into the IDE, and program the Atom Pro. Then use the buttons to find offsets:</p>
111 <ul style="margin-top:0.5rem; padding-left:1.2rem;">
112 <li><b>A</b> — decrease servo offset by 5µs</li>
113 <li><b>C</b> — increase servo offset by 5µs</li>
114 <li><b>B</b> — change which servo is being adjusted, and save offsets (order shown in Figure 3)</li>
115 </ul>
116 <p>If the Speaker is enabled, pressing B plays a tone that rises in pitch as you cycle through servos, and drops to a longer tone when returning to Start.</p>
117 </div>
118 <div class="asm-step-figure">
119 <img src="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/bratosf3.jpg">
120 <span>Figure 3 — Servo offset finder sequence.</span>
121 </div>
122 </div>
123 </div>
124
125 <!-- Step 4 -->
126 <div class="asm-step">
127 <div class="asm-step-header">
128 <div class="asm-step-name">Autonomous — Calibrate Robot to Neutral Position</div>
129 <div class="asm-step-num">Step 4 / 10</div>
130 </div>
131 <div class="asm-step-body">
132 <div class="asm-step-text">
133 <p>Place the robot as close to neutral as possible and turn it on. It should hold the neutral position resembling Figures 4-1 through 4-3. If any joint is off by more than 15°, remove the servo horn, rotate to align, and reattach. Use the A, B, and C buttons to fine-tune.</p>
134 <p>Note: HS-422 hip servos may oscillate when the robot is lifted off the ground — this is normal and minimal when walking. Higher voltage makes oscillations worse. Higher-power servos (HS-475, HS-485, HS-645) do not exhibit this.</p>
135 <p><span class="asm-warning">After adjusting all servos to match Figures 4-1 through 4-3, pressing B saves the offset values to the Atom Pro's EEPROM.</span></p>
136 </div>
137 <div class="asm-figures">
138 <div class="asm-step-figure">
139 <img src="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/brat10.jpg">
140 <span>Figure 4-1 (front view).</span>
141 </div>
142 <div class="asm-step-figure">
143 <img src="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/brat07.jpg">
144 <span>Figure 4-2 (side view).</span>
145 </div>
146 <div class="asm-step-figure">
147 <img src="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/brat04.jpg">
148 <span>Figure 4-3 (rear view).</span>
149 </div>
150 </div>
151 </div>
152 </div>
153
154 <!-- Step 5 -->
155 <div class="asm-step">
156 <div class="asm-step-header">
157 <div class="asm-step-name">Autonomous — Load Basic Walk Code</div>
158 <div class="asm-step-num">Step 5 / 10</div>
159 </div>
160 <div class="asm-step-body">
161 <div class="asm-step-text">
162 <p>Download the <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/abrat1.zip">BRAT Autonomous Walk Code</a>, load it into the IDE, and program your BRAT.</p>
163 <p>The BRAT will now walk autonomously following this sequence: walk × 3, turn, long-stride × 2, kick, turn, stop. To customise behavior, modify the code between the labels "main" and "move", or create new sequences following the format below the "move" label.</p>
164 </div>
165 </div>
166 </div>
167
168 <!-- Step 6 -->
169 <div class="asm-step">
170 <div class="asm-step-header">
171 <div class="asm-step-name">Autonomous — Mount &amp; Connect GP2D12 Sensor</div>
172 <div class="asm-step-num">Step 6 / 10</div>
173 </div>
174 <div class="asm-step-body">
175 <div class="asm-step-text">
176 <p>Use double-sided tape to attach the GP2D12 sensor to the BRAT's head area, facing the front. Exact position is not critical. Plug the sensor into the channel shown in Table 6.</p>
177 <table class="ref-table" style="width:auto; margin-top:0.5rem;">
178 <tr><th>Bot Board I/O</th><th>Connection</th></tr>
179 <tr><td>P19 (AX3)</td><td>GP2D12 Sensor</td></tr>
180 </table>
181 <p style="font-size:11px; color:#666; margin-top:0.3rem;">Table 6.</p>
182 </div>
183 <div class="asm-step-figure">
184 <img src="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/bratsens.jpg">
185 <span>Figure 6 — GP2D12 sensor mounted.</span>
186 </div>
187 </div>
188 </div>
189
190 <!-- Step 7 -->
191 <div class="asm-step">
192 <div class="asm-step-header">
193 <div class="asm-step-name">Autonomous — Load GP2D12 Obstacle Avoidance Code</div>
194 <div class="asm-step-num">Step 7 / 10</div>
195 </div>
196 <div class="asm-step-body">
197 <div class="asm-step-text">
198 <p>Download the <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/abrat2.zip">BRAT Autonomous GP2D12 Code</a>, load it into the IDE, and program your BRAT.</p>
199 <p>The BRAT can now roam without bumping into obstacles. The sensor is read before each step. A short low beep means nothing is detected; the beep rises in pitch as objects get closer. At ~8" the robot backs up one step, turns left two steps, then continues. A looping counter periodically puts the robot into a resting position. LEDs illuminate based on the current command.</p>
200 <p>Videos: <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/avoid01.mpg">Avoiding obstacle</a> · <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/break01.mpg">Taking a break</a> · <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/walkaway.mpg">Proximity beeps</a></p>
201 </div>
202 </div>
203 </div>
204
205 <!-- Step 8 -->
206 <div class="asm-step">
207 <div class="asm-step-header">
208 <div class="asm-step-name">Autonomous — Mount &amp; Connect Accelerometer</div>
209 <div class="asm-step-num">Step 8 / 10</div>
210 </div>
211 <div class="asm-step-body">
212 <div class="asm-step-text">
213 <p>Use double-sided tape to attach the accelerometer to the BRAT's head area. <span class="asm-warning">Axis orientation is critical — follow the orientation shown in Figure 8 exactly.</span> Plug the sensor into the channels shown in Table 8.</p>
214 <table class="ref-table" style="width:auto; margin-top:0.5rem;">
215 <tr><th>Bot Board I/O</th><th>Connection</th></tr>
216 <tr><td>P17 (AX1)</td><td>Accelerometer Y Axis (front-to-back tilt)</td></tr>
217 <tr><td>P18 (AX2)</td><td>Accelerometer X Axis (side-to-side tilt)</td></tr>
218 </table>
219 <p style="font-size:11px; color:#666; margin-top:0.3rem;">Table 8.</p>
220 </div>
221 <div class="asm-step-figure">
222 <img src="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/bratacc.jpg">
223 <span>Figure 8 — Accelerometer orientation.</span>
224 </div>
225 </div>
226 </div>
227
228 <!-- Step 9 -->
229 <div class="asm-step">
230 <div class="asm-step-header">
231 <div class="asm-step-name">Autonomous — Load 1-Axis Accelerometer Code</div>
232 <div class="asm-step-num">Step 9 / 10</div>
233 </div>
234 <div class="asm-step-body">
235 <div class="asm-step-text">
236 <p>Download the <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/abrat3.zip">BRAT Autonomous 1-Axis Accelerometer Code</a>, load it into the IDE, and program your BRAT.</p>
237 <p>This program uses only the Y Axis to detect front-to-back tilt — the BRAT can tell when it has fallen forward or backward and get back up. The X Axis will be incorporated in Step 10.</p>
238 <p>Video: <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/getup01.mpg">Getting up front and back</a></p>
239 </div>
240 </div>
241 </div>
242
243 <!-- Step 10 -->
244 <div class="asm-step">
245 <div class="asm-step-header">
246 <div class="asm-step-name">Autonomous — Load 2-Axis Accelerometer Code</div>
247 <div class="asm-step-num">Step 10 / 10</div>
248 </div>
249 <div class="asm-step-body">
250 <div class="asm-step-text">
251 <p>Download the <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/abrat4.zip">BRAT Autonomous 2-Axis Accelerometer Code</a>, load it into the IDE, and program your BRAT.</p>
252 <p>This version adds the X Axis for side-to-side tilt detection — if the BRAT falls onto its side it will roll over to get back up. It also includes an improved "get up from back" routine for robots with heavy cabling, and a "startled" behaviour: if the BRAT is resting and the GP2D12 suddenly detects an object, it will lean back and beep.</p>
253 <p>Video: <a href="https://wiki.lynxmotion.com/info/wiki/lynxmotion/download/servo-erector-set-robots-kits/ses-v1-robots/ses-v1-bipeds/brat-biped-autonomous/WebHome/getup02.mpg">Getting up front and side</a></p>
254 </div>
255 </div>
256 </div>
257
258 </div>
Eric Nantel 1.1 259 {{/html}}
Copyright RobotShop 2018