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