Robot Principal 26
Documentation du Club Robot INSA Rennes 2026
Chargement...
Recherche...
Aucune correspondance
SensorArray.h
1//
2// Created by romain on 5/18/25.
3//
4
5#ifndef SENSORARRAY_H
6#define SENSORARRAY_H
7
8#include <Arduino.h>
9#include <Wire.h>
10
11#include "../../Wheeledbase/include/Components/Odometry.h"
12#include "Logger.h"
13#include "Types.h"
14#include "Wheeledbase.h"
15#include "uld/include/VL53L5CX.h"
16
17#define MASTER_ADDRESS 0x01
18
19#define SENSORARRAY_MAX 8
20//Number of millis between two frames at 10Hz
21#define SENSORARRAY_SENSOR_TIMEOUT (1/10*1000)c
22#define SENSORARRAY_RESOLUTION VL53L5CX_RESOLUTION_8X8
23
24#define X_FROM_1D(i) (uint8_t) floor(i / 8.00)
25#define Y_FROM_1D(i) (uint8_t) (i % 8)
26
27#define X_Y_FOR_LOOP uint8_t x = 0, y = 0; x < 8 && y < 8; y = (y + 1) % 8, x += y ? 0 : 1
28
29//Sensors positions in the frame
30#define SENSORARRAY_FRAME_RADIUS 38.2
31#define SENSORARRAY_FRAME_Z 70.8
32#define SENSORARRAY_ROOF_Z 340.0
33
34#ifndef SENSORARRAY_STOP_DISTANCE_FORWARD
35#define SENSORARRAY_STOP_DISTANCE_FORWARD 475
36#endif
37
38#ifndef SENSORARRAY_STOP_DISTANCE_BACKWARD
39#define SENSORARRAY_STOP_DISTANCE_BACKWARD 400
40#endif
41#define SENSORARRAY_FUTURE_ORIGIN 1
42#define SENSORARRAY_CURRENT_ORIGIN 0
43
44static Logger logs = Logger("SensorArray");
45class SensorArray
46{
47public:
48
50 {
51 uint16_t addr;
52 uint8_t pin;
53 };
54
56 {
57 VL53L5CX* sensor;
58 SensorConfig cfg;
59 uint8_t is_alive;
60 };
61
62 SensorArray(i2c_t* i2c, uint32_t latch, uint32_t data, uint32_t clock);
63 uint8_t addSensor(SensorConfig sensor_cfg);
64 uint8_t Init();
65 uint8_t Start();
66 void Stop();
67
68 //Get new data
69 uint8_t getNormalisedData(const Wheeledbase::WheeledBase& wheeledbase);
70 void Print();
71 bool isThereAnObstacle(float start, float end, float distance);
72
73 std::vector<Point> points;
74 bool isThereAnObstacleTerrain(bool interrupt, float velocity, float current_angle, float current_x, float current_y,
75 float max_x, float max_y);
76
77private:
78 uint8_t nb_sensors;
79 std::array<SensorHandle, 8> sensors;
80
81 VL53L5CX_ResultsData raw_data[8] = {};
82 Position origin_mesure[2][8];
83
84 uint8_t power_config;
85
86 uint32_t ds_pin;
87 uint32_t shcp_pin;
88 uint32_t stcp_pin;
89
90 i2c_t* i2c_bus;
91
92
93 void ApplyPowerConfig() const;
94 uint8_t AquireRawData(const Wheeledbase::WheeledBase& wheeledbase);
95 static void Mesurement_to_Point(uint16_t measure, uint8_t x, uint8_t y, Point* point);
96
97
98
99};
100
101#endif //SENSORARRAY_H
Un logger qui permet d'avoir une belle sortie console.
Log pour la sortie console avec des couleurs et éventuellement la sortie LCD.
Definition Logger.h:49
Definition VL53L5CX.h:16
Definition Types.h:9
Definition SensorArray.h:50
Definition SensorArray.h:56
Structure VL53L5CX_ResultsData contains the ranging results of VL53L5CX. If user wants more than 1 ta...
Definition vl53l5cx_api.h:302