Files
Bachelorarbeit-Rover/src/driveModi/Modi/ManualControl/manualControl.h
T
kleiax 22eb6788c3 - remove NtripReconnect from Autopilot and CaptureRoute
- shiftet moveControl States in the class namespace
- added auto reconeect to NtripClient
- a lot of refactor
2023-05-30 23:40:05 +02:00

98 lines
3.0 KiB
C++

/**
* @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"
#include "calibrateCompass.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; }
void increaseMaxSpeed(double increase = 0.1) { max_speed += increase; }
void decreaseMaxSpeed(double increase = 0.1) { max_speed -= increase; }
double getMaxSpeed() { return this->max_speed; }
/**
* @brief Set the max rotation
*
* @param maxRotation in rad/s (maybe)
*/
void setMaxRotation(double maxRotation) { max_rotation = maxRotation; }
void increaseMaxRotation(double increase = 0.1) { max_rotation += increase; }
void decreaseMaxRotation(double increase = 0.1) { max_rotation -= increase; }
double getMaxRotation() { return this->max_rotation; }
void setCalibrateCompass(CalibrateCompass* val = nullptr) { this->caliCompass = val; }
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
protected:
MoveControl *moveControl;
const ControlPadInput* input;
private:
uint32_t lastMillis = 0;
uint8_t delay = 10;
double max_speed = 1;
double max_rotation = 7;
CalibrateCompass* caliCompass = nullptr;
};
#endif // MANUAL_CONTROL_H