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

interface for a drivetrain that makes it into field oriented More...

#include <JDrivetrainFieldOriented.h>

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

Public Member Functions

 JDrivetrainFieldOriented (JDrivetrain &_drivetrain)
 
float getHeading ()
 
void giveHeading (float _heading)
 
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=false)
 sets a velocity for the drivetrain to move at
 
JTwoDTransform getMaxVel ()
 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.
 
JTwoDTransform getVel (bool _run=false)
 
JTwoDTransform getDist (bool _run=false)
 
void setDistSetpoint (JTwoDTransform _dist, bool _run=false)
 
void setDistDelta (JTwoDTransform _dist, bool _run=false)
 
void resetDist ()
 
void setMotorVel (float vel, unsigned char i, bool _run=false)
 
float getMotorVel (unsigned char i)
 
void setMotorDistSetpoint (float distSetpoint, unsigned char i, bool _run=false)
 
void setMotorDistDelta (float distDelta, unsigned char i, bool _run=false)
 
unsigned char getNumberMotors ()
 

Protected Attributes

JDrivetraindrivetrain
 
float imuHeading = 0
 
float imuHeadingOffset = 0
 
float lastImuHeading = 0
 
float theta = 0
 
int fullRotations = 0
 
JTwoDTransform dist = { 0, 0, 0 }
 
JTwoDTransform lastDrivetrainDist = { 0, 0, 0 }
 

Detailed Description

interface for a drivetrain that makes it into field oriented

/ TODO: NOT DONE YET* //TODO: COMMENT

Note
only makes sense for drivetrains that can move in any direction

Constructor & Destructor Documentation

◆ JDrivetrainFieldOriented()

JDrivetrainFieldOriented::JDrivetrainFieldOriented ( JDrivetrain _drivetrain)
inline

Member Function Documentation

◆ disable()

bool JDrivetrainFieldOriented::disable ( )
inlinevirtual

disables movement

Return values
didthe state change

Implements JDrivetrainBasic.

◆ enable()

bool JDrivetrainFieldOriented::enable ( )
inlinevirtual

enables movement

Return values
didthe state change

Implements JDrivetrainBasic.

◆ getDist()

JTwoDTransform JDrivetrainFieldOriented::getDist ( bool  _run = false)
inlinevirtual

Reimplemented from JDrivetrain.

◆ getEnable()

bool JDrivetrainFieldOriented::getEnable ( )
inlinevirtual

gets the current state (enabled or disabled)

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

Implements JDrivetrainBasic.

◆ getHeading()

float JDrivetrainFieldOriented::getHeading ( )
inline

◆ getMaxVel()

JTwoDTransform JDrivetrainFieldOriented::getMaxVel ( )
inlinevirtual

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.

Note
depends on how well calibrated the motor compensators are
Return values
(JTwoDTransform)maximum velocity (in whatever units your drivetrain and motors are set up for)

Implements JDrivetrainBasic.

◆ getMotorVel()

float JDrivetrainFieldOriented::getMotorVel ( unsigned char  i)
inlinevirtual

Reimplemented from JDrivetrain.

◆ getNumberMotors()

unsigned char JDrivetrainFieldOriented::getNumberMotors ( )
inlinevirtual

Reimplemented from JDrivetrain.

◆ getVel()

JTwoDTransform JDrivetrainFieldOriented::getVel ( bool  _run = false)
inlinevirtual

Reimplemented from JDrivetrain.

◆ giveHeading()

void JDrivetrainFieldOriented::giveHeading ( float  _heading)
inline

◆ resetDist()

void JDrivetrainFieldOriented::resetDist ( )
inlinevirtual

Reimplemented from JDrivetrain.

◆ run()

void JDrivetrainFieldOriented::run ( )
inlinevirtual

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

Implements JDrivetrainBasic.

◆ setDistDelta()

void JDrivetrainFieldOriented::setDistDelta ( JTwoDTransform  _dist,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setDistSetpoint()

void JDrivetrainFieldOriented::setDistSetpoint ( JTwoDTransform  _dist,
bool  _run = false 
)
inlinevirtual
Note
don't set a dist setpoint far from the current distance
Parameters
_dist
_run
Return values
None

Reimplemented from JDrivetrain.

◆ setEnable()

bool JDrivetrainFieldOriented::setEnable ( bool  _enable)
inlinevirtual

enables or disables movement

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

Implements JDrivetrainBasic.

◆ setMotorDistDelta()

void JDrivetrainFieldOriented::setMotorDistDelta ( float  distDelta,
unsigned char  i,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setMotorDistSetpoint()

void JDrivetrainFieldOriented::setMotorDistSetpoint ( float  distSetpoint,
unsigned char  i,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setMotorVel()

void JDrivetrainFieldOriented::setMotorVel ( float  vel,
unsigned char  i,
bool  _run = false 
)
inlinevirtual

Reimplemented from JDrivetrain.

◆ setVel()

void JDrivetrainFieldOriented::setVel ( JTwoDTransform  _vel,
bool  _run = false 
)
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

◆ dist

JTwoDTransform JDrivetrainFieldOriented::dist = { 0, 0, 0 }
protected

◆ drivetrain

JDrivetrain& JDrivetrainFieldOriented::drivetrain
protected

◆ fullRotations

int JDrivetrainFieldOriented::fullRotations = 0
protected

◆ imuHeading

float JDrivetrainFieldOriented::imuHeading = 0
protected

◆ imuHeadingOffset

float JDrivetrainFieldOriented::imuHeadingOffset = 0
protected

◆ lastDrivetrainDist

JTwoDTransform JDrivetrainFieldOriented::lastDrivetrainDist = { 0, 0, 0 }
protected

◆ lastImuHeading

float JDrivetrainFieldOriented::lastImuHeading = 0
protected

◆ theta

float JDrivetrainFieldOriented::theta = 0
protected

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