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

JServoControllerGentle is an extension of JServoController that uses JServoStallSensing to make a servo grip with a specific amount of force. More...

#include <JServoControllerGentle.h>

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

Public Member Functions

 JServoControllerGentle (JServoControllerAdvanced servo, JServoStallSensing &servoStallSensor, float _targetForce=.05, float _gripSpeed=30)
 Constructor for JServoController Gentle (a child class of JServoController)
 
virtual void run ()
 call this in your main loop
 
void gripGently (bool _dirPos, float _targetForce=NAN, float _gripSpeed=NAN, bool _run=false)
 have the servo move until it is pushing with a set amount of force
 
void setPosition (float pos, bool _run)
 
void setAngleImmediate (float angle, bool _run=true)
 
void setAngleImmediateInc (float angleDiff, bool _run=true)
 
void setAngleSmoothed (float angle, bool _run=true)
 
- Public Member Functions inherited from JServoController
 JServoController (JMotorDriverServo &_servo, bool _reverse=false, float velLimit=INFINITY, float accelLimit=INFINITY, float decelLimit=NAN, unsigned long _disableTimeout=0, float _minAngleLimit=0, float _maxAngleLimit=180, float _pos=90, float _minSetAngle=0, float _maxSetAngle=180, int minServoVal=544, int maxServoVal=2400, bool _preventGoingWrongWay=true, bool _preventGoingTooFast=true, float _stoppingDecelLimit=INFINITY)
 Constructor for JServoController, a class for controlling JMotorDriverServo, with angle calibration and accel and velocity limiting.
 
void setAngleImmediate (float angle, bool _run=true)
 set servo angle immediately, without velocity or acceleration limiting
 
void setAngleImmediateInc (float angleDiff, bool _run=true)
 increment servo angle and set immediately, without velocity or acceleration limiting
 
void setAngleSmoothed (float angle, bool _run=true)
 set servo angle target, servo will move to target but at limited velocity and acceleration
 
void setDisableTimeout (unsigned long _timeout)
 default: 0, after how many milliseconds of no movement should the servo be disabled? 0=never disable
 
unsigned long getDisableTimeout ()
 
unsigned long getLastMovedMillis ()
 returns the value of millis() when the servo last moved
 
unsigned long getMillisSinceMoved ()
 returns the number of milliseconds since the servo last moved
 
void setLastMovedMillis (unsigned long mil)
 allows for changing the variable that stores when the servo last moved
 
virtual bool setEnable (bool _enable)
 enable or disable the servo (start or stop sending a signal to the servo)
 
bool enable ()
 equivalent to setEnable(true)
 
bool disable ()
 equivalent to setEnable(false)
 
bool getEnable ()
 returns whether the servo is enabled or not
 
float getPosTarget ()
 what position is the servo moving towards or at
 
float getPos ()
 what position is the servo actually being set to? (slowly approaches target if smoothing is used)
 
float getVelocity ()
 what rate is servo position being changed at?
 
bool isPosAtTarget ()
 true if position=target, false otherwise
 
bool isPosNotAtTarget ()
 equivalent to !isPosAtTarget()
 
float distToTarget ()
 returns target-position
 
void restartRun ()
 if you stopped calling run() for a while, call this before restarting run() to avoid a big jump in movement
 
bool getActive ()
 returns whether the servo is "awake" (whether signals are being sent)
 
void wake ()
 if the servo has been disabled because of inactivity, calling this function simulates the servo being told to move and wakes it up
 
void setReverse (bool rev)
 
bool getReverse ()
 
void setAngleLimits (float _minAngleLimit, float _maxAngleLimit)
 
void setMinAngleLimit (float _minAngleLimit)
 
void setMaxAngleLimit (float _maxAngleLimit)
 
float getMinAngleLimit ()
 
float getMaxAngleLimit ()
 
float getAngleLimitRange ()
 
void setSetAngles (float _minSetAngle, float _maxSetAngle)
 
void setMinSetAngle (float _minSetAngle)
 
void setMaxSetAngle (float _maxSetAngle)
 
float getAccelLimit ()
 returns value of accelLimit
 
float getDecelLimit ()
 
float getVelLimit ()
 returns value of velLimit
 
void setAccelLimit (float accelLim)
 set maximum rate that motor speed can be changed at
 
void setAccelAndDecelLimits (float accelLim, float decelLim=NAN)
 
void setDecelLimit (float decelLim=NAN)
 
void setVelLimit (float velLim)
 set maximum motor speed
 
void setVelAccelLimits (float velLim, float accelLim, float decelLim=NAN)
 
void setPosition (float pos, bool _run=true)
 sets servo position, leaves target where it was
 
void setMinServoValue (int value)
 microseconds for shortest servo pulse
 
void setMaxServoValue (int value)
 microseconds for longest servo pulse
 
void setServoRangeValues (int min, int max)
 set the settings for short and long servo pulses at the same time
 
int getMinServoRangeValue ()
 returns setting for microseconds for shortest servo pulse
 
int getMaxServoRangeValue ()
 returns setting for microseconds for longest servo pulse
 
int getServoValueRange ()
 returns difference (in microseconds) between longest and shortest servo pulse settings
 
int getSetMicroseconds ()
 returns how many microseconds the servo signal pulse was most recently set to
 
bool getConstrainRange ()
 returns whether the range of set() will be constrained to within -1 and 1
 
