#pragma once #include #include "Thing.h" namespace Passer { namespace RoboidControl { class Motor : public Thing { public: Motor(); /// @brief Turning direction of the motor /// @brief Motor turning direction enum class Direction { Clockwise = 1, CounterClockwise = -1 }; /// @brief The forward turning direction of the motor Direction direction = Direction::Clockwise; /// @brief Set the target motor speed /// @param speed The speed between -1 (full backward), 0 (stop) and 1 (full /// forward) virtual void SetSpeed(float speed); /// @brief Get the current target speed of the motor /// @return The speed between -1 (full backward), 0 (stop) and 1 (full /// forward) virtual float GetSpeed(); bool Drive(float distance); protected: float currentTargetSpeed = 0; bool driving = false; float targetDistance = 0; time_t startTime = 0; }; } // namespace RoboidControl } // namespace Passer using namespace Passer::RoboidControl;