JMotor
Loading...
Searching...
No Matches
JMotorCompDirect.h
Go to the documentation of this file.
1#ifndef J_MOTOR_COMP_DIRECT_H
2#define J_MOTOR_COMP_DIRECT_H
3#include "JMotorCompensator.h"
4#include <Arduino.h>
9private:
10 float multiplier;
11
12public:
17 JMotorCompDirect(float _multiplier)
18 {
19 multiplier = _multiplier;
20 }
21 float compensate(float val)
22 {
23 return constrain(val * multiplier, -maxDriverRange, maxDriverRange);
24 }
29 bool setMultiplier(float _multiplier)
30 {
31 if (multiplier != _multiplier) {
32 multiplier = _multiplier;
33 return true;
34 }
35 return false;
36 }
37 float getMaxVel()
38 {
39 return driverRange / multiplier * maxDriverRange;
40 }
41
42 float getMinVel()
43 {
44 return 0;
45 }
46};
47#endif
Converts from speed to driver input with a simple multiplier.
Definition JMotorCompDirect.h:8
bool setMultiplier(float _multiplier)
Definition JMotorCompDirect.h:29
float getMinVel()
Slowest speed motor can go.
Definition JMotorCompDirect.h:42
JMotorCompDirect(float _multiplier)
constructor
Definition JMotorCompDirect.h:17
float compensate(float val)
calculate
Definition JMotorCompDirect.h:21
float getMaxVel()
How fast of a motor speed setting would get adjusted to full motor power.
Definition JMotorCompDirect.h:37
This class defines a common interface for converting from speed to driver input. It should compensate...
Definition JMotorCompensator.h:9
float maxDriverRange
Definition JMotorCompensator.h:12
float driverRange
Definition JMotorCompensator.h:11