| 162 | | If you launch this tool in the dir. containing your '''{{{settings.py}}}''' config file with a previous {{{SERVOS_CALIBRATION}}} dict., it will be used as default values. |
| | 163 | ------------ |
| | 164 | |
| | 165 | Most servos have a range of 180°. So, it is important to mount them on the robot so the servo neutral position (''SNP'') match the joint neutral position (''JNP''). Here is the leg neutrals usually used for a 3 DoF leg: |
| | 166 | |
| | 167 | {{{ |
| | 168 | XY plane (top view): |
| | 169 | |
| | 170 | C F T |
| | 171 | o---o---------o------- |
| | 172 | |
| | 173 | XZ plane (side view): |
| | 174 | |
| | 175 | C F T |
| | 176 | o---o---------o |
| | 177 | | |
| | 178 | | |
| | 179 | | |
| | 180 | }}} |
| | 181 | |
| | 182 | * C = coxa |
| | 183 | * F = femur |
| | 184 | * T = tibia |
| | 185 | |
| | 186 | This position should be reached when servos pulses are 1500µs (1500µs is the neutral pulse of hobby servos). It may vary a little bit, and you can fine tune this value by scanning the mechanical range of the servo, and take the middle value (neutral_pulse = (min_pulse + max_pulse) / 2). A little servo tester can be helpful. |
| | 187 | |
| | 188 | In the above position, ''SNP'' are all 90°, as it is standard servo neutral position for 1500µs. |
| | 189 | |
| | 190 | Looking how '''Py4bot''' internally manages angles (http://www.py4bot.org/wiki/UserGuideGit#a3DoFlegs), we can see that in this same position, ''JNP'' are: |
| | 191 | |
| | 192 | * coxa = 0° |
| | 193 | * femur = 180° |
| | 194 | * tibia = 90° |
| | 195 | |
| | 196 | This means that there will be some offset between the servo angles and the framework angles. |
| | 197 | |
| | 198 | Another thing to tune is the ratio between pulse variation and real servo displacement. This ratio varies a lot from a brand to another. And even for a same model, it varies from a servo to another. This is especially true for low cost servos. |
| | 199 | |
| | 200 | Offsets and ratios are defined in the {{{SERVO_CALIBRATION}}} table. This table also has a '''pulse90''' param, to fine tune the ''SNP'' (it is not always possible to mount the servo so 1500µs is the perfect ''JNP''). |
| | 201 | |
| | 202 | Py4bot has a graphical tool, '''{{{py4bot-gui-servocal.py}}}''', to help set up this table once the robot is build. Here is how to use it. |
| | 203 | |
| | 204 | We first need to enable the servo, by clicking the '''Enable''' checkbox. Then, we need to check if the servo rotates the right direction: increasing the pulse value should make the joint turning in the trigonometric sense regarding our previous schematic. If it is not the case, click the '''Invert''' checkbox (usually, coxa joints are all the same, and other joints should be inverted for legs of one side, but it depends if there is a symmetry in the mechanics or not). Note that from within this tool, the servo direction won't change! But the ratio will be inverted, so '''Py4bot''' computes angles the right way. |
| | 205 | |
| | 206 | We are now ready to fine tune the ''SNP'', and set its matching ''JNP''. To do this, we move the '''Pulse''' slider until we mechanically reach the ''JNP''. Then, we move the '''Joint neutral''' slider to match the theoretical ''JNP'' for that specific joint (as we seen, coxa = 0°, femur = 180°, tibia = 90°). Then, we click the '''Set pulse''' button of the joint neutral setting. This recomputes the '''offset''' and '''pulse90''' params of the {{{SERVO_CALIBRATION}}} table. |
| | 207 | |
| | 208 | Then, we need to tune the ratio. This step is a little bit harder, as we need to measure the angle the joint really moves. The best way is to move up to +-90°, as it is visually easy to see, but it is not always mechanically possible, and we can restrict the range to +-45°. |
| | 209 | |
| | 210 | So, we move the 'Angle min' slider to -45°. Then, we move the '''Pulse''' slider so our joint really reaches -45°. Last, we click the '''Set pulse''' button of the '''Angle min'' slider to recompute the ratio. |
| | 211 | |
| | 212 | We of course need to repeat the procedure for the angle max. After both have been tuned, the ratio should be correct. |
| | 213 | |
| | 214 | And we need to repeat the entire procedure for each servo/joint, which can be tedious for a 4 DoF hexapod :o/ But after that, our robot should walk better ;o) |
| | 215 | |
| | 216 | Note that if we already have a '''{{{settings.py}}}''' module, we can launch '''{{{py4bot-gui-servocal.py}}}''' from the directory containing that module in order to reload the previous values (no gui values are stored, though). |
| | 217 | |
| | 218 | ------------------- |