View unanswered posts | View active topics It is currently Tue May 21, 2013 4:43 am

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
aStar (a-star, A-Stern) Algorithm for NXT: TamTam.c
Author Message
Senior Roboticist

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 936
Location: a small planet in the vicinity of Beteigeuze
aStar (a-star, A-Stern) Algorithm for NXT: TamTam.c
hi everyone,
here's my a-star for NXT to solve navigation in labyrinths - or simply in your living rooms.
It uses an a-star algorithm, modified by Dijkstra (the estimated distance to destination is always =0; this simplifies the node structure, enlarges the possible size of the map and excelerates the execution speed).

This is a "virtual solution"; in future this file will be added to the Navigation project (algorithm is to be enclosed to navigator.h file, see different thread).

_________________
Ford Prefect

Never purchase release 1.x ! (ancient programmer's wisdom)
"Don't argue with idiots. They'll drag you down to their level and then beat you with experience."

Last edited by Ford Prefect on Sat Mar 22, 2008 2:08 pm, edited 1 time in total.

Sun Mar 16, 2008 12:00 pm
Senior Roboticist

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 936
Location: a small planet in the vicinity of Beteigeuze

(You'll need in addition the file RobotC+.h, see below)

_________________
Ford Prefect

Never purchase release 1.x ! (ancient programmer's wisdom)
"Don't argue with idiots. They'll drag you down to their level and then beat you with experience."

Last edited by Ford Prefect on Sat Apr 19, 2008 2:59 pm, edited 19 times in total.

Sat Mar 22, 2008 2:08 pm
Senior Roboticist

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 936
Location: a small planet in the vicinity of Beteigeuze

this is an additional file which is included and needed for some variable definitions a.s.o.:
 Code:///////////////////////////////////////////////////////////////////////// RobotC+.h - damit's ein bisserl einfacher wird...    ;-)          //// Version 0.5.8/////////////////////////////////////////////////////////////////////////===================================================================// mathematische Konstanten und Funktionen//===================================================================// Eulersche Zahl E:const float E=2.718281828450945235360287471352662497757247093699959574966967627724076630353547594571;//********************************************int  min(int a, int b){   int m;   m=(ab ? a:b);   return m;}//********************************************float max(float a, float b){   float m;   m=(a>b ? a:b);   return m;}//********************************************int round(float f){  if(f>0) return (int)(f + 0.5);  else    return (int)(f - 0.5);}//********************************************// ArcusTangens mit Sonderfaellen; Angabe in Grad!// x=Ankathete y=Gegenkathete Tangens=y/xfloat atan2Degrees(float x, float y){  float phi, alpha; //phi=Bogenmass, alpha=Grad;   if (x>0) {phi=atan(y/x);}   else   if ((x<0)&&(y>=0))  {phi=PI+atan(y/x);}   else   if ((x<0)&&(y<0))   {phi=-PI+atan(y/x);}   else   if ((x==0)&&(y>0))  {phi=PI/2;}   else   if ((x==0)&&(y<0))  {phi=-PI/2;}   else   if ((x==0)&&(y==0)) {phi=0;}   alpha=radiansToDegrees(phi);   return alpha;}//********************************************bool IsInRange(int Wert, int Basis, int Toleranz){   return((Wert>=Basis-Toleranz) && (Wert<=Basis+Toleranz));}//===================================================================// Prozeduren fuer Sensoren//===================================================================bool SMuxPressed(int port, byte ch) // MUX-Port an NXT (S1, S2,... ) // ch: 0=direkt, 1=ch1, 2=ch2, 3=ch3{  int v;   bool pressed;   v=SensorValue(port);   if (ch==0)   { pressed=(v<100 ); }   else  if (ch==1)   { pressed=( IsInRange(v,775,30) || IsInRange(v,523,25) || IsInRange(v,343,8)   || IsInRange(v,275,8)) ; }  else   if (ch==2)   { pressed=( IsInRange(v,620,40) || IsInRange(v,523,25) || IsInRange(v,295,8)   || IsInRange(v,275,8)) ; }  else   if (ch==3)   { pressed=( IsInRange(v,363,15) || IsInRange(v,343,8)  || IsInRange(v,295,8)   || IsInRange(v,275,8)) ; }  return pressed;// Wertetabelle fuer Sensor-Muxer (natuerlich Bauform-abhaengig)//*************************************************************////  rcx ch3 ch2 ch1     raw       // RCX-WiderstMux als sensorRawValue definiert//   0   0   0   0     1023       // an 3 Mux-Einaenge UND direktan rcx-Eingang//   0   0   0   1      775       // je 1 Taster angeschlossen//   0   0   1   0      620//   0   0   1   1      523//   0   1   0   0      363//   0   1   0   1      343//   0   1   1   0      295//   0   1   1   1      275//   1   0   0   0       79        // ab hier die Werte, wenn der//   1   0   0   1       64        // 4. Taster direkt am rcx-Sensor-Eingang//   1   0   1   0       74        // gedrueckt wird.//   1   0   1   1       70        // Eine Unterscheidung, ob dann auch//   1   1   0   0       69        // gleichzeitig  noch andere Taster//   1   1   0   1       55        // zusaetzlich gedrueckt sind,//   1   1   1   0       55        // ist dann kaum mehr moeglich.//   1   1   1   1       55        //}//===================================================================// globale Prozeduren fue Motor-Steuerung//===================================================================void  motSync (int m, int s) // setzt Sync-Master & Slave{   if ((m==0) && (s==0))   { nSyncedMotors = synchNone;}   else   if ((m==0) && (s==1))   { nSyncedMotors = synchAB;}   else   if ((m==0) && (s==2))   { nSyncedMotors = synchAC;}   else   if ((m==1) && (s==0))   { nSyncedMotors = synchBA;}   else  if ((m==1) && (s==2))   { nSyncedMotors = synchBC;}   else  if ((m==2) && (s==0))   { nSyncedMotors = synchCA;}   else  if ((m==2) && (s==1))   { nSyncedMotors = synchCB;}   else nSyncedMotors = synchNone;}//===================================================================//===================================================================

_________________
Ford Prefect

Never purchase release 1.x ! (ancient programmer's wisdom)
"Don't argue with idiots. They'll drag you down to their level and then beat you with experience."

Sat Mar 22, 2008 2:38 pm
Rookie

Joined: Sat Jan 10, 2009 6:26 pm
Posts: 14
Re: aStar (a-star, A-Stern) Algorithm for NXT: TamTam.c
Nice, i phink it was what i was looking for, in the future i will tell if this works for me. Meanwhile thanks for the help.

Mon Nov 09, 2009 7:22 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions    Robotics Merit Badge Robotics Discussions    General Discussions    Project Discussions International Forums    Spanish Forums       ROBOTC for MINDSTORMS       ROBOTC for VEX    French Forums       ROBOTC pour Mindstorms       ROBOTC pour IFI VEX    Japanese Forums （日本語のフォーラム） Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC