elbestia-robot/lib/motor/OmniWheelMotors.hpp

55 lines
No EOL
1.3 KiB
C++

#ifndef OMNIWHEEL_MOTORS_HPP
#define OMNIWHEEL_MOTORS_HPP
#include <Arduino.h>
#include <Wire.h>
class OmniWheelMotors {
public:
int FULL_ROTATION_TIME; // Time for 360 degrees in milliseconds
struct Motor {
int R_PWM;
int L_PWM;
};
OmniWheelMotors(int m1_r_pwm, int m1_l_pwm,
int m2_r_pwm, int m2_l_pwm,
int m3_r_pwm, int m3_l_pwm);
// Initialize the motors
void begin();
// Basic movement functions
void moveForward(int speed);
void moveBackward(int speed);
void moveLeft(int speed);
void moveRight(int speed);
void rotateClockwise(int speed);
void rotateCounterClockwise(int speed);
// Rotation functions
void rotate360();
void rotateToAngle(int targetAngle);
// Stop all motors
void stop();
// Direct motor control
void setMotorSpeed(Motor motor, int rightSpeed, int leftSpeed);
// Set maximum and minimum speed limits
void setSpeedLimits(int min, int max);
// Set time for full rotation
void setRotationTime(int milliseconds);
private:
Motor motor_1; // First motor
Motor motor_2; // Second motor
Motor motor_3; // Third motor
int MAX_SPEED; // Maximum speed value
int MIN_SPEED; // Minimum speed value for stable movement
};
#endif // OMNIWHEEL_MOTORS_HPP