1#ifndef JDRIVETRAIN_SWERVE_H
2#define JDRIVETRAIN_SWERVE_H
45 for (
byte i = 0; i < N; i++) {
48 modPosF[i] = _modPosForwards[i];
58 for (
byte i = 0; i < N; i++) {
66 for (
byte i = 0; i < N; i++) {
82 for (
byte i = 0; i < N; i++) {
91 for (
byte i = 0; i < N; i++) {
96 for (
byte i = 0; i < N; i++) {
101 float targetThetaHeading = degrees(atan2(vx, vy));
108 for (
byte i = 0; i < N; i++) {
111 for (
byte i = 0; i < N; i++) {
114 for (
byte i = 0; i < N; i++) {
120 return fmod(fmod((target - theta + 90), 180) + 360, 180) - 90 + theta;
interface for a drivetrain with only simple velocity control
Definition JDrivetrainBasic.h:8
number of swerve modules
Definition JDrivetrainSwerve.h:17
void setVel(JTwoDTransform _vel, bool _run=true)
sets a velocity for the drivetrain to move at
Definition JDrivetrainSwerve.h:88
float modPosF[N]
Definition JDrivetrainSwerve.h:21
bool getEnable()
gets the current state (enabled or disabled)
Definition JDrivetrainSwerve.h:79
float modPosL[N]
Definition JDrivetrainSwerve.h:20
float centerF
Definition JDrivetrainSwerve.h:26
void run()
call this in loop. it calls any encoder or motor update functions
Definition JDrivetrainSwerve.h:56
static float calcClosestAngle(float target, float theta)
Definition JDrivetrainSwerve.h:118
JDrivetrainSwerve(JSwerveModule *_swerveModule[N], float _modPosForwards[N], float _modPosLeft[N], float _centerL=0, float _centerF=0)
Definition JDrivetrainSwerve.h:41
float targetTheta[N]
Definition JDrivetrainSwerve.h:22
bool setEnable(bool _enable)
enables or disables movement
Definition JDrivetrainSwerve.h:63
bool enable()
enables movement
Definition JDrivetrainSwerve.h:71
float deadzone
Definition JDrivetrainSwerve.h:24
void setCenter(float forwards, float left)
Definition JDrivetrainSwerve.h:51
float targetSpeed[N]
Definition JDrivetrainSwerve.h:23
JSwerveModule * swerveModule[N]
Definition JDrivetrainSwerve.h:19
float centerL
Definition JDrivetrainSwerve.h:25
bool disable()
disables movement
Definition JDrivetrainSwerve.h:75
defines a common interface for swerve modules
Definition JSwerveModule.h:7
virtual bool setEnable(bool _enable)
set enable state of swerve module motors
virtual void run()
call this in loop() so that the swerve module can update its motors and angle control loop
virtual void set(float _speed, float _angle, bool _run=true)
set speed and angle setpoints for wheel
virtual bool getEnable()
get enable state of module