View unanswered posts | View active topics It is currently Sat Oct 25, 2014 9:04 pm






Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Lego Two-Dimensional Array 
Author Message
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Lego Two-Dimensional Array
Dear,
i want to make a Two-Dimensional Array for Lego,
i want to make a path planning to avoid the obstacles and find the shorter path in a map

how to create this program?

thanks in advance
best regards


Tue Apr 09, 2013 7:49 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Lego Two-Dimensional Array
I can help you with the array but you're on your own with the other thing. Good luck though!

Code:
int array[10][10];


= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Apr 09, 2013 9:23 am
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: Lego Two-Dimensional Array
thanks bro, i will start the project with this


Tue Apr 09, 2013 12:06 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Lego Two-Dimensional Array
Good start but I think you're likely to need a bit more code to get the whole thing working :)

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Apr 09, 2013 12:23 pm
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: Lego Two-Dimensional Array
i have one square 5X5,
any square 25cm
so the big square is 125X125 cm
how to define this in a two dimensional array?


Attachments:
PathPlanning.png
PathPlanning.png [ 25.96 KiB | Viewed 4785 times ]
Fri May 10, 2013 7:56 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Lego Two-Dimensional Array
You could make obstacles to be -1
Code:
int maze[][] = {{10, 9, 8, 7, 8},
{11, 10, -1, 6, 7},
{-1, -1, -1, 5, 6},
{1, 2, -1, 4, 5}
{0, 1, 2, 3, 4}};


= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri May 10, 2013 8:37 am
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: Lego Two-Dimensional Array
thanks a lot bro


Fri May 10, 2013 9:07 am
Profile
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: Lego Two-Dimensional Array
another one question bro, how to define the start point and end point?


Fri May 10, 2013 5:06 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Lego Two-Dimensional Array
Well, that depends, do you know before you start the robot where the start and finish are? How does your robot distinguish the tiles? Or do you already know "I start here and I finish there"?

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat May 11, 2013 1:03 am
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: Lego Two-Dimensional Array
i want to give the start point and the end point and found the shorter path and avoid obstacles
for found the obstacles i will use the sonar sensor
but i don't know how to define start and end point


Sat May 11, 2013 3:17 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Lego Two-Dimensional Array
You should have a look to see how others have implemented this in C. Also take a look here:
http://www.mcs.alma.edu/LMICSE/LabMater ... lgCoL4.htm
http://www.me.iitb.ac.in/~adeshmukh/floodfill.php

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat May 11, 2013 3:29 am
Profile WWW
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: Lego Two-Dimensional Array
Dear,
i want only to move from one point to other point,
is it easy?

thanks in advance
best regards


Mon Jun 03, 2013 5:51 pm
Profile
Expert
User avatar

Joined: Fri Nov 02, 2012 12:07 am
Posts: 164
Location: California, USA
Post Re: Lego Two-Dimensional Array
mightor wrote:
I can help you with the array but you're on your own with the other thing. Good luck though!

Code:
int array[10][10];


= Xander



I didn't know that that was possible!!!! :shock: :eek:

_________________
string Robored = "Awesome"
~~Neil Balch~~


Mon Jun 03, 2013 7:43 pm
Profile WWW
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: Lego Two-Dimensional Array
Just a quick interjection:
I've read of the wavefront method multiple times; is it the only method? It's always mentioned as the most primitive, so surely there must be better ones :)

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Mon Jun 03, 2013 9:34 pm
Profile
Novice

Joined: Wed Feb 20, 2013 2:46 am
Posts: 64
Post Re: Lego Two-Dimensional Array
can you help me with robotC code?

my instructor give me some code's parts and i implemented an algorithm but not working

Code:
#pragma config(Sensor, S4,     sonarSensor,    sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

int  M[25][25];
int  V[25][25];
int maxx = 24;
int maxy = 24;
int Gx, Gy, x, y;
int goal, Sx, Sy;

