JMotor
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
JSwerveModuleDifferential Class Reference

#include <JSwerveModuleDifferential.h>

Inheritance diagram for JSwerveModuleDifferential:
Inheritance graph
[legend]
Collaboration diagram for JSwerveModuleDifferential:
Collaboration graph
[legend]

Public Member Functions

 JSwerveModuleDifferential (JMotorControllerBasic &_m1, JMotorControllerBasic &_m2, JEncoder &_angleEncoder, JSwerveAngleControlLoop &_angleControlLoop, float _driveRatio, float _steeringRatio, float _angleOffset=0)
 
void set (float _speed, float _angle, bool _run=true)
 set speed and angle setpoints for wheel
 
float getAngle ()
 get angle measurement from wheel
 
long zeroTurnCounter ()
 zeros the encoder's counter of full turns, leaving only the fractional turn
 
bool setEnable (bool _enable)
 set enable state of swerve module motors
 
bool getEnable ()
 get enable state of module
 
float getMaxSpeed ()
 maximum drive speed
 
void run ()
 call this in loop() so that the swerve module can update its motors and angle control loop
 
- Public Member Functions inherited from JSwerveModule
bool enable ()
 enable motor
 
bool disable ()
 disable motor
 

Public Attributes

JMotorControllerBasicm1
 
JMotorControllerBasicm2
 
JEncoderangleEncoder
 
JSwerveAngleControlLoopangleControlLoop
 
float driveRatio = 1
 
float steeringRatio = 1
 
float angleOffset = 0
 
float speedSetpoint = 0
 
float angleSetpoint = 0
 

Constructor & Destructor Documentation

◆ JSwerveModuleDifferential()

JSwerveModuleDifferential::JSwerveModuleDifferential ( JMotorControllerBasic _m1,
JMotorControllerBasic _m2,
JEncoder _angleEncoder,
JSwerveAngleControlLoop _angleControlLoop,
float  _driveRatio,
float  _steeringRatio,
float  _angleOffset = 0 
)
inline
Parameters
_m1positive speed drives forward and steers CCW if viewed from above, just swap which motor is m1 and m2 or reverse a motor if this is not the case
_m2positive speed drives forward and steers CW if viewed from above, just swap which motor is m1 and m2 or reverse a motor if this is not the case
_angleEncoderJEncoder, should be absolute encoder, from 0-360 degrees for a revolution
_angleControlLoopJSwerveAngleControlLoop object
_driveRatiomotor revolutions per drive distance unit
_steeringRatiomotor revolutions per steering revolution
_angleOffsetdegrees, default=0 added to encoder reading, adjust until angle is zero when wheel is straight forwards

Member Function Documentation

◆ getAngle()

float JSwerveModuleDifferential::getAngle ( )
inlinevirtual

get angle measurement from wheel

Return values
(float)angle in degrees

Reimplemented from JSwerveModule.

◆ getEnable()

bool JSwerveModuleDifferential::getEnable ( )
inlinevirtual

get enable state of module

Return values
(bool)true = motors enabled, false = motors disabled

Reimplemented from JSwerveModule.

◆ getMaxSpeed()

float JSwerveModuleDifferential::getMaxSpeed ( )
inlinevirtual

maximum drive speed

Reimplemented from JSwerveModule.

◆ run()

void JSwerveModuleDifferential::run ( )
inlinevirtual

call this in loop() so that the swerve module can update its motors and angle control loop

Reimplemented from JSwerveModule.

◆ set()

void JSwerveModuleDifferential::set ( float  _speed,
float  _angle,
bool  _run = true 
)
inlinevirtual

set speed and angle setpoints for wheel

Parameters
speed(float) speed for wheel
angle(float) angle in degrees
run(bool) default:true, true = call run() in this function, false = you'll call run() yourself
Return values
None

Reimplemented from JSwerveModule.

◆ setEnable()

bool JSwerveModuleDifferential::setEnable ( bool  _enable)
inlinevirtual

set enable state of swerve module motors

Parameters
_enable(bool) true = enable module, false = disable module
Return values
(bool)true if state changed, false if state already set

Reimplemented from JSwerveModule.

◆ zeroTurnCounter()

long JSwerveModuleDifferential::zeroTurnCounter ( )
inlinevirtual

zeros the encoder's counter of full turns, leaving only the fractional turn

Return values
(long)previous turn counter value

Reimplemented from JSwerveModule.

Member Data Documentation

◆ angleControlLoop

JSwerveAngleControlLoop& JSwerveModuleDifferential::angleControlLoop

◆ angleEncoder

JEncoder& JSwerveModuleDifferential::angleEncoder

◆ angleOffset

float JSwerveModuleDifferential::angleOffset = 0

◆ angleSetpoint

float JSwerveModuleDifferential::angleSetpoint = 0

◆ driveRatio

float JSwerveModuleDifferential::driveRatio = 1

◆ m1

JMotorControllerBasic& JSwerveModuleDifferential::m1

◆ m2

JMotorControllerBasic& JSwerveModuleDifferential::m2

◆ speedSetpoint

float JSwerveModuleDifferential::speedSetpoint = 0

◆ steeringRatio

float JSwerveModuleDifferential::steeringRatio = 1

The documentation for this class was generated from the following file: