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. ^^