Bascat
Bascat
Website of the robot Bascat for OS project 2018
A little video of Bascat in action
Here you can see Bascat scoring a ball in the basket and catching another ball
Our team
Julie BONNASSIEUX
Worked on positioning of the robot, discussion between threads, code organization and calibration
Pauline TRONCY
Worked on bluetooth communication, the launcher and clamp algorithm, calibration and code organization
Abbe AHMED-KHALIFA
Worked on code organization, robot architecture and detection
Jordan MEALLIER
Worked on website, robot architecture and robot construction
Architecture of Bascat
The architecture of Bascat consists of 4 motors and 3 sensors.
- Two motors are used for moving the two wheels
- One motor is used for the clamp to grab the ball and put the ball on the launcher
- The last motor is used for the laucher to send the ball in the basket
- An ultrasonic sensor is used to detect a ball and calculate the distance between a ball and the robot
- A color sensor to detect the ball on the launcher
- A gyroscope to get the position in real time
The Clamp
The clamp has two functions. The first one is to grab the ball and the second is to put the ball on the laucher.
The launcher
The launcher has to receive a ball from the clamp in the base. Then it sends the ball thanks to an arm leads by he motor. We had to change several times this architecture due to a lack of power of the motor.
The ultrasonic sensor
The ultrasonic sensor detects a ball that is in front of it. It gives the distance between the robot and the ball. It is placed just near to the clamp to facilitate the robot to grab the ball so he will just have to turn left and go forward to catch the ball.
The color sensor
The color sensor is placed just near to the launcher. It is able to know if a ball is on the laucher. Thus, the robot can know if a ball is present on the launcher or if it has fallen.
The gyroscope
The gyroscope sensor can measure the robot's rotational motion and changes in its orientation.
Competition
The goal is to win a basketball game by sending 4 balls in a basket.
Arena
There are 2 large areas, one for each competitor. On each large area, there is a starting area where the robot will begin the game. Then there is a front area where inside you can score 1 point by sending a ball in the basket and where outside of this area you can score 3 points.
Conduct of the competition
Each robot will have 4 minutes at most to score as many points as possible. It begins from the front area with 2 balls and 2 other balls are placed randomly. It will have to send the 2 first balls int the basket from the front area to score 1 points for each ball or outside the front area to score 3 points. Then it will have to detect the 2 others balls, collect them and send them in the basket.
Our Algorithm
Here are two schemas of how and where our robot detects the balls on the arena and sends it in the basket. First it scans in front of him, in the direction of A. If there is a ball, it catches the ball, goes back to the starting position and sends it in the basket. If there is no balls, it turns by 180° and scans in direction of C and does the same instructions if it finds a ball. Then it goes against the wall by going backwards and scans the orange side of the arena. If there is a ball, it does again the instructions to send the ball in the basket. If it doesn't find a ball, it turns back near A, goes ahead, scans the green side and does the same things if it finds a ball in this area. Then it scans the white area and the pink area with the same instructions if it finds a ball in.
Our Code
Our working code is actually quite easy to read. It stands in the "working code" repository of the GitLab, of which we will talk later. It is divided in four different files :
- function.c
In this file, we defined all the functions we will use during the game (before they get compiled). For example, it contains the "throw_the_ball.c" function, which makes the robot throw the ball from the starting area, or the "grab_the_ball.c" function, which grabs a ball and drops it in the launcher.
The file is itself divided into four parts :
the initialisation functions, the functions related to the server, the ones related to the ball manipulation, and the ones related to the robot's movement.
There, you can read in details what functions do. There is a short description of what a function should do above its definition.
- function.h
In this file, we declared and included all the needed global variables and libraries of the functions written in functions.c. Then, we declared all the functions of functions.c. It offers a good overview of all the functions we wrote, and use in the main.c file.
- main.c
This file contains our "strategy", that is to say it connects to a server through a socket and uses the functions written in functions.c and declared in functions.h in the game context.
- Makefile
This file is the shortest one, it is usefull for the compilation. First, it compiles all the *.c files to get their *.o equivalent. Then, it links them together (functions.o and main.o) to build the main executable file.
You can find all the programs we wrote on the GitLab (even the ones used as tests, or the out-of-date ones). More precisely, the working code we described above stands in the repository named "working code". The "a_mid_tests" repository contains the functions dropping/throwing the ball from the wall/front/back area in the basket (respectively tests 1, 2, 3).
The "a_color_progs" concerns some tests with the color sensor, and the a_ball_progs contains some tests concerning interactions with the ball.
If you want to use our code, on just need to download it on your machine. For example, if you want to use it all, just download the "working code" repository. Then, in a terminal, run "make" in it. It will create all the needed files.Finally, to run the code, enter the "./main" command line in this same terminal.
However, remember that our code has been written for a specific game, in which the robot connects to a server (whose code isn't given here), so you might meet some difficulties using it.
Anyway, if you use some material we wrote, please do not forget to mention where you found it !
Special thanks to Ludovic APVRILLE and Matteo BERTOLINO for their help for this project.