Link to home
Start Free TrialLog in
Avatar of krish006
krish006

asked on

obstacle avoidance

I am having a problem.
I have to write a program for a robot to move from (1,1) to 20,20 on a surface of 20 by 20 without hitting the obstacle.The robot is considered as one pixel(1,1)initially. The obstacle is input to the program .How do i write a progarm in VB to find the obstacle free path.
Avatar of Gunsen
Gunsen

Sounds like homework.
You have to simulate (make the robot travel the path) and test if obstacle is in this route, pixel by pixel... :)
Avatar of krish006

ASKER

Yes it is a home work. I have cretaed the interface in VB.
I have generated a control array of command buttons for 20 by 20.
It is pixel to pixel movement. The robot is at pixel /block(1,1).We donot have to show how a robot looks , i mean no graphical robot. So i have made the (1,1) block green . 20,20 is the destination, i have that also green. The interface is designed like this: when form is loaded, whichever pixel the user clicks becomes black which means they are obstacles.So tehy obstacle can be rectangle, triangle or shaples. The problem is i dont know to program to move from 1,1 to 20,  20 avoiding obstacles on its way in VB. I think we have to check whether the next block/pixel is black before moving. But i dont know abt how to program this.
Please help me....
should i use select case statement in Vb ..
I mean case 1: go horizontal
case 2: diagonal
case 3: vertical
but how to write code to check every pixel before moving in VB
Please help me

There are numerous ways to do this.
Normally i would make an array like  Dim pixel(20,20) As Long (or 0-19).
This to have housekeeping information held in one array to be able to determine what is where and so on.

To move you could make an array of relative movements like:
Dim rx(3) As Long ,ry(3) As Long
rx(0)=-1:ry(0)=0 ' Left
rx(1)=0:ry(1)=-1 ' Up
rx(2)=1:ry(2)=0  ' Right
rx(3)=0:ry(3)=1  ' Down

To move:
x = x + rx(direction)
y = y + ry(direction)

Does this give u the clue....?
thanks , but if i create an array how do i check whether the pixel is black ot not...I dont know to check the color in VB.  all the obstacles command buttons are turned black when the user clicks on them. before moving to next cell i have to check the color and then proceed. How do i write code for this???
ASKER CERTIFIED SOLUTION
Avatar of Gunsen
Gunsen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial