diff --git a/app/raspberry_pi/src/car/system/lidar/LidarScanner.hpp b/app/raspberry_pi/src/car/system/lidar/LidarScanner.hpp index 03eaf59b..b4caad12 100644 --- a/app/raspberry_pi/src/car/system/lidar/LidarScanner.hpp +++ b/app/raspberry_pi/src/car/system/lidar/LidarScanner.hpp @@ -8,6 +8,7 @@ #include #include +#include using namespace rplidar; @@ -16,16 +17,20 @@ namespace car::system::lidar class LidarScanner : public LidarDevice { public: - LidarScanner(const std::string &lidar_port) : lidar(RPLidar::create(lidar_port).value()) + LidarScanner(const std::string &lidar_port, const bool &enabled) : lidar(RPLidar::create(lidar_port).value()), enabled(enabled) { + if (!this->enabled) + { + spdlog::warn("The Lidar Scanner is disabled"); + }; }; - ~LidarScanner() - { - }; + ~LidarScanner(){}; void initialize() const override { + if (!this->enabled) + return; this->lidar->reset(); this->lidar->stop(); this->lidar->stop_motor(); @@ -33,6 +38,8 @@ namespace car::system::lidar void start() const override { + if (!this->enabled) + return; this->lidar->start_motor(); // auto info_result = lidar->get_info(); @@ -53,12 +60,19 @@ namespace car::system::lidar }; std::vector scan() const override { + if (!this->enabled) + { + std::vector measures; + return measures; + } std::function()> scanGenerator = this->lidar->iter_scans(); return scanGenerator(); }; - void terminate() const override + void terminate() const override { + if (!this->enabled) + return; this->lidar->stop(); this->lidar->stop_motor(); this->lidar->disconnect(); @@ -66,6 +80,7 @@ namespace car::system::lidar private: std::unique_ptr lidar; + const bool enabled; }; } diff --git a/app/raspberry_pi/src/car/system/movement/MovementSystem.hpp b/app/raspberry_pi/src/car/system/movement/MovementSystem.hpp index ca0ef206..da834a97 100644 --- a/app/raspberry_pi/src/car/system/movement/MovementSystem.hpp +++ b/app/raspberry_pi/src/car/system/movement/MovementSystem.hpp @@ -38,31 +38,6 @@ namespace car::system::movement { void terminate() { } - // From: https://github.com/chaoticmachinery/pca9685 - int map(int x, int in_min, int in_max, int out_min, int out_max) { - return ((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min); - } - - // From: https://github.com/chaoticmachinery/pca9685 - int setAngleToAnalog(int angle) { - float pulse_wide; - int analog_value; - - pulse_wide = map(angle, 0, 180, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); - analog_value = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096); - return (analog_value); - } - - // From: https://github.com/chaoticmachinery/pca9685 - void turn(const TurnCommand& command) { - const float angle = std::clamp(command.angle, 1.0f, 179.0f); - for (int channel = 0; channel < 2; channel++) { - int val = 0; - val = setAngleToAnalog(angle); - this->pwm->setPWM(channel, 0, val); - } - } - ~MovementSystem() { }; diff --git a/app/raspberry_pi/src/car/system/movement/wheels/FrontWheel.hpp b/app/raspberry_pi/src/car/system/movement/wheels/FrontWheel.hpp new file mode 100644 index 00000000..06027b7b --- /dev/null +++ b/app/raspberry_pi/src/car/system/movement/wheels/FrontWheel.hpp @@ -0,0 +1,6 @@ +namespace car::system::movement::wheels +{ + class FrontWheel { + + }; +} // namespace car::system::movement::wheels diff --git a/app/raspberry_pi/src/car/system/movement/wheels/RearWheel.hpp b/app/raspberry_pi/src/car/system/movement/wheels/RearWheel.hpp new file mode 100644 index 00000000..bd459a69 --- /dev/null +++ b/app/raspberry_pi/src/car/system/movement/wheels/RearWheel.hpp @@ -0,0 +1,6 @@ +namespace car::system::movement::wheels +{ + class RearWheel { + + }; +} // namespace car::system::movement::wheels