RoboidControl-cpp/Things/DifferentialDrive.h
2025-03-06 09:25:47 +01:00

33 lines
871 B
C++

#pragma once
#include "Thing.h"
namespace RoboidControl {
/// @brief A thing which can move itself using a differential drive system
class DifferentialDrive : public Thing {
public:
DifferentialDrive(Participant* participant);
void SetDimensions(float wheelDiameter, float wheelSeparation);
void SetMotors(Thing* leftWheel, Thing* rightWheel);
void SetLeftWheelVelocity(float angularSpeed);
void SetRightWheelVelocity(float angularSpeed);
virtual void Update(unsigned long currentMs) override;
protected:
/// @brief The radius of a wheel in meters
float wheelRadius = 1.0f;
/// @brief The distance between the wheels in meters
float wheelSeparation = 1.0f;
/// @brief Convert revolutions per second to meters per second
float rpsToMs = 1.0f;
Thing* leftWheel = nullptr;
Thing* rightWheel = nullptr;
};
} // namespace RoboidControl