/** * @file manualControl.h * @author Alexander Klein (alex@kleiax.de) * @brief A small class to drive the Rover by the controller joystick. * @version 0.1 * @date 2021-12-13 * * @copyright Copyright (c) 2021 * */ #ifndef MANUAL_CONTROL_H #define MANUAL_CONTROL_H #include "moveControl.h" #include "driveModi/driveModi.h" #include "controlPadInput.h" /** * @brief Drive the Rover with a Joystick * * This class gets the x and y value from the PS3 controller * and map the values to moveControl * * @see MoveControl */ class ManualControl : public DriveModi { public: ManualControl(MoveControl *moveControl, const ControlPadInput *input); /** * @brief Destroy the Manual Control object * Set in moveControl speed and rotation to 0 and set DrivingStatus::stop */ ~ManualControl(); /** * @brief Calls runManualControl() to update all values. * * This function should be called every mainloop. If the delay is not reached, than the * functions returns immediately. * @see runSpeedometer() * @see setDelay() */ void loop() override; /** * @brief Noramly called repeatedly by loop() to calcluate new values. * Set new values for speed and rotation in moveControl */ void runManualControl(); /** * @brief Set the min delay between each loop * * @param delay_ time in Milliseconds */ void setDelay(uint8_t delay_) { delay = delay_; } /** * @brief Set the max speed * * @param maxSpeed in m/s */ void setMaxSpeed(double maxSpeed) { max_speed = maxSpeed; } /** * @brief Set the max rotation * * @param maxRotation in rad/s (maybe) */ void setMaxRotation(double maxRotation) { max_rotation = maxRotation; } protected: MoveControl *moveControl; const ControlPadInput* input; private: uint32_t lastMillis = 0; uint8_t delay = 10; double max_speed = 1; double max_rotation = 7; }; #endif // MANUAL_CONTROL_H