Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
378572e
structure of projects folders
bmarid Dec 8, 2022
14feabf
fill the matrix
bmarid Dec 29, 2022
5e2769b
Merge pull request #3 from bmarid/mari
bmarid Dec 29, 2022
de8f9b2
path x,y
bmarid Dec 29, 2022
a55390a
Merge pull request #5 from bmarid/mari
bmarid Dec 29, 2022
d6d6b2b
Merge pull request #10 from bmarid/dev
halaalbahloul Dec 29, 2022
88d58f0
Navigation, movment functions, detecting obstacles
halaalbahloul Dec 29, 2022
149387c
Merge pull request #11 from bmarid/hala
halaalbahloul Dec 29, 2022
eda9498
Create Arduino Python
andreeastroia Jan 2, 2023
cc2bc2f
Create Arduino C
andreeastroia Jan 2, 2023
faf03fa
Rename Arduino Python to A* algorithm Python
andreeastroia Jan 2, 2023
2036a1b
Rename Arduino C to A* algorithm C
andreeastroia Jan 2, 2023
9174dc3
Add files via upload
andreeastroia Jan 2, 2023
be6b940
Final movment with delay
halaalbahloul Jan 2, 2023
5bc3a60
Merge pull request #16 from bmarid/dev
bmarid Jan 2, 2023
0f01360
Merge pull request #17 from bmarid/hala
bmarid Jan 2, 2023
2a76faf
Merge pull request #18 from bmarid/dev
bmarid Jan 2, 2023
5e19153
Merge pull request #19 from bmarid/mari
bmarid Jan 2, 2023
c0895fa
1 version
bmarid Jan 2, 2023
67cdc64
Merge pull request #21 from bmarid/mari
bmarid Jan 2, 2023
c440acf
Merge pull request #35 from bmarid/dev
bmarid Jan 2, 2023
3e6ae68
Merge pull request #36 from bmarid/dev
bmarid Jan 2, 2023
638e245
cleaning
bmarid Jan 2, 2023
2022d7d
Merge pull request #38 from bmarid/mari
bmarid Jan 2, 2023
0f5d9c2
Merge pull request #40 from bmarid/dev
bmarid Jan 2, 2023
9e939d5
Update full_workable_version_1.ino
halaalbahloul Jan 2, 2023
0cb0aeb
Use millis for movment
halaalbahloul Jan 2, 2023
ee3a218
Cleaning
halaalbahloul Jan 3, 2023
613ec59
Add flowcharts of program movement
halaalbahloul Jan 3, 2023
52e01c1
Merge pull request #42 from bmarid/hala
halaalbahloul Jan 3, 2023
9379116
Update components.md
halaalbahloul Jan 5, 2023
c7600e2
Update components.md
halaalbahloul Jan 5, 2023
9c6839a
Create resources.md
halaalbahloul Jan 5, 2023
7d98ec5
Update resources.md
halaalbahloul Jan 5, 2023
2aa1bf0
Update algorithm.md
halaalbahloul Jan 5, 2023
5c0cd98
Update algorithm.md
halaalbahloul Jan 5, 2023
2d02de5
Update full_workable_version_1.ino
halaalbahloul Jan 5, 2023
45a5449
Update movment_with_millis.ino
halaalbahloul Jan 5, 2023
5ecf640
Merge pull request #44 from bmarid/hala
halaalbahloul Jan 5, 2023
4f1eca9
Merge pull request #46 from bmarid/dev
andreeastroia Jan 5, 2023
fe7d58f
Update components.md
andreeastroia Jan 5, 2023
6d953c4
Merge pull request #47 from bmarid/andreea
andreeastroia Jan 5, 2023
8558dd5
Update components.md
andreeastroia Jan 5, 2023
533de33
Update components.md
andreeastroia Jan 5, 2023
6c37138
Merge pull request #48 from bmarid/andreea
andreeastroia Jan 5, 2023
2afea1c
Update resources.md
andreeastroia Jan 5, 2023
81882a2
Merge pull request #49 from bmarid/dev
andreeastroia Jan 5, 2023
586262e
Update components.md
andreeastroia Jan 5, 2023
ede04e5
Update algorithm.md
andreeastroia Jan 5, 2023
510dfd6
Merge pull request #50 from bmarid/andreea
andreeastroia Jan 5, 2023
37223b2
Update algorithm.md
andreeastroia Jan 5, 2023
bb92732
Merge pull request #52 from bmarid/andreea
andreeastroia Jan 5, 2023
8667f53
Merge pull request #53 from bmarid/dev
andreeastroia Jan 5, 2023
b6c62aa
Create test
andreeastroia Jan 5, 2023
58b649d
Add files via upload
andreeastroia Jan 5, 2023
0e80026
Add files via upload
andreeastroia Jan 5, 2023
b7ede7e
Delete test
andreeastroia Jan 5, 2023
c9eafed
Update Astar_Python.py
andreeastroia Jan 5, 2023
691120a
Update algorithm.md
andreeastroia Jan 5, 2023
32afea9
Update components.md
andreeastroia Jan 5, 2023
5d0eea1
Update README.md
andreeastroia Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ This is the repository of the [LPI](https://www.learningplanetinstitute.org/en),
* Team formation + Ideation report
* Project week - Project mainly focusing on solving the challenge while addressing odometry or kinematics problems. Implementation of your own algorithm to optimise the results.

## General Algorithm

![WhatsApp Image 2023-01-05 at 02 10 01](https://user-images.githubusercontent.com/113441374/211695876-3de23d4a-08ad-44cb-9595-b7b99a7c9578.jpg)

## A* Algorithm

![image](https://user-images.githubusercontent.com/113441374/211696021-2a777b58-28ab-4869-af80-ab5d695bcebe.png)


# Mini project guide
Fork this repository and add your team members as collaborators to your fork. Make sure it is a public repository.

Expand Down
Binary file added lib/Flowchart_Astar algorithm.pdf
Binary file not shown.
73 changes: 73 additions & 0 deletions lib/algorithm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Algorithm
## Path finding and A*

#### A* is a graph traversal and path search algorithm. Starting from a specific starting node of a graph, it aims to find apath to the given goal node having the smallest cost

We are going to take this grid as an example:

![image](https://user-images.githubusercontent.com/113441374/210691268-29917a55-1359-42c9-96c4-0a360b14ac95.png)


The grid has a start point, an end point and obstacles

- First, it checks for neighbours. Because our robot can move up,
down, right or left, it checks for the neighbour that has
smallest cost.

- The smallest cost, f is the sum of g and h, where:
- g = the movement cost to move from the starting point to a given
square on the grid, following the path generated to get there
- h = the estimated movement cost to move from that given square on the grid to
the final destination

- At each iteration, the f value is calculated

- It keeps track of the paths originating from the start node

- The algorithm is extending the paths one grid cell at a time until its termination criterion is satisfied, which is meeting the end node

## The steps involved in implementation of A*

- Specifying the start and end node

- Creating an open list to store all the nodes that can be taken into account when calculating the path

- Creating a closed list that stores all the nodes that have been visited

- We start with the start node and check its children (up, down, left and right)

- We check if the children are in the maze boundaries, if the identify as an obstacle, or if they were already visited. If they meet any of these requirements, then we skip to the next child and do not calculate the f value, nor assign it to the open list. Otherwise, we calculate the g and h cost that form the final f.

- We then check for the child with the lowest f and make this child the current node. We also append it to the closed list to form the path later

- The iteration continues until the current node will have the same x and y positions as the end node.

- The path will be returned taken into account the parents of the nodes. The path is calculated backwards, starting with the end point and tracing back the parents accordingly.

## Flowchart of A* algorithm

![image](https://user-images.githubusercontent.com/113441374/210694023-ff1081c1-a971-48b0-8659-01b11a468859.png)


## Movment

## Test the front

![WhatsApp Image 2023-01-05 at 09 25 47](https://user-images.githubusercontent.com/113441374/210738497-08524a0e-cebb-4d09-93bc-6667d08010e6.jpg)

## frontOpen

![WhatsApp Image 2023-01-05 at 09 25 48](https://user-images.githubusercontent.com/113441374/210738582-f55d6433-0d8e-457a-8c01-411f206d52bc.jpg)

## Go Forward

![WhatsApp Image 2023-01-05 at 09 25 48](https://user-images.githubusercontent.com/113441374/210738674-e10dde17-e0c5-458c-9e5b-c02088b8faa9.jpg)

## Turn left

![WhatsApp Image 2023-01-05 at 09 25 47](https://user-images.githubusercontent.com/113441374/210738742-470fb530-3c18-4797-bcde-74f7c72a3066.jpg)


### General Algorithm of movment

![WhatsApp Image 2023-01-05 at 02 10 02](https://user-images.githubusercontent.com/113441374/210738268-da515aec-b926-45a1-8071-9e2a88f34c6f.jpg)
35 changes: 35 additions & 0 deletions lib/ideation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Ideation Report Template

Project Name: Robot MHA

Team: CRI project Link https://github.com/bmarid/robotics_course_2022

Mariia Bai, Andreea Stroia, Hala Albahloul

1. Introduction : what do you want to do
Path planning robot. (8*8, 1 cell - 51 sm)

2. Algorithm / Bibliography
A* algorithm

3. How you will solve this problem
Code the map, Recognise obstacles, recalculate path, using A* algorithm.

4. Expected List of Features
Code a Map
Recognise obstacles
Change/recalculate best path

5. List of equipment needed (if we need to buy)
Arduino uno
H-bridge
Ultrasonic sensor
DC-motors
Jumpers
Battery
Robot pieces
Wheels

6. References
https://www.youtube.com/watch?v=6TsL96NAZCo

Binary file added lib/images/forward.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/images/front_open.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/images/general_movment_algorithm.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/images/left.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/images/test_front.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions lib/resources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Resources

### Using L298N Dual H-Bridge to control of DC motors:
https://dronebotworkshop.com/dc-motors-l298n-h-bridge/

### Using Ultrasonic sensor:
https://www.maxbotix.com/articles/how-ultrasonic-sensors-work.htm

### A* Algorithm
https://www.youtube.com/watch?v=-L-WgKMFuhE&t=331s

https://www.youtube.com/watch?v=6TsL96NAZCo

https://www.geeksforgeeks.org/a-search-algorithm/

55 changes: 55 additions & 0 deletions lib/schematics/components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Circuit and Schematics
## 1. Circuit
![Copy of H-bridge motor driver](https://user-images.githubusercontent.com/113441374/210682973-18f31141-829d-4f7e-8ea8-1e3abdd9150d.png)


## 2. Components
- Arduino Uno.

![image](https://user-images.githubusercontent.com/113441374/210687728-327f0895-2ed0-4d82-b56c-b8b7f33a53a9.png)


- L298N Dual H-bridge.

- HC-SR04 Ultrasonic sensor.

- 2 DC motors.

![image](https://user-images.githubusercontent.com/113441374/210687852-0bfac715-8339-416a-8b22-6e41a906753c.png)

- Battery 6v.

![image](https://user-images.githubusercontent.com/113441374/210688150-caf0acda-b1c5-4c2b-9200-30cf57a4ed8c.png)


- BreadBoard.

![image](https://user-images.githubusercontent.com/113441374/210687993-6f0da085-5ee1-4233-a764-671feb3f4a3c.png)

- Wires.

- ### L298N Dual H-bridge

![WhatsApp Image 2023-01-05 at 01 37 36](https://user-images.githubusercontent.com/113441374/210739374-1c4d257d-d582-4194-8653-66b8e8871443.jpg)

An H-bridge is a simple circuit that lets you control a DC motor to go backward or forward.

Changing the polarity of the power supply to DC motor is used to change the direction of rotation.
Apart from changing the rotation direction, the H-bridge can provide additional operation modes, "brake" and "free run until frictional stop". The H-bridge arrangement is generally used to reverse the polarity/direction of the motor, but can also be used to 'brake' the motor, where the motor comes to a sudden stop, as the motor's terminals are shorted

- ### HC-SR04 Ultrasonic sensor

![image](https://user-images.githubusercontent.com/113441374/210739285-c5b838a6-2a18-4c3e-858f-190f58706721.png)

Ultrasonic sensors work by emitting sound waves at a frequency too high for humans to hear. then wait for the sound to be reflected back, calculating distance based on the time required.
calculated based on this formula: Distance = ½ T x C

T = Time and C = the speed of sound

![WhatsApp Image 2023-01-05 at 01 28 59](https://user-images.githubusercontent.com/113441374/210690752-99c998a2-366d-4235-aff9-a494c9369873.jpg)

![WhatsApp Image 2023-01-05 at 01 29 23](https://user-images.githubusercontent.com/113441374/210690803-d6ab0ac6-a0ac-416a-95bb-29af6868a3ea.jpg)




183 changes: 183 additions & 0 deletions src/A* algorithm C
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#include <stdio.h>
#include <stdlib.h>

//Defining the start and end nodes
int start_x =1;
int start_y=0;
int end_y=5;
int end_x=9;

//Creating a struct to store all the nodes that the robot can take

typedef struct {
int x; //position of x
int y; //position of y
double f;
double g;
double h;
}Node;

typedef struct{
Node info;
struct List_node* next;
}List_node;


// Creating a simple list to store the nodes

List_node* creation(List_node* new_node, List_node* startnode, Node node, List_node* endnode) {

new_node->info.x = node.x;
new_node->info.y = node.y;
new_node->info.g = abs((new_node->info.x - startnode->info.x) + (new_node->info.y - startnode->info.y));
new_node->info.h = abs((new_node->info.x - endnode->info.x) + (new_node->info.y - endnode->info.y));
new_node->info.f = new_node->info.g + new_node->info.h;

return new_node;
}

//Creating a function to insert new nodes

List_node* inseration(List_node* startnode, Node node, List_node* endnode)
{
List_node* new_node = (List_node*)malloc(sizeof(List_node));
new_node = creation(new_node, startnode, node, endnode);

if (startnode)
{
List_node* aux = startnode;
while (aux->next)
aux = aux->next;
aux->next = new_node;
}
else
startnode = new_node;

int min = 10000;
int count = 0;

//Allocating memory for the new nodes the robot can take
//It can go left, right, down and up
List_node* left_node = (List_node*)malloc(sizeof(List_node));
List_node* up_node = (List_node*)malloc(sizeof(List_node));
List_node* right_node = (List_node*)malloc(sizeof(List_node));
List_node* down_node = (List_node*)malloc(sizeof(List_node));

//The robot goes left
if(node.x > 0) { //
Node nodeLeft;
nodeLeft = node;
nodeLeft.x = node.x - 1;
left_node = creation(left_node, startnode, nodeLeft, endnode);
if(left_node->info.f < min)
{
min = left_node->info.f;
count = 4;
}
}

//The robot goes uo
if(node.y > 0) {
Node nodeUp;
nodeUp = node;
nodeUp.y = node.y + 1;
up_node = creation(up_node, startnode, nodeUp, endnode);
if(up_node->info.f < min)
{
min = up_node->info.f;
count = 1;
}
}

//The robot goes right
if(node.x < 7) {
Node nodeRight;
nodeRight = node;
nodeRight.x = node.x + 1;
right_node = creation(right_node, startnode, nodeRight, endnode);
if(right_node->info.f < min)
{
min = right_node->info.f;
count = 2;
}
}

//The robot goes down
if(node.y < 7) {
Node nodeDown;
nodeDown = node;
nodeDown.y = node.y - 1;
down_node = creation(down_node, startnode, nodeDown, endnode);
if(down_node->info.f < min)
{
min = down_node->info.f;
count = 3;
}
}

//The robot goes up
if(count == 1) {
new_node->next = up_node;
} else if (count == 2) {
new_node->next = right_node;
} else if (count == 3) {
new_node->next = down_node;
} else {
new_node->next = left_node;
}

if(new_node->info.x != end_x && new_node->info.y != end_y)
return startnode;
else
inseration(startnode, node, endnode);
}

void path(List_node* head)
{
List_node* aux = head;
while (aux)
{
printf("\n(%d, %d) ",
aux->info.x, aux->info.y);
aux = aux->next;
}
}

void main()
{
//Initializing the end node

List_node *Endnode;
Endnode->info.x = end_x;
Endnode->info.y = end_y;
Endnode->info.g = 0;
Endnode->info.h = 0;
Endnode->info.f = 0;
Endnode->next = NULL;

int maze[8][8] =
{{0, 0, 1, 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0}};

for(int i = 0; i < 8; i++)
for(int j = 0; j < 8; j++) {

List_node *Startnode;
Node node;
node.x = start_x;
node.y = start_y;
node.g = 0;
node.h = 0;
node.f = 0;
Startnode->info = node;
Startnode->next = NULL;

Startnode = inseration(Startnode, node, Endnode);
}
}
Loading