Boboter
Loading...
Searching...
No Matches
linefollower.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <soc/gpio_num.h>
11#include <esp_adc/adc_oneshot.h>
12#include "include/log_sources.h"
13
14class Robot;
15
16namespace Device {
18 public:
19 enum class linefollower_result_t : uint8_t;
20
21 private:
22 static constexpr const char* TAG = "Device::Linefollower";
23 static constexpr log_source LOG_SOURCE = LOG_SOURCE_DEVICE_LINEFOLLOWER;
24
25 static constexpr uint8_t NUM_LF_MODULES = 2;
26 static constexpr gpio_num_t LF_RIGHT_LEFT_PIN = GPIO_NUM_12;
27 static constexpr adc_channel_t ADC_CHANNEL = ADC_CHANNEL_0;
28
29 Robot& robot;
30 linefollower_result_t left_sensor_color;
31 linefollower_result_t right_sensor_color;
32
33 public:
34 static constexpr uint16_t REFLECTIVITY_THRESHOLD = 2300;
35
36 enum class linefollower_id_t : uint8_t {
37 LEFT = 0,
39 };
40
41 enum class linefollower_result_t : uint8_t {
42 BLACK = 0,
44 };
45
46 public:
47 explicit Linefollower(Robot& robot);
49
53 void initialize();
54
58 void measure();
59
65 [[nodiscard]] linefollower_result_t get_left_sensor_color() const { return left_sensor_color; }
66
72 [[nodiscard]] linefollower_result_t get_right_sensor_color() const { return right_sensor_color; }
73 };
74}
~Linefollower()
Definition linefollower.cpp:23
Linefollower(Robot &robot)
Definition linefollower.cpp:15
linefollower_id_t
Definition linefollower.h:36
@ RIGHT
Definition linefollower.h:38
@ LEFT
Definition linefollower.h:37
linefollower_result_t
Definition linefollower.h:41
@ BLACK
Definition linefollower.h:42
@ WHITE
Definition linefollower.h:43
linefollower_result_t get_right_sensor_color() const
Get the last measured color from the right sensor.
Definition linefollower.h:72
static constexpr uint16_t REFLECTIVITY_THRESHOLD
Definition linefollower.h:34
void measure()
Measures the currently seen color from both sensors.
Definition linefollower.cpp:42
linefollower_result_t get_left_sensor_color() const
Get the last measured color from the left sensor.
Definition linefollower.h:65
void initialize()
Sets up the necessary GPIO pin and ADC channel.
Definition linefollower.cpp:27
Class containing all the components of the robot.
Definition robot.h:32
log_source
Definition log_sources.h:12
@ LOG_SOURCE_DEVICE_LINEFOLLOWER
Definition log_sources.h:30
Definition battery.cpp:14