Unofficial library update: 1.0.5.4b plus move fixes

Since Arcbotics has not responded to the persisting problems with move distances and angles not working right, I have cloned their files and implemented some fixes in the Sparki library. (See also this post: [url]Driving distance and turning angle still don't work right])

My files also include a proper fix for allowing negative move distances and angles. (See this post: [url]moveForward() broken in library on GitHub])

For anybody who’s interested, my repository is here:
https://github.com/robotobyte/Sparki/tree/27bea9dc44faf8406e20c6c75fb44dcd4e09633d/Arduino%20Library

The only file you really need is this one:
https://github.com/robotobyte/Sparki/blob/27bea9dc44faf8406e20c6c75fb44dcd4e09633d/Arduino%20Library/Sparki.cpp

If you replace the matching file in your local copy of the Sparki library, you’ll get all of the move function fixes relative to official release 1.0.5.4b. (If you haven’t already updated to the 1.0.5.4b release, please do that first.)

Note again that my code is not an official release from Arcbotics; I don’t work for them.

My test program for my fixes is this:

[code]#include <Sparki.h>

void setup () {

// Basic movement test: Sparki should end up where it started:

sparki.moveForward ( 10 );
sparki.moveForward ( -10 );
delay ( 1000 );
sparki.moveBackward ( 10 );
sparki.moveBackward ( -10 );
delay ( 1000 );
sparki.moveRight ( 45 );
sparki.moveRight ( -45 );
delay ( 1000 );
sparki.moveLeft ( 45 );
sparki.moveLeft ( -45 );

delay ( 2000 );

// Draw two 10cm x 10cm squares, once using positive and once
// using negative distances/angles: the two squares will be
// sharing one edge:

uint8_t square;
uint8_t side;
int8_t sign;
for ( square = 0; square < 2; square++ ) {
sign = square == 0 ? +1 : -1;
for ( side = 0; side < 4; side++ ) {
sparki.moveForward ( 10 * sign );
sparki.moveRight ( 90 * sign );
}
}

}

void loop () {
}[/code]

Why branch from b? C is the latest.

I realize that the overall SparkiDuino package is at 1.0.5.4c, but did the library actually change from the b package to the c package? I have to admit that I did not look inside the full Windows 1.0.5.4c install package. I was trying to avoid redundant Arduino and SparkiDuino installations, so I manually plugged the Sparki library into my Arduino environment. When I updated my IDE to 1.0.5.4, I got the library from the “Arduino Library file” link in the initial post on the “SparkiDuino 1.0.5.4 Update (Feb 17th)” thread. At this very moment, that link still points to 1.0.5.4b (d3k8ss0l8daviq.cloudfront.net/Sp … 0.5.4b.zip). The OS X package also still points to b. Only the Windows and driver installers point to c.

In any case, when I forked on GitHub, it was from the latest version of your repo at the time. Maybe it’s my inexperience with GitHub, but looking at your repository there, I have not found an easy way to match a particular commit with a formal release. If I’m missing something, I’d appreciate an education.

I should add that my fixes for driving distance and turn angles are based on the following assumptions:
[ul]wheel diameter (outside diameter of black o-rings around the wheels) = 51.5mm
wheel separation (from one wheel’s o-ring to the o-ring of the other wheel) = 85.5mm[/ul]

For driving distance, only the wheel diameter matters, and the mechanical variation of that 51.5mm diameter seems to be relatively small (at least based on my small set of samples). As a result, if you tell Sparki to drive, for example, 10cm, you should get something that’s indeed pretty close to 10cm.

Turns are more flaky. Turns depend on wheel diameter and separation, so the mechanical variation in both compounds. Furthermore, there’s a lot of mechanical slop (+/-1.5mm?) in the wheel-to-wheel separation (much due to axial plan in the motor shafts), so that makes turning angles potentially imprecise.

I’ve been wondering whether there’s a simple modification to reduce the mechanical slop, but I haven’t had a chance to play around. Any ideas?