Go Down

Topic: Boe-bot for arduino roaming with ping on servo turret (Read 3708 times) previous topic - next topic

S_Flex

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

UKHeliBob

One thing that I noticed without going far into the code is this
Code: [Select]
// 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: [Select]
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: [Select]
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.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

AWOL

I see "detach" calls for the servos, but no re-attach.
Make sure you never call "maneuver" with -1 for the argument "msTime".
"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.

holmes4

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

S_Flex


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.

UKHeliBob

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.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

S_Flex


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.

PaulS

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

S_Flex


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?

AWOL

I've used IR proximity sensors and bits of white card stuck to the tyre in the past.
"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.

S_Flex

#10
Feb 12, 2013, 07:00 pm Last Edit: Feb 12, 2013, 07:05 pm by S_Flex Reason: 1

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.

UKHeliBob



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.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

PaulS

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.

S_Flex


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.

PaulS

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.

Go Up