Author Topic: Help with algorithm for grid solving  (Read 1696 times)

0 Members and 1 Guest are viewing this topic.

Offline Ankit VirdiTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 1
Help with algorithm for grid solving
« on: July 02, 2013, 07:49:48 AM »
I am using 5 sensors and 2 dc motors. I want to turn my bot by 90deg at a node. I am doing that using delay, the problem i am facing with it is as my battery goes a bit down my delay changes. Is there any other algorithm for 90deg turn as I am not using stepper motors.
here's the code
#include"sensor.h"
#define S3 (PINA&(1<<3))
#define S2 (PINA&(1<<2))
#define S4 (PINA&(1<<4))
#define S5 (PINA&(1<<5))
#define S1 (PINA&(1<<1))
void main()
   {
   motor_init();
sensor_init();
while(1)
{
if(!(S1&&S5))
{
motor_forward();
}
if(S1&&S2&&S4&&S5&&S3)
{
motor_right();
_delay_ms(1000);
motor_forward();
_delay_ms(500);
}
}
)

Offline jkerns

  • Robot Overlord
  • ****
  • Posts: 269
  • Helpful? 12
Re: Help with algorithm for grid solving
« Reply #1 on: July 02, 2013, 08:53:44 AM »
If you need to continue to do this open loop you would need two things - an input to measure your battery voltage (voltage divider into an A/D) and some data that lets you write a function to determine how long to delay for the 90 degree turn.

Other options would be rotation sensors on the wheels, compass sensor or gyro sensors.
I get paid to play with robots - can't beat that with a stick.

http://www.ltu.edu/engineering/mechanical/bachelor-science-robotics-engineering.asp

Offline Ankit VirdiTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 1
Re: Help with algorithm for grid solving
« Reply #2 on: July 02, 2013, 09:27:51 AM »
Can I not do it with just the sensors I have? How is this guy doing it?
https://www.youtube.com/watch?v=0BXxfHZzw2Y

Offline robonerd137

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 1
Re: Help with algorithm for grid solving
« Reply #3 on: July 02, 2013, 10:19:18 AM »
That guy is using infrared sensors to track the black lines on the ground.

Offline Ankit VirdiTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 1
Re: Help with algorithm for grid solving
« Reply #4 on: July 02, 2013, 12:55:02 PM »
How is he turning his bot 90deg and 180deg?
By giving specific delays? or is there any other method?

Offline jkerns

  • Robot Overlord
  • ****
  • Posts: 269
  • Helpful? 12
Re: Help with algorithm for grid solving
« Reply #5 on: July 02, 2013, 01:33:25 PM »
It turns until the sensors "see" the black line in the proper place again.  I assume he is using two sensors spaced so that one is on each side of the line and makes adjustments to the right/left as each sensor moves over the line.
I get paid to play with robots - can't beat that with a stick.

http://www.ltu.edu/engineering/mechanical/bachelor-science-robotics-engineering.asp

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: Help with algorithm for grid solving
« Reply #6 on: July 02, 2013, 02:00:18 PM »
Typically you actually use more than two sensors -- six or eight are good, for line following. The further out to the side you detect the line, the stronger you make the turn signal.

Basically, when you "detect" that the sensors on the right hand side to "dark," you have a crossing to the right. If you want to turn right, start turning until at least one or two sensors on the right are "light" again, while moving forward. Keep doing that, and the 'bot will turn 90 degrees as it moves forward.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Help with algorithm for grid solving
« Reply #7 on: July 02, 2013, 05:15:18 PM »
Can I not do it with just the sensors I have?
What sensors do you have on your Bot?
With wheel encoders this is fairly easy without an external reference, like the line follower has.

Offline Ankit VirdiTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 1
Re: Help with algorithm for grid solving
« Reply #8 on: July 03, 2013, 12:22:13 AM »
I have 5 infrared sensors from which i had earlier made a line follower.Now I want to try and make a Path Finder, and I am sorry I don't know what are wheel encoders.

Offline Ankit VirdiTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 1
Re: Help with algorithm for grid solving
« Reply #9 on: July 03, 2013, 12:31:58 AM »
makes adjustments to the right/left as each sensor moves over the line.
I did not get what kinda adjustments?

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: Help with algorithm for grid solving
« Reply #10 on: July 03, 2013, 10:13:06 AM »
Adjustments to how you're turning.
If you know how to follow a line, you already know this.

Offline Ankit VirdiTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 1
Re: Help with algorithm for grid solving
« Reply #11 on: July 03, 2013, 12:59:21 PM »
Yes I got it thanks.. I have set a variable as a flag.. its working fine.. Thanks a lot everybody :)

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Help with algorithm for grid solving
« Reply #12 on: July 03, 2013, 07:40:12 PM »
Wheel encode output ticks (pulses) as the wheel rotates. There are multiple tick per one revolution of a wheel. These can be using as feed back to maintain a constant wheel rotation speed and can also be counted to know how much a wheel has rotated.
By knowing the wheel diameter/circumference and the number of encoder ticks it can then be calculated how far along the ground the wheel has moved (assuming the wheel did not slip).

Here is an example:
http://www.pololu.com/catalog/product/1218

 


Get Your Ad Here