JMotor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
JDrivetrainSwerve< N > Class Template Reference

number of swerve modules More...

#include <JDrivetrainSwerve.h>

Inheritance diagram for JDrivetrainSwerve< N >:
Inheritance graph
[legend]
Collaboration diagram for JDrivetrainSwerve< N >:
Collaboration graph
[legend]

Public Member Functions

 JDrivetrainSwerve (JSwerveModule *_swerveModule[N], float _modPosForwards[N], float _modPosLeft[N], float _centerL=0, float _centerF=0)
 
void setCenter (float forwards, float left)
 
void run ()
 call this in loop. it calls any encoder or motor update functions
 
bool setEnable (bool _enable)
 enables or disables movement
 
bool enable ()
 enables movement
 
bool disable ()
 disables movement
 
bool getEnable ()
 gets the current state (enabled or disabled)
 
void setVel (JTwoDTransform _vel, bool _run=true)
 sets a velocity for the drivetrain to move at
 
- Public Member Functions inherited from JDrivetrainBasic
virtual JTwoDTransform getMaxVel ()=0
 returns the approximate maximum velocity of the drivetrain, if the drivetrain is told to move at max velocity, it should set the motors to full power.
 

Static Public Member Functions

static float calcClosestAngle (float target, float theta)
 

Public Attributes

JSwerveModuleswerveModule [N]
 
float modPosL [N]
 
float modPosF [N]
 
float targetTheta [N]
 
float targetSpeed [N]
 
float deadzone = 0.0001
 
float centerL = 0
 
float centerF = 0
 

Detailed Description

template<byte N>
class JDrivetrainSwerve< N >

number of swerve modules

swerve drivetrain.

Note
not actually a subclass of JDrivetrain, since currently only velocity control is implemented The code for calculating speed and angles for each wheel is in this file.

Constructor & Destructor Documentation

◆ JDrivetrainSwerve()

template<byte N>
JDrivetrainSwerve< N >::JDrivetrainSwerve ( JSwerveModule _swerveModule[N],
float  _modPosForwards[N],
float  _modPosLeft[N],
float  _centerL = 0,
float  _centerF = 0 
)
inline
Note
Parameters
_swerveModule[N]array of pointers to swerveModules. Sorry, couldn't figure out how to hide the pointers from you. example: pass swerveModules to constructor: JSwerveModule* swerveModules[3] = { &swerveModule1, &swerveModule2, &swerveModule3 }; where swerveModuleN is a subclass of JSwerveModule
_modPosForwards[N]
_modPosLeft[N]
_centerL
_centerF
Return values

Member Function Documentation

◆ calcClosestAngle()

template<byte N>
static float JDrivetrainSwerve< N >::calcClosestAngle ( float  target,
float  theta 
)
inlinestatic

◆ disable()

template<byte N>
bool JDrivetrainSwerve< N >::disable ( )
inlinevirtual

disables movement

Return values
didthe state change

Implements JDrivetrainBasic.

◆ enable()

template<byte N>
bool JDrivetrainSwerve< N >::enable ( )
inlinevirtual

enables movement

Return values
didthe state change

Implements JDrivetrainBasic.

◆ getEnable()

template<byte N>
bool JDrivetrainSwerve< N >::getEnable ( )
inlinevirtual

gets the current state (enabled or disabled)

Return values
(bool)true=enabled false=movement disabled

Implements JDrivetrainBasic.

◆ run()

template<byte N>
void JDrivetrainSwerve< N >::run ( )
inlinevirtual

call this in loop. it calls any encoder or motor update functions

Implements JDrivetrainBasic.

◆ setCenter()

template<byte N>
void JDrivetrainSwerve< N >::setCenter ( float  forwards,
float  left 
)
inline

◆ setEnable()

template<byte N>
bool JDrivetrainSwerve< N >::setEnable ( bool  _enable)
inlinevirtual

enables or disables movement

Parameters
_enable(bool) true=enabled false=movement disabled
Return values
didthe state change

Implements JDrivetrainBasic.

◆ setVel()

template<byte N>
void JDrivetrainSwerve< N >::setVel ( JTwoDTransform  _vel,
bool  _run = true 
)
inlinevirtual

sets a velocity for the drivetrain to move at

Parameters
_vel(JTwoDTransform) velocity to move at
_run(bool, default=true) if true setVel will call run() for you, if false you must call it yourself
Return values
None

Implements JDrivetrainBasic.

Member Data Documentation

◆ centerF

template<byte N>
float JDrivetrainSwerve< N >::centerF = 0

◆ centerL

template<byte N>
float JDrivetrainSwerve< N >::centerL = 0

◆ deadzone

template<byte N>
float JDrivetrainSwerve< N >::deadzone = 0.0001

◆ modPosF

template<byte N>
float JDrivetrainSwerve< N >::modPosF[N]

◆ modPosL

template<byte N>
float JDrivetrainSwerve< N >::modPosL[N]

◆ swerveModule

template<byte N>
JSwerveModule* JDrivetrainSwerve< N >::swerveModule[N]

◆ targetSpeed

template<byte N>
float JDrivetrainSwerve< N >::targetSpeed[N]

◆ targetTheta

template<byte N>
float JDrivetrainSwerve< N >::targetTheta[N]

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