libstp
Robotics library for Botball
Loading...
Searching...
No Matches
differential.hpp
Go to the documentation of this file.
1#pragma once
4#include "hal/IMotor.hpp"
5#include <vector>
6
8{
16 {
17 private:
18 double m_wheelbase;
19 double m_wheelRadius;
20 double m_maxWheelSpeed{0.0}; // 0 = no limiting
21
22 drive::MotorAdapter left_motor_;
23 drive::MotorAdapter right_motor_;
24
25 public:
33 hal::motor::IMotor* right_motor,
34 double wheelbase,
35 double wheelRadius);
36 ~DifferentialKinematics() override = default;
37
39 [[nodiscard]] std::size_t wheelCount() const override;
40
43
45 [[nodiscard]] foundation::ChassisVelocity estimateState() const override;
46
48 void hardStop() override;
49
51 [[nodiscard]] bool supportsLateralMotion() const override;
52
54 void resetEncoders() override;
55
56 [[nodiscard]] double getWheelRadius() const override { return m_wheelRadius; }
57
59 [[nodiscard]] std::vector<hal::motor::IMotor*> getMotors() override;
60
61 [[nodiscard]] StmOdometryConfig getStmOdometryConfig() override;
62
65 int power_percent) override;
66
67 void setMaxWheelSpeed(double max_wheel_speed) { m_maxWheelSpeed = max_wheel_speed; }
68 [[nodiscard]] double getMaxWheelSpeed() const { return m_maxWheelSpeed; }
69
75 [[nodiscard]] double maxYawRateForArcRadius(double radius_m,
76 bool /*lateral*/) const override
77 {
78 if (m_maxWheelSpeed <= 0.0)
79 return std::numeric_limits<double>::infinity();
80 const double max_wheel_mps = m_maxWheelSpeed * m_wheelRadius;
81 return max_wheel_mps / (radius_m + 0.5 * m_wheelbase);
82 }
83 };
84}
foundation::ChassisVelocity estimateState() const override
void applyPowerCommand(const foundation::ChassisVelocity &direction, int power_percent) override
double maxYawRateForArcRadius(double radius_m, bool) const override
MotorCommands applyCommand(const foundation::ChassisVelocity &cmd, double dt) override
DifferentialKinematics(hal::motor::IMotor *left_motor, hal::motor::IMotor *right_motor, double wheelbase, double wheelRadius)
double getWheelRadius() const override
Get the wheel radius used by this kinematics model.
std::vector< hal::motor::IMotor * > getMotors() override
Interface for motor abstraction.
Definition IMotor.hpp:17