Folks, I’m still having issues with incorrect angles, even after .h & .cpp updates today. Anyone else seeing this?
Was using this very crude code to try draw a letter “H”:
[code]/*******************************************
Basic motor test
Move Sparki forward and backwards, then
rotate right and left, then stop. Repeat!
Can you get Sparki to do any cool motions?
Maybe draw something by sticking a pen down
the center?
********************************************/
#include <Sparki.h> // include the robot library
void setup()
//Write the word “HELLO” with marker.
//Start with Sparki on Top Left of sheet of paper & facing down.
{
//letter “H”.
sparki.moveForward(20);// move the robot forward
sparki.moveLeft(180); // rotate the robot counter clockwise
sparki.moveForward(10);// move the robot forward
sparki.moveRight(90); // rotate the robot clockwise
sparki.moveForward(10);// move the robot forward
sparki.moveLeft(90); // rotate the robot counter clockwise
sparki.moveForward(10);// move the robot forward
sparki.moveLeft(180); // rotate the robot counter clockwise
sparki.moveForward(20);// move the robot forward
sparki.moveLeft(90); // rotate the robot counter clockwise
}
void loop()
{
}[/code]
Angles are way off.
In Sparki.h, it states that the distance between both wheels is 11.1cm. Surely it’s to be measured between the rubber tracks. If so, it’s actually 8.5cm.
It’s used to calculate the rotation angles as follows:
const float TRACK_WIDTH = 11.1; //tyre seperation in cm
const float STEPS_PER_ROTATION = (TRACK_WIDTH / WHEEL_DIAMETER_CM) * STEPS_PER_REV ; // robot rotation