2 problems I found in the library. (Wheel control & ping)

When I was running my program on the sparki robot, I got some wired results. After days of frustration, I found an important bug in the source code.
On line 369, 400, 431 and 462 of sparki.cpp, in these function: moveLeft(deg),moveRight(deg),moveForward(cm) and moveBackward(cm), when a negative value is encountered, the function of the opposite movement is called, but the parameter is not changed to positive, which creates infinity recursive loop !!

In addition, in the ping() function, it stores the returned value from ping_single(), an integer, as a float. This value is only used for sorting, and is converted to integer again. This is quite a waste of precious memory, which should be fixed as well.

^^ Hope other people don’t encounter the same issue. ^^

I’ve shelved my Sparki…too many issues. It seems that they rush into releasing new versions without testing or that they are rookie coders. I’ll get back on it once the system is stable. It’s taking too much time to debug issues such as this…

That’s so cool! Nice work!

[quote=“dingdinglhz”]When I was running my program on the sparki robot, I got some wired results. After days of frustration, I found an important bug in the source code.
On line 369, 400, 431 and 462 of sparki.cpp, in these function: moveLeft(deg),moveRight(deg),moveForward(cm) and moveBackward(cm), when a negative value is encountered, the function of the opposite movement is called, but the parameter is not changed to positive, which creates infinity recursive loop !!

In addition, in the ping() function, it stores the returned value from ping_single(), an integer, as a float. This value is only used for sorting, and is converted to integer again. This is quite a waste of precious memory, which should be fixed as well.

^^ Hope other people don’t encounter the same issue. ^^[/quote]

Where on my mac is can I find sparki.h and spark.cpp?

For OSX, assuming you dragged SparkiDuino.app to your Applications folder, it would be in:

/Applications/SparkiDuino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Sparki.cpp
/Applications/SparkiDuino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Sparki.h

You can get to it by going to the applications folder, right clicking, and going “Show Package Contents”

I got my new sparkie and one of the wheels could not spin. Do you think they are related?

nope, this was fixed ages ago

In that case, should the item be returned? The robot cannot only rotate clockwise or anti-clockwise.

See [url]New sparki - One wheel cannot rotate], my problem was fixed.