Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed X_NUCLEO_IHM02A1
chemin.h
00001 #ifndef CHEMIN_H 00002 #define CHEMIN_H 00003 // C code to implement Priority Queue 00004 // using Linked List 00005 // https://www.geeksforgeeks.org/priority-queue-using-linked-list/ 00006 00007 // C code for path fining 00008 // https://github.com/AtsushiSakai/PythonRobotics 00009 00010 //Exemple: 00011 /* 00012 int vitesse_deplacement = 200; 00013 00014 calc_distances(20,180,270,180); //x_départ , y_arrivée , x_arrivée, y_arrivée 00015 Node* commandes = (Node*)malloc(sizeof(Node)); 00016 commandes = traduction_points_commandes(trouver_chemin(20,180,270,180)); 00017 while(!isEmpty(&commandes)){ 00018 int angle,distance_avancement_cm,_ = 0; 00019 peek(&commandes,&angle,&distance_avancement_cm,&_); //on recupere les infos du point 00020 pop(&commandes); 00021 printf("rotation %d, avancement de %d\n",angle,distance_avancement_cm); 00022 if(distance_avancement_cm != 0 && angle != 0) { 00023 test_ligne_droite(10*distance_avancement_cm, vitesse_deplacement); 00024 test_rotation_rel(angle,vitesse_deplacement); 00025 } 00026 } 00027 */ 00028 00029 00030 #include <stdio.h> 00031 #include <stdlib.h> 00032 #include <time.h> 00033 00034 00035 00036 00037 // Node 00038 typedef struct node { 00039 int x; 00040 int y; 00041 int distance; 00042 00043 // Lower values indicate higher priority 00044 int priority; 00045 00046 struct node* next; 00047 00048 } Node; 00049 00050 // Function to Create A New Node 00051 Node* newNode(int x , int y, int distance, int p); 00052 00053 // Return the value at head 00054 void peek(Node** head, int*x, int*y, int*distance); 00055 00056 // Removes the element with the 00057 // highest priority form the list 00058 void pop(Node** head); 00059 00060 // Function to push according to priority 00061 void push(Node** head, int x, int y, int distance, int p); 00062 00063 // Function to check is list is empty 00064 int isEmpty(Node** head); 00065 00066 00067 void calc_distances(int ox, int oy, int gx , int gy); //ogigine, goal 00068 00069 Node* trouver_chemin(int ox, int oy, int gx , int gy); //retourne une suite de points , du point de départ au point d'arrivé en évitant les obstacles 00070 00071 Node* traduction_points_commandes(Node* pq); 00072 00073 void afficher_terrain(); 00074 void afficher_terrain(Node* commandes); 00075 00076 int conversion_codage_angles(int o); 00077 00078 00079 void aller_a_point(int ox , int oy, int gx , int gy , int vitesse_deplacement = 100); 00080 00081 #endif 00082 00083
Generated on Sun Jul 17 2022 20:58:42 by
1.7.2