1#ifndef JSWERVE_MODULE_DIFFERENTIAL_H
2#define JSWERVE_MODULE_DIFFERENTIAL_H
33 float _driveRatio,
float _steeringRatio,
float _angleOffset = 0)
44 void set(
float _speed,
float _angle,
bool _run =
true)
68 if (m1state || m2state) {
72 return m1state || m2state;
79 return m1state || m2state;
defines common interface for JEncoder
Definition JEncoder.h:33
virtual void run()
if an encoder needs to have some code called each loop (like absolute encoder polling encoder and cal...
virtual float getPos()
returns how far the encoder has turned from the zero position converted to distance
virtual long zeroCounter()
reset the counter of how far the encoder has turned
A motor controller object that uses a JMotorCompensator to set velocity of a motor.
Definition JMotorControllerBasic.h:12
void setVelTarget(float vel, bool _run=true)
set target velocity for controller (acceleration limited)
Definition JMotorControllerBasic.h:65
bool setEnable(bool _enable)
change whether motor controller is enabled
Definition JMotorControllerBasic.h:108
void run()
update driver
Definition JMotorControllerBasic.h:87
bool getEnable()
is the controller enabled
Definition JMotorControllerBasic.h:143
float getMaxVel()
How fast of a motor speed setting would get adjusted to full motor power.
Definition JMotorControllerBasic.h:148
Definition JSwerveAngleControlLoop.h:4
virtual float calculate(float error)
Definition JSwerveModuleDifferential.h:8
long zeroTurnCounter()
zeros the encoder's counter of full turns, leaving only the fractional turn
Definition JSwerveModuleDifferential.h:59
float angleSetpoint
Definition JSwerveModuleDifferential.h:20
JEncoder & angleEncoder
Definition JSwerveModuleDifferential.h:12
float speedSetpoint
Definition JSwerveModuleDifferential.h:19
JSwerveAngleControlLoop & angleControlLoop
Definition JSwerveModuleDifferential.h:13
void set(float _speed, float _angle, bool _run=true)
set speed and angle setpoints for wheel
Definition JSwerveModuleDifferential.h:44
float steeringRatio
Definition JSwerveModuleDifferential.h:16
void run()
call this in loop() so that the swerve module can update its motors and angle control loop
Definition JSwerveModuleDifferential.h:87
JMotorControllerBasic & m1
Definition JSwerveModuleDifferential.h:10
float getAngle()
get angle measurement from wheel
Definition JSwerveModuleDifferential.h:54
JSwerveModuleDifferential(JMotorControllerBasic &_m1, JMotorControllerBasic &_m2, JEncoder &_angleEncoder, JSwerveAngleControlLoop &_angleControlLoop, float _driveRatio, float _steeringRatio, float _angleOffset=0)
Definition JSwerveModuleDifferential.h:32
bool setEnable(bool _enable)
set enable state of swerve module motors
Definition JSwerveModuleDifferential.h:64
bool getEnable()
get enable state of module
Definition JSwerveModuleDifferential.h:75
float getMaxSpeed()
maximum drive speed
Definition JSwerveModuleDifferential.h:82
float driveRatio
Definition JSwerveModuleDifferential.h:15
float angleOffset
Definition JSwerveModuleDifferential.h:17
JMotorControllerBasic & m2
Definition JSwerveModuleDifferential.h:11
defines a common interface for swerve modules
Definition JSwerveModule.h:7