Pages: [1] 2   Go Down
Author Topic: Boe-bot for arduino roaming with ping on servo turret  (Read 2935 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been trying to find out why the boe-bot jacks the turret to the left and starts turning in circles to the left. When the boe-bot encounters a corner. If I put an object in front of the sensor while its in its retard turn it snaps out of it and starts to move around like normal. Knowing C++ fairly well I can see in the sketch the author may have had a major lack of concentration because I see a lot of first grader mistakes and "WTF's?".

Others have had this issues and their fix was ether new battery's or a bad ground. Well that's not the problem with this bot, all fresh batteries, connections to the circuit are fine and everything works.

I have tried to find help on the parallax forum and other parts of their site but it seems to me their company or users have a major bias towards arduino and do not support the arduino shield as well as their own micro controller even though they said they would.

I think its programing. Am I wrong?

Here is a link to the sketch:
http://learn.parallax.com/project/let-it-roam
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4257
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One thing that I noticed without going far into the code is this
Code:
// Declare array to store that many cm distance elements using pre-calculated
// number of elements in array.
const int elements = sizeof(sequence);
int cm[elements];
Despite what it says in the comment
Code:
sizeof(sequence);
does not return the number of elements in the array but rather the number of bytes in the array.  It probably does not matter because sequence[] is an int array so the cm[] array will have twice as many elements in it as needed.

Interestingly in the very next section of code sizeof() is used again but incorrectly in a different way.
Code:
const int degreesTurret = 180/(sizeof(sequence)/sizeof(int)-1);
degreesTurret is going to end up wrong because the number of elements is not actually sizeof(sequence)/sizeof(int)-1 so the turret will presumably try to move too far.

Neither of these observations may actually cause any problems but it does not bode well for the rest of the program.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26293
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see "detach" calls for the servos, but no re-attach.
Make sure you never call "maneuver" with -1 for the argument "msTime".
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Check which pins your using for servo timing and motor control. For example, the standard servo.h lib is not compatible with the standard motor shield.

Mark
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Check which pins your using for servo timing and motor control. For example, the standard servo.h lib is not compatible with the standard motor shield.

Mark


The bot uses two servos to move it one for the left and one for the right wheel. Those two servos have some modification that makes them a continuous rotation servo motor, they also have a potentiometer for calibrating the speed so they both move the bot strait. But it can be a pain to keep the two servos even and calibrated.
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4257
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need some rotation sensors so that you can compare the rotational speed of the wheels and adjust the speed of the motors accordingly.  There are even clever ways to do it with only one rotation sensor but it would be easy to do it with two.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see "detach" calls for the servos, but no re-attach.
Make sure you never call "maneuver" with -1 for the argument "msTime".

yes, that's one spot that made me wonder why a detach is ever needed and if that sketch uses that part of the function.

It also made me wonder how delay() would handle a negative number or if it defaults to one or zero.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It also made me wonder how delay() would handle a negative number or if it defaults to one or zero.
The argument to delay() is an unsigned long. You need to determine for yourself what -1 as an unsigned long looks like. It will mean a lot more to you if you figure that out that if we tell you.

A hint, though. No, it does not cause delay() to think that you meant 0 or 1, not be a long shot. (Or an unsigned long shot).
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need some rotation sensors so that you can compare the rotational speed of the wheels and adjust the speed of the motors accordingly.  There are even clever ways to do it with only one rotation sensor but it would be easy to do it with two.

Can you tell me what rotation sensors would be good enough, easy to get and and fairly cheap?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26293
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've used IR proximity sensors and bits of white card stuck to the tyre in the past.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It also made me wonder how delay() would handle a negative number or if it defaults to one or zero.
The argument to delay() is an unsigned long. You need to determine for yourself what -1 as an unsigned long looks like. It will mean a lot more to you if you figure that out that if we tell you.

A hint, though. No, it does not cause delay() to think that you meant 0 or 1, not be a long shot. (Or an unsigned long shot).

Either Im going blind or the banks should start storing everyone's negative debt in an unsigned long.
« Last Edit: February 12, 2013, 01:05:50 pm by S_Flex » Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4257
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need some rotation sensors so that you can compare the rotational speed of the wheels and adjust the speed of the motors accordingly.  There are even clever ways to do it with only one rotation sensor but it would be easy to do it with two.

Can you tell me what rotation sensors would be good enough, easy to get and and fairly cheap?
I can't recommend a particular one but Google will find you plenty, or ask in the Robotics section of this forum for more specific advice.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What value is in a byte (unsigned) when you try to store -1 in it?
What value is in an int (unsigned) when you try to store -1 in it?
What value is in a long (unsigned) when you try to store -1 in it?

Write a sketch to find out.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 47
I'm glad I bought an Arduino Leonardo
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What value is in a byte (unsigned) when you try to store -1 in it?
What value is in an int (unsigned) when you try to store -1 in it?
What value is in a long (unsigned) when you try to store -1 in it?

Write a sketch to find out.

1) error: invalid combination of multiple type-specifiers
2) 65,535
3) 4,294,967,295

I maybe wrong on the exact number for three and two because I didnt have time to copy it. I sure didnt think it would return the highest number it can hold...

well seeing that makes truely think the boe-bot sketch is broke and its not a hardware issue.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49343
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I sure didnt think it would return the highest number it can hold...
Which is why delay(-1) is not a good idea. That will take a few weeks to complete.
Logged

Pages: [1] 2   Go Up
Jump to: