Simple Rotation

Ringo setup, hardware, basic programming. User to user support.
cbw060
Posts: 23
Joined: Wed Aug 26, 2015 6:21 pm

Simple Rotation

Postby cbw060 » Tue Sep 08, 2015 4:39 am

I was trying the example navigation on page 49 of the Guide, using the RotateSimple routine.

Problem: no matter what degrees of rotation i put in, Ringo goes forward in straight line.

Any suggestions?!?

Code Follows:
#include "RingoHardware.h"


void setup() {
HardwareBegin(); //initialize Ringo's brain to work with his circuitry
PlayStartChirp(); //Play startup chirp and blink eyes
delay(5000); // wait 1 sec before starting Navigation
NavigationBegin();
//SwitchMotorsToSerial(); //Call "SwitchMotorsToSerial()" before using Serial.print functions as motors & serial share a line
RestartTimer();
}

void loop() {

// add your own code here
//simple motor testing:
RotateSimple(180, 150, 150, 1500, 200);
delay(1000);
RotateSimple(-180,150,150,1500,200);
delay (1000);

}

Kevin
Posts: 175
Joined: Tue Jul 28, 2015 12:56 am

Re: Simple Rotation

Postby Kevin » Fri Sep 11, 2015 7:58 pm

lol. I guess I should have actually tested that code. :?

I was writing the manual in a big hurry and described the functions as I understood them - I obviously misunderstood that one. So RotateSimple drives the motors at whatever speed you've set and stops them when the prescribed rotation has been achieved. So the idea is to make them different speeds so a rotation is produced and they will both stop when Ringo turns the correct amount.

I think if you try something like this inside loop() you'll get expected the results:

Code: Select all

RotateSimple(90, 200, 120, 3000, 200);  // set motors to drive in an arc to the right then stop at 90 degrees rotation
delay(1000);
RotateSimple(-90, 120, 200, 3000, 200);  // drive arc to the left, stop at -90 degree rotation
delay (1000);


I'll need to update the guide.

Generally you'll use RotateSimple if you plan on moving during the rotation - like driving an arc. RotateSimple makes a guess as to how far Ringo will skid after turning off the motors, so it's not dead accurate but it's pretty close. RotateAccurate is when you want to rotate in its own footprint and as accurate as possible. If you run the calibrate gyro sketch and get the gyro dialed in once, then this RotateAccurate will work really well. With RotateAccurate, if it over-shoots a bit due to a skid, it'll reverse and correct to land on the target heading.

Try this code below. It should rotate to 180 degrees, then back around the top to -180 degrees then repeat.

Code: Select all

#include "RingoHardware.h"


void setup() {
HardwareBegin(); //initialize Ringo's brain to work with his circuitry
PlayStartChirp(); //Play startup chirp and blink eyes
delay(5000); // wait 1 sec before starting Navigation
NavigationBegin();
//SwitchMotorsToSerial(); //Call "SwitchMotorsToSerial()" before using Serial.print functions as motors & serial share a line
RestartTimer();
}

void loop() {

// add your own code here
//simple motor testing:
CalibrateNavigationSensors();
RotateAccurate(180, 2000);
delay(1000);
CalibrateNavigationSensors();
RotateAccurate(-180, 2000);
delay (1000);

}


Who is online

Users browsing this forum: No registered users and 1 guest