//Assign sequencial values in the value array
void assignvalues(){
  bool check = false;

  while (check == false){
       for (y=Gy; y>=0; y--){
          for (x=Gx; x<=maxx; x++){
               if (((y-1)>=0) && (M[x][y-1]!=1) && ((V[x][y]+1)<V[x][y-1]))
                  V[x][y-1] = V[x][y] + 1;

            if (((x-1)>=0) && (M[x-1][y]!=1) && ((V[x][y]+1)<V[x-1][y]))
              V[x-1][y] = V[x][y] + 1;

            if (((y+1)<=maxy) && (M[x][y+1]!=1) && ((V[x][y]+1)<V[x][y+1]))
              V[x][y+1] = V[x][y] + 1;

            if (((x+1)<=maxx) && (M[x+1][y]!=1) && ((V[x][y]+1)<V[x+1][y]))
              V[x+1][y] = V[x][y] + 1;
           }

          for (x=Gx-1; x>=0; x--){
            if (((y-1)>=0) && (M[x][y-1]!=1) && ((V[x][y]+1)<V[x][y-1]))
              V[x][y-1] = V[x][y] + 1;

            if (((x-1)>=0) && (M[x-1][y]!=1) && ((V[x][y]+1)<V[x-1][y]))
              V[x-1][y] = V[x][y] + 1;

            if (((y+1)<=maxy) && (M[x][y+1]!=1) && ((V[x][y]+1)<V[x][y+1]))
              V[x][y+1] = V[x][y] + 1;

            if (((x+1)<=maxx) && (M[x+1][y]!=1) && ((V[x][y]+1)<V[x+1][y]))
              V[x+1][y] = V[x][y] + 1;
          }
        }

       for (y=Gy+1; y<=maxy; y++){
          for (x=Gx; x<=maxx; x++){
            if (((y-1)>=0) && (M[x][y-1]!=1) && ((V[x][y]+1)<V[x][y-1]))
              V[x][y-1] = V[x][y] + 1;

            if (((x-1)>=0) && (M[x-1][y]!=1) && ((V[x][y]+1)<V[x-1][y]))
              V[x-1][y] = V[x][y] + 1;

            if (((y+1)<=maxy) && (M[x][y+1]!=1) && ((V[x][y]+1)<V[x][y+1]))
              V[x][y+1] = V[x][y] + 1;

            if (((x+1)<=maxx) && (M[x+1][y]!=1) && ((V[x][y]+1)<V[x+1][y]))
              V[x+1][y] = V[x][y] + 1;
          }

          for (x=Gx-1; x>=0; x--){
            if (((y-1)>=0) && (M[x][y-1]!=1) && ((V[x][y]+1)<V[x][y-1]))
              V[x][y-1] = V[x][y] + 1;

            if (((x-1)>=0) && (M[x-1][y]!=1) && ((V[x][y]+1)<V[x-1][y]))
              V[x-1][y] = V[x][y] + 1;

            if (((y+1)<=maxy) && (M[x][y+1]!=1) && ((V[x][y]+1)<V[x][y+1]))
              V[x][y+1] = V[x][y] + 1;

            if (((x+1)<=maxx) && (M[x+1][y]!=1) && ((V[x][y]+1)<V[x+1][y]))
              V[x+1][y] = V[x][y] + 1;
          }
        }
        check = true;
        for(int j=0;j<=maxy;j++)
           for(int i=0;i<=maxx;i++)
             if ((M[i][j]!=1) && (V[i][j]==-1)) //-1:obstacle
               check = false;
  }

}

}
task main()
{
  int i, j;

  //Assign values in the Main array
   for(j=0;j<=maxy;j++){
     for(i=0;i<=maxx;i++){
       M[i][j] = 1;
     }
  }

  M[1][0] = 0;
  M[2][0] = 0;
  M[3][0] = 0;
  M[4][0] = 0;
  M[5][0] = 0;
 
  M[2][1] = 0;
  M[3][1] = 0;
  M[4][1] = 0;
  M[5][1] = 0;
  M[6][1] = 0;
 

  for (i=3; i<25; i++){
     M[i][2] = 0;}

  for (i=3; i<25; i++){
     M[i][3] = 0;}

  for (i=3; i<25; i++){
     M[i][4] = 0;}

  for (i=3; i<25; i++){
     M[i][5] = 0;}

  for (i=3; i<25; i++){
     M[i][6] = 0;}
   M[1][6] = 0;
   M[2][6] = 0;

   for (i=3; i<25; i++){
      M[i][7] = 0;}
   M[1][7] = 0;
   M[2][7] = 0;
   for (i=3; i<25; i++){
      M[i][7] = 1;}

    M[1][8] = 0;
    M[2][8] = 0;
   for (i=3; i<25; i++){
      M[i][8] = 0;}
   for (i=3; i<25; i++){
     M[i][8] = 1;}

   for (i=3; i<25; i++){
      M[i][9] = 0;}
   for (i=3; i<25; i++){
      M[i][9] = 0;}
  M[22][9] = 0;
   M[23][9] = 0;

   for (i=3; i<25; i++){
      M[i][10] = 0;}

    M[24][10] = 0;
    M[25][10] = 0;

    M[2][11] = 0;
    M[3][11] = 0;
    M[4][11] = 0;

    M[3][12] = 0;
    M[4][12] = 0;

   

   for (i=3; i<25; i++){
      M[i][13] = 0;}

   for (i=3; i<25; i++){
      M[i][14] = 0;}

   for (i=3; i<25; i++){
      M[i][15] = 0;}

   for (i=3; i<25; i++){
      M[i][16] = 0;}

   for (i=22; i<28; i++){
      M[i][17] = 0;}

    //Reset the values in the Value array
    for (j=0; j<=maxy; j++)
      for (i=0; i<=maxx; i++)
        V[i][j] = -1;

    V[Gx][Gy] = 0;

   Gx=25;
   Sx=1;
   
  // Move forward until 7 cm from the wall.
    while (SensorValue(sonarSensor) > 7)
    {
        motor[motorA] = 10;
        motor[motorC] = 10;
    }

   // go backward
    motor[motorA] = -6;
    motor[motorC] = -6;
    wait1Msec(5000); // stop in 5 seconds
 }


Tue Jun 04, 2013 7:11 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 27 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.