JMotor
Loading...
Searching...
No Matches
Public Member Functions | List of all members
JMotorController Class Referenceabstract

This class defines a common interface for classes which control velocity and position of a motor controlled by a JMotorDriver. More...

#include <JMotorController.h>

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

Public Member Functions

virtual bool setPosTarget (float _posTarget, bool _run=true)=0
 set target position (motor drives towards position, following acceleration profile)
 
virtual bool setPosSetpoint (float _posSetpoint, bool _run=true)=0
 set position for motor to drive towards position as fast as possible (setpoint for control loop if available)
 
virtual bool setPosDelta (float _posDelta, bool _run=true, bool _resetPos=false)=0
 alternative method for setting velocity that uses setPosSetpoint
 
virtual float getPosTarget ()=0
 get position set as target (for smoothed position setting mode)
 
virtual float getPosSetpoint ()=0
 get position controller is currently trying to get to
 
virtual float getPos ()=0
 get what position the motor is currently at
 
virtual float resetPos ()=0
 reset what position the controller thinks it's in
 
virtual void setVelLimit (float _velLimit)=0
 set maximum motor speed
 
virtual bool isPosModeNotVelocity ()=0
 true if controller is in position target mode, false if in velocity mode
 
- Public Member Functions inherited from JMotorControllerBase
virtual void setAccelLimit (float _accelLimit)=0
 set maximum rate that motor speed can be changed at
 
virtual void setVel (float vel, bool _run=true)=0
 set velocity for controller
 
virtual void setVelTarget (float vel, bool _run=true)=0
 set target velocity for controller (acceleration limited)
 
virtual float getVelTarget ()=0
 get target velocity for controller
 
virtual float getVel ()=0
 get current velocity of motor
 
virtual float getDriverSetVal ()=0
 returns the value the motor driver is being set to
 
virtual void run ()=0
 update driver
 
virtual bool setEnable (bool _enable)=0
 change whether motor controller is enabled
 
virtual bool isDriverInRange ()=0
 true if motor driver is being set to within its range, false if driver is at a maximum
 
virtual bool enable ()=0
 enable motor controller
 
virtual bool disable ()=0
 disable motor controller
 
virtual float getDriverMinRange ()=0
 if getDriverSetVal goes below this, isDriverInRange will go false
 
virtual float getDriverMaxRange ()=0
 if getDriverSetVal exceeds this, isDriverInRange will go false
 
virtual bool getEnable ()=0
 is the controller enabled
 
virtual float getMaxVel ()=0
 How fast of a motor speed setting would get adjusted to full motor power.
 
virtual float getMinVel ()=0
 slowest speed motor can go
 
virtual void setMaxDriverRangeAmount (float _driverRangeAmount)=0
 set what fraction of driverRange can be used
 
virtual float getAccelLimit ()=0
 returns value of accelLimit
 
virtual float getVelLimit ()=0
 returns value of velLimit
 

Detailed Description

This class defines a common interface for classes which control velocity and position of a motor controlled by a JMotorDriver.

Member Function Documentation

◆ getPos()

virtual float JMotorController::getPos ( )
pure virtual

get what position the motor is currently at

Return values
(float)

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.

◆ getPosSetpoint()

virtual float JMotorController::getPosSetpoint ( )
pure virtual

get position controller is currently trying to get to

Return values
(float)

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.

◆ getPosTarget()

virtual float JMotorController::getPosTarget ( )
pure virtual

get position set as target (for smoothed position setting mode)

Return values
(float)

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.

◆ isPosModeNotVelocity()

virtual bool JMotorController::isPosModeNotVelocity ( )
pure virtual

true if controller is in position target mode, false if in velocity mode

Return values
(bool)

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.

◆ resetPos()

virtual float JMotorController::resetPos ( )
pure virtual

reset what position the controller thinks it's in

Note
don't drive too far without resetting this so that the limited precision of floats doesn't become a problem.
Return values
(float)returns old position

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.

◆ setPosDelta()

virtual bool JMotorController::setPosDelta ( float  _posDelta,
bool  _run = true,
bool  _resetPos = false 
)
pure virtual

alternative method for setting velocity that uses setPosSetpoint

Note
handles velocities below getMinVel(), and may have better distance accuracy, doesn't smooth velocity
Parameters
_posDelta(float) basically velocity
_resetPos(bool) default=false, keep setting current position to zero
_run(bool) default:true, true = call run() in this function, false = you'll call run() yourself
Return values
(bool)did the setting change?

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.

◆ setPosSetpoint()

virtual bool JMotorController::setPosSetpoint ( float  _posSetpoint,
bool  _run = true 
)
pure virtual

set position for motor to drive towards position as fast as possible (setpoint for control loop if available)

Note
run() needs to be called in order for the motor to move
Parameters
_posSetpoint(float) position setpoint
_run(bool) default:true, true = call run() in this function, false = you'll call run() yourself
Return values
(bool)did the setpoint change?

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.

◆ setPosTarget()

virtual bool JMotorController::setPosTarget ( float  _posTarget,
bool  _run = true 
)
pure virtual

set target position (motor drives towards position, following acceleration profile)

Parameters
_posTarget(float) target position
_run(bool) default:true, true = call run() in this function, false = you'll call run() yourself
Return values
(bool)did the target change?

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.

◆ setVelLimit()

virtual void JMotorController::setVelLimit ( float  _velLimit)
pure virtual

set maximum motor speed

Note
set to INFINITY to disable limit
Parameters
_velLimit(float)

Implements JMotorControllerBase.

Implemented in JMotorControllerClosed, JMotorControllerOpen, and JServoController.


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