void setConstrainRange (bool _constrainRange)
 set whether the range of set() will be constrained to within -1 and 1
 
void setVel (float vel, bool _run=true)
 set velocity for controller
 
void setVelTarget (float vel, bool _run=true)
 set target velocity for controller (acceleration limited)
 
float getVelTarget ()
 get target velocity for controller
 
float getVel ()
 get current velocity of motor
 
float getDriverSetVal ()
 returns the value the motor driver is being set to
 
bool isDriverInRange ()
 true if motor driver is being set to within its range, false if driver is at a maximum
 
float getDriverMinRange ()
 if getDriverSetVal goes below this, isDriverInRange will go false
 
float getDriverMaxRange ()
 if getDriverSetVal exceeds this, isDriverInRange will go false
 
float getMaxVel ()
 How fast of a motor speed setting would get adjusted to full motor power.
 
float getMinVel ()
 slowest speed motor can go
 
void setMaxDriverRangeAmount (float _driverRangeAmount)
 set what fraction of driverRange can be used
 
bool setPosTarget (float _posTarget, bool _run=true)
 set target position (motor drives towards position, following acceleration profile)
 
bool setPosSetpoint (float _posSetpoint, bool _run=true)
 set position for motor to drive towards position as fast as possible (setpoint for control loop if available)
 
bool setPosDelta (float _posDelta, bool _run=true, bool _resetPos=false)
 alternative method for setting velocity that uses setPosSetpoint
 
float getPosSetpoint ()
 get position controller is currently trying to get to
 
float resetPos ()
 reset what position the controller thinks it's in
 
bool isPosModeNotVelocity ()
 true if controller is in position target mode, false if in velocity mode
 

Public Attributes

bool grippingGently
 true=gripping, false = other servo movmement set
 
JServoStallSensingstallSensor
 
- Public Attributes inherited from JServoController
Derivs_Limiter dL
 instance of Derivs_Limiter class used to smoothly move servo
 

Protected Attributes

bool gripDirPos
 
float targetForce
 
float gripSpeed
 
- Protected Attributes inherited from JServoController
JMotorDriverServoservo
 reference to driver that's a subclass of JMotorDriverServo
 
unsigned long disableTimeout
 variable for how long to wait if not moved before disabling (default: 0, never disable)
 
float minAngleLimit
 lower limit for angle setpoint
 
float maxAngleLimit
 higher limit for angle setpoint
 
float minSetAngle
 when servodriver is set to getMinValue what angle is the servo?
 
float maxSetAngle
 when servodriver is set to getMaxValue what angle is the servo?
 
bool reverse
 reverse range of servo
 
unsigned long lastMovedMillis
 variable used to keep track of how long the servo has been still for
 
bool enabled
 keep track of whether controller is enabled (since even when controller is enabled driver might be disabled if timedout and sleeping)
 
bool sleeping
 has it been longer than disableTimeout since the servo has moved?
 

Additional Inherited Members

- Protected Member Functions inherited from JServoController
void writeAngleToServo (float ang)
 
float floatMap (float x, float in_min, float in_max, float out_min, float out_max)
 

Detailed Description

JServoControllerGentle is an extension of JServoController that uses JServoStallSensing to make a servo grip with a specific amount of force.

Constructor & Destructor Documentation

◆ JServoControllerGentle()

JServoControllerGentle::JServoControllerGentle ( JServoControllerAdvanced  servo,
JServoStallSensing servoStallSensor,
float  _targetForce = .05,
float  _gripSpeed = 30 
)
inline

Constructor for JServoController Gentle (a child class of JServoController)

Parameters
servo
servoStallSensor
_targetForcetarget force as measured by JServoStallSensing (if set too low, gripping may not work since just moving the servo could take more than the set power)
_gripSpeed

Member Function Documentation

◆ gripGently()

void JServoControllerGentle::gripGently ( bool  _dirPos,
float  _targetForce = NAN,
float  _gripSpeed = NAN,
bool  _run = false 
)
inline

have the servo move until it is pushing with a set amount of force

Parameters
_dirPos(bool) true = move in positive direction, false = move in negative direction
_targetForce(float, default NAN) if not NAN, override default setting for how hard to grip
_gripSpeed(float, default NAN) if not NAN, override default setting for how fast to move
_run(bool, default false) true = call run() in this function, false = you'll call run() yourself

◆ run()

virtual void JServoControllerGentle::run ( )
inlinevirtual

call this in your main loop

Reimplemented from JServoController.

◆ setAngleImmediate()

void JServoControllerGentle::setAngleImmediate ( float  angle,
bool  _run = true 
)
inline

◆ setAngleImmediateInc()

void JServoControllerGentle::setAngleImmediateInc ( float  angleDiff,
bool  _run = true 
)
inline

◆ setAngleSmoothed()

void JServoControllerGentle::setAngleSmoothed ( float  angle,
bool  _run = true 
)
inline

◆ setPosition()

void JServoControllerGentle::setPosition ( float  pos,
bool  _run 
)
inline

Member Data Documentation

◆ gripDirPos

bool JServoControllerGentle::gripDirPos
protected

◆ grippingGently

bool JServoControllerGentle::grippingGently

true=gripping, false = other servo movmement set

◆ gripSpeed

float JServoControllerGentle::gripSpeed
protected

◆ stallSensor

JServoStallSensing& JServoControllerGentle::stallSensor

◆ targetForce

float JServoControllerGentle::targetForce
protected